From 31dd49b2758f68f72c8adb6a90cec6f8320a6c63 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 8 Jan 2026 22:34:17 +0100 Subject: [PATCH 001/100] wip --- programs/futarchy/src/events.rs | 1 + programs/futarchy/src/instructions/initialize_dao.rs | 3 +++ programs/futarchy/src/instructions/update_dao.rs | 8 ++++++++ programs/futarchy/src/state/dao.rs | 6 ++++++ scripts/v0.6/launchSOLO.ts | 3 +-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/programs/futarchy/src/events.rs b/programs/futarchy/src/events.rs index 5e96aedf6..a718a725b 100644 --- a/programs/futarchy/src/events.rs +++ b/programs/futarchy/src/events.rs @@ -69,6 +69,7 @@ pub struct UpdateDaoEvent { pub base_to_stake: u64, pub team_sponsored_pass_threshold_bps: i16, pub team_address: Pubkey, + pub is_optimistic_governance_enabled: bool, } #[event] diff --git a/programs/futarchy/src/instructions/initialize_dao.rs b/programs/futarchy/src/instructions/initialize_dao.rs index a2503459f..4e8afc591 100644 --- a/programs/futarchy/src/instructions/initialize_dao.rs +++ b/programs/futarchy/src/instructions/initialize_dao.rs @@ -212,6 +212,9 @@ impl InitializeDao<'_> { }, team_sponsored_pass_threshold_bps, team_address, + active_optimistic_squads_proposal: None, + active_optimistic_squads_proposal_enqueued_timestamp: None, + is_optimistic_governance_enabled: false, }); dao.invariant()?; diff --git a/programs/futarchy/src/instructions/update_dao.rs b/programs/futarchy/src/instructions/update_dao.rs index 3d3babb39..2a2e5e667 100644 --- a/programs/futarchy/src/instructions/update_dao.rs +++ b/programs/futarchy/src/instructions/update_dao.rs @@ -12,6 +12,7 @@ pub struct UpdateDaoParams { pub base_to_stake: Option, pub team_sponsored_pass_threshold_bps: Option, pub team_address: Option, + pub is_optimistic_governance_enabled: Option, } #[derive(Accounts)] @@ -64,6 +65,12 @@ impl UpdateDao<'_> { .team_sponsored_pass_threshold_bps .unwrap_or(dao.team_sponsored_pass_threshold_bps), team_address: dao_params.team_address.unwrap_or(dao.team_address), + active_optimistic_squads_proposal: dao.active_optimistic_squads_proposal, + active_optimistic_squads_proposal_enqueued_timestamp: dao + .active_optimistic_squads_proposal_enqueued_timestamp, + is_optimistic_governance_enabled: dao_params + .is_optimistic_governance_enabled + .unwrap_or(dao.is_optimistic_governance_enabled), }); dao.seq_num += 1; @@ -84,6 +91,7 @@ impl UpdateDao<'_> { base_to_stake: dao.base_to_stake, team_sponsored_pass_threshold_bps: dao.team_sponsored_pass_threshold_bps, team_address: dao.team_address, + is_optimistic_governance_enabled: dao.is_optimistic_governance_enabled, }); Ok(()) diff --git a/programs/futarchy/src/state/dao.rs b/programs/futarchy/src/state/dao.rs index 24e066cae..61248646a 100644 --- a/programs/futarchy/src/state/dao.rs +++ b/programs/futarchy/src/state/dao.rs @@ -56,6 +56,12 @@ pub struct Dao { /// Can be negative to allow for team-sponsored proposals to pass by default. pub team_sponsored_pass_threshold_bps: i16, pub team_address: Pubkey, + /// The squads proposal currently enqueued for execution if not challenged by a new proposal. + pub active_optimistic_squads_proposal: Option, + /// The timestamp when the active optimistic squads proposal was enqueued. + pub active_optimistic_squads_proposal_enqueued_timestamp: Option, + /// Whether optimistic governance is enabled for this DAO. + pub is_optimistic_governance_enabled: bool, } #[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, PartialEq, Eq, InitSpace)] diff --git a/scripts/v0.6/launchSOLO.ts b/scripts/v0.6/launchSOLO.ts index 37e129268..0ec11ec52 100644 --- a/scripts/v0.6/launchSOLO.ts +++ b/scripts/v0.6/launchSOLO.ts @@ -74,8 +74,7 @@ export const launch = async () => { .initializeLaunchIx({ tokenName: "Solomon", tokenSymbol: "SOLO", - tokenUri: - "https://solomonlabs.org/assets/solo.json", + tokenUri: "https://solomonlabs.org/assets/solo.json", minimumRaiseAmount: new BN(MIN_GOAL * 10 ** 6), baseMint: TOKEN, monthlySpendingLimitAmount: new BN(SPENDING_LIMIT * 10 ** 6), From a303f5c7ec42a5f13a69c9426b7ffb286a30d52a Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 9 Jan 2026 01:25:55 +0100 Subject: [PATCH 002/100] wip --- programs/futarchy/src/error.rs | 4 + .../instructions/collect_meteora_damm_fees.rs | 103 ---------- ...nitiate_vault_spend_optimistic_proposal.rs | 188 ++++++++++++++++++ programs/futarchy/src/instructions/mod.rs | 2 + programs/futarchy/src/lib.rs | 10 + programs/futarchy/src/squads.rs | 107 ++++++++++ sdk/src/v0.7/types/futarchy.ts | 68 +++++++ 7 files changed, 379 insertions(+), 103 deletions(-) create mode 100644 programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs create mode 100644 programs/futarchy/src/squads.rs diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index e40223c50..3a6f26b2b 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -76,4 +76,8 @@ pub enum FutarchyError { InvalidTargetK, #[msg("Failed to compile transaction message for Squads vault transaction")] InvalidTransactionMessage, + #[msg("Invalid recipient")] + InvalidRecipient, + #[msg("Optimistic governance is disabled")] + OptimisticGovernanceDisabled, } diff --git a/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs b/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs index d068f5e2d..d4125ef05 100644 --- a/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs +++ b/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs @@ -1,7 +1,6 @@ use anchor_lang::AnchorSerialize; use anchor_lang::InstructionData; use damm_v2_cpi::program::DammV2Cpi; -use std::collections::BTreeMap; use super::*; @@ -399,105 +398,3 @@ impl CollectMeteoraDammFees<'_> { Ok(()) } } - -/// Compiles a Solana instruction into a Squads TransactionMessage format. -/// This is necessary because Solana's Message::serialize() uses a different header format -/// (num_readonly_signed_accounts, num_readonly_unsigned_accounts) than Squads expects -/// (num_writable_signers, num_writable_non_signers). -fn compile_transaction_message( - vault_key: &Pubkey, - instructions: &[anchor_lang::solana_program::instruction::Instruction], -) -> Result { - // Track account metadata: (is_signer, is_writable) - let mut key_meta_map: BTreeMap = BTreeMap::new(); - - // Add vault as a signer (it will sign the vault transaction) - // Writability is determined by whether it appears as writable in instruction accounts - key_meta_map.insert(*vault_key, (true, false)); - - // Collect all accounts from instructions, merging their flags with OR - for ix in instructions { - // Program ID is a non-signer, non-writable account - key_meta_map.entry(ix.program_id).or_insert((false, false)); - - for meta in &ix.accounts { - let entry = key_meta_map.entry(meta.pubkey).or_insert((false, false)); - entry.0 |= meta.is_signer; - entry.1 |= meta.is_writable; - } - } - - // Sort accounts into: writable signers, readonly signers, writable non-signers, readonly non-signers - let mut writable_signers: Vec = Vec::new(); - let mut readonly_signers: Vec = Vec::new(); - let mut writable_non_signers: Vec = Vec::new(); - let mut readonly_non_signers: Vec = Vec::new(); - - for (pubkey, (is_signer, is_writable)) in &key_meta_map { - if *is_signer && *is_writable { - writable_signers.push(*pubkey); - } else if *is_signer { - // Vault key should be first among readonly signers - if *pubkey == *vault_key { - readonly_signers.insert(0, *pubkey); - } else { - readonly_signers.push(*pubkey); - } - } else if *is_writable { - writable_non_signers.push(*pubkey); - } else { - readonly_non_signers.push(*pubkey); - } - } - - // Build the final account keys list in sorted order - let mut account_keys: Vec = Vec::new(); - account_keys.extend(&writable_signers); - account_keys.extend(&readonly_signers); - account_keys.extend(&writable_non_signers); - account_keys.extend(&readonly_non_signers); - - // Calculate counts - let num_signers = (writable_signers.len() + readonly_signers.len()) as u8; - let num_writable_signers = writable_signers.len() as u8; - let num_writable_non_signers = writable_non_signers.len() as u8; - - // Build account key index lookup - let key_to_index: BTreeMap = account_keys - .iter() - .enumerate() - .map(|(i, k)| (*k, i as u8)) - .collect(); - - // Compile instructions with new indices - let mut compiled_instructions: Vec = Vec::new(); - for ix in instructions { - let program_id_index = *key_to_index - .get(&ix.program_id) - .ok_or(FutarchyError::InvalidTransactionMessage)?; - - let account_indexes: Vec = ix - .accounts - .iter() - .map(|meta| key_to_index.get(&meta.pubkey).copied()) - .collect::>>() - .ok_or(FutarchyError::InvalidTransactionMessage)?; - - compiled_instructions.push(squads_multisig_program::CompiledInstruction { - program_id_index, - account_indexes: squads_multisig_program::SmallVec::from(account_indexes), - data: squads_multisig_program::SmallVec::from(ix.data.clone()), - }); - } - - Ok(squads_multisig_program::TransactionMessage { - num_signers, - num_writable_signers, - num_writable_non_signers, - account_keys: squads_multisig_program::SmallVec::from(account_keys), - instructions: squads_multisig_program::SmallVec::from(compiled_instructions), - address_table_lookups: squads_multisig_program::SmallVec::from(Vec::< - squads_multisig_program::MessageAddressTableLookup, - >::new()), - }) -} diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs new file mode 100644 index 000000000..241efdc5b --- /dev/null +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -0,0 +1,188 @@ +use super::*; + +#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize, PartialEq, Eq)] +pub struct InitiateVaultSpendOptimisticProposalParams { + pub amount: u64, +} + +#[derive(Accounts)] +#[event_cpi] +pub struct InitiateVaultSpendOptimisticProposal<'info> { + #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] + pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], bump, seeds::program = squads_program)] + pub squads_multisig_vault: UncheckedAccount<'info>, + #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = squads_program)] + pub squads_spending_limit: Account<'info, squads_multisig_program::SpendingLimit>, + // Probably need to use unchecked account, as these are not yet initialized + #[account(mut)] + pub squads_proposal: Box>, + #[account(mut)] + pub squads_vault_transaction: Box>, + + #[account(mut)] + pub dao: Box>, + #[account(mut, address = dao.team_address)] + pub proposer: Signer<'info>, + + #[account(address = permissionless_account::id())] + pub squads_multisig_permissionless_account: Signer<'info>, + + pub recipient: UncheckedAccount<'info>, + #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = recipient)] + pub recipient_quote_account: Account<'info, TokenAccount>, + + #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = dao.squads_multisig_vault)] + pub dao_quote_vault_account: Account<'info, TokenAccount>, + + #[account(mut)] + pub payer: Signer<'info>, + pub system_program: Program<'info, System>, + pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, + pub token_program: Program<'info, Token>, +} + +impl InitiateVaultSpendOptimisticProposal<'_> { + pub fn validate(&self, params: &InitiateVaultSpendOptimisticProposalParams) -> Result<()> { + require_keys_eq!(self.squads_proposal.multisig, self.dao.squads_multisig); + + // Optimistic governance must be enabled + require!( + self.dao.is_optimistic_governance_enabled, + FutarchyError::OptimisticGovernanceDisabled + ); + + // Pool must be in spot state - no active proposals + match self.dao.amm.state { + PoolState::Spot { spot: _ } => {} + _ => { + return Err(FutarchyError::PoolNotInSpotState.into()); + } + } + + // A minimum of proposal duration must have passed since the last optimistic proposal was enqueued + match self + .dao + .active_optimistic_squads_proposal_enqueued_timestamp + { + Some(enqueued_timestamp) => { + require_gte!( + Clock::get()?.unix_timestamp, + enqueued_timestamp + self.dao.seconds_per_proposal as i64, + FutarchyError::ProposalDurationTooShort + ); + } + None => {} + }; + + // Amount must be less than or equal to 3 times the spending limit + require_gte!( + self.squads_spending_limit.amount.checked_mul(3).unwrap(), + params.amount, + FutarchyError::InvalidAmount + ); + + Ok(()) + } + + pub fn handle( + ctx: Context, + params: InitiateVaultSpendOptimisticProposalParams, + ) -> Result<()> { + let Self { + squads_multisig, + squads_multisig_vault, + squads_spending_limit, + squads_proposal, + squads_vault_transaction: squads_transaction, + dao, + payer: _, + system_program: _, + event_authority: _, + program: _, + squads_program: _, + proposer, + recipient, + recipient_quote_account, + squads_multisig_permissionless_account, + token_program, + dao_quote_vault_account, + } = ctx.accounts; + + let ix = anchor_spl::token::spl_token::instruction::transfer( + &ctx.accounts.token_program.key(), + &ctx.accounts.dao_quote_vault_account.key(), + &ctx.accounts.recipient_quote_account.key(), + &ctx.accounts.dao.squads_multisig_vault.key(), + &[&ctx.accounts.squads_multisig_vault.key()], + params.amount, + )?; + + // Compile the transaction message in Squads' format + let transaction_message = + compile_transaction_message(&ctx.accounts.squads_multisig_vault.key(), &[ix])?; + + let transaction_message_bytes = transaction_message.try_to_vec()?; + + let dao_nonce = &ctx.accounts.dao.nonce.to_le_bytes(); + let dao_creator_key = ctx.accounts.dao.dao_creator.as_ref(); + let dao_seeds = &[ + b"dao".as_ref(), + dao_creator_key, + dao_nonce, + &[ctx.accounts.dao.pda_bump], + ]; + + let dao_signer = &[&dao_seeds[..]]; + + // Create the squads transaction + squads_multisig_program::cpi::vault_transaction_create( + CpiContext::new( + ctx.accounts.squads_program.to_account_info(), + squads_multisig_program::cpi::accounts::VaultTransactionCreate { + creator: ctx + .accounts + .squads_multisig_permissionless_account + .to_account_info(), + multisig: ctx.accounts.squads_multisig.to_account_info(), + rent_payer: ctx.accounts.proposer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + transaction: ctx.accounts.squads_vault_transaction.to_account_info(), + }, + ), + squads_multisig_program::VaultTransactionCreateArgs { + ephemeral_signers: 0, + vault_index: 0, + transaction_message: transaction_message_bytes, + memo: None, + }, + )?; + // Create the squads proposal + + // Update the DAO state + let clock = Clock::get()?; + + ctx.accounts.dao.active_optimistic_squads_proposal = Some(squads_proposal.key()); + ctx.accounts + .dao + .active_optimistic_squads_proposal_enqueued_timestamp = Some(clock.unix_timestamp); + + // emit_cpi!(InitializeProposalEvent { + // common: CommonFields::new(&clock, dao.seq_num), + // proposal: proposal.key(), + // dao: dao.key(), + // question: question.key(), + // base_vault: base_vault.key(), + // quote_vault: quote_vault.key(), + // proposer: proposer.key(), + // number: dao.proposal_count, + // pda_bump: ctx.bumps.proposal, + // duration_in_seconds: proposal.duration_in_seconds, + // squads_proposal: squads_proposal.key(), + // squads_multisig: dao.squads_multisig, + // squads_multisig_vault: dao.squads_multisig_vault, + // }); + + Ok(()) + } +} diff --git a/programs/futarchy/src/instructions/mod.rs b/programs/futarchy/src/instructions/mod.rs index a43513a64..4f0886052 100644 --- a/programs/futarchy/src/instructions/mod.rs +++ b/programs/futarchy/src/instructions/mod.rs @@ -7,6 +7,7 @@ pub mod execute_spending_limit_change; pub mod finalize_proposal; pub mod initialize_dao; pub mod initialize_proposal; +pub mod initiate_vault_spend_optimistic_proposal; pub mod launch_proposal; pub mod provide_liquidity; pub mod sponsor_proposal; @@ -23,6 +24,7 @@ pub use execute_spending_limit_change::*; pub use finalize_proposal::*; pub use initialize_dao::*; pub use initialize_proposal::*; +pub use initiate_vault_spend_optimistic_proposal::*; pub use launch_proposal::*; pub use provide_liquidity::*; pub use sponsor_proposal::*; diff --git a/programs/futarchy/src/lib.rs b/programs/futarchy/src/lib.rs index 6971fb523..37494c8f6 100644 --- a/programs/futarchy/src/lib.rs +++ b/programs/futarchy/src/lib.rs @@ -7,11 +7,13 @@ use conditional_vault::{ConditionalVault, Question}; pub mod error; pub mod events; pub mod instructions; +pub mod squads; pub mod state; pub use error::FutarchyError; pub use events::*; pub use instructions::*; +pub use squads::*; pub use state::*; #[cfg(not(feature = "no-entrypoint"))] @@ -147,4 +149,12 @@ pub mod futarchy { pub fn collect_meteora_damm_fees(ctx: Context) -> Result<()> { CollectMeteoraDammFees::handle(ctx) } + + #[access_control(ctx.accounts.validate(¶ms))] + pub fn initiate_vault_spend_optimistic_proposal( + ctx: Context, + params: InitiateVaultSpendOptimisticProposalParams, + ) -> Result<()> { + InitiateVaultSpendOptimisticProposal::handle(ctx, params) + } } diff --git a/programs/futarchy/src/squads.rs b/programs/futarchy/src/squads.rs new file mode 100644 index 000000000..ef85474c5 --- /dev/null +++ b/programs/futarchy/src/squads.rs @@ -0,0 +1,107 @@ +use anchor_lang::prelude::*; + +use std::collections::BTreeMap; + +use crate::FutarchyError; + +/// Compiles a Solana instruction into a Squads TransactionMessage format. +/// This is necessary because Solana's Message::serialize() uses a different header format +/// (num_readonly_signed_accounts, num_readonly_unsigned_accounts) than Squads expects +/// (num_writable_signers, num_writable_non_signers). +pub fn compile_transaction_message( + vault_key: &Pubkey, + instructions: &[anchor_lang::solana_program::instruction::Instruction], +) -> Result { + // Track account metadata: (is_signer, is_writable) + let mut key_meta_map: BTreeMap = BTreeMap::new(); + + // Add vault as a signer (it will sign the vault transaction) + // Writability is determined by whether it appears as writable in instruction accounts + key_meta_map.insert(*vault_key, (true, false)); + + // Collect all accounts from instructions, merging their flags with OR + for ix in instructions { + // Program ID is a non-signer, non-writable account + key_meta_map.entry(ix.program_id).or_insert((false, false)); + + for meta in &ix.accounts { + let entry = key_meta_map.entry(meta.pubkey).or_insert((false, false)); + entry.0 |= meta.is_signer; + entry.1 |= meta.is_writable; + } + } + + // Sort accounts into: writable signers, readonly signers, writable non-signers, readonly non-signers + let mut writable_signers: Vec = Vec::new(); + let mut readonly_signers: Vec = Vec::new(); + let mut writable_non_signers: Vec = Vec::new(); + let mut readonly_non_signers: Vec = Vec::new(); + + for (pubkey, (is_signer, is_writable)) in &key_meta_map { + if *is_signer && *is_writable { + writable_signers.push(*pubkey); + } else if *is_signer { + // Vault key should be first among readonly signers + if *pubkey == *vault_key { + readonly_signers.insert(0, *pubkey); + } else { + readonly_signers.push(*pubkey); + } + } else if *is_writable { + writable_non_signers.push(*pubkey); + } else { + readonly_non_signers.push(*pubkey); + } + } + + // Build the final account keys list in sorted order + let mut account_keys: Vec = Vec::new(); + account_keys.extend(&writable_signers); + account_keys.extend(&readonly_signers); + account_keys.extend(&writable_non_signers); + account_keys.extend(&readonly_non_signers); + + // Calculate counts + let num_signers = (writable_signers.len() + readonly_signers.len()) as u8; + let num_writable_signers = writable_signers.len() as u8; + let num_writable_non_signers = writable_non_signers.len() as u8; + + // Build account key index lookup + let key_to_index: BTreeMap = account_keys + .iter() + .enumerate() + .map(|(i, k)| (*k, i as u8)) + .collect(); + + // Compile instructions with new indices + let mut compiled_instructions: Vec = Vec::new(); + for ix in instructions { + let program_id_index = *key_to_index + .get(&ix.program_id) + .ok_or(FutarchyError::InvalidTransactionMessage)?; + + let account_indexes: Vec = ix + .accounts + .iter() + .map(|meta| key_to_index.get(&meta.pubkey).copied()) + .collect::>>() + .ok_or(FutarchyError::InvalidTransactionMessage)?; + + compiled_instructions.push(squads_multisig_program::CompiledInstruction { + program_id_index, + account_indexes: squads_multisig_program::SmallVec::from(account_indexes), + data: squads_multisig_program::SmallVec::from(ix.data.clone()), + }); + } + + Ok(squads_multisig_program::TransactionMessage { + num_signers, + num_writable_signers, + num_writable_non_signers, + account_keys: squads_multisig_program::SmallVec::from(account_keys), + instructions: squads_multisig_program::SmallVec::from(compiled_instructions), + address_table_lookups: squads_multisig_program::SmallVec::from(Vec::< + squads_multisig_program::MessageAddressTableLookup, + >::new()), + }) +} diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 19b1d17ff..adde546ce 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -1325,6 +1325,29 @@ export type Futarchy = { name: "teamAddress"; type: "publicKey"; }, + { + name: "activeOptimisticSquadsProposal"; + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "activeOptimisticSquadsProposalEnqueuedTimestamp"; + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "isOptimisticGovernanceEnabled"; + docs: ["Whether optimistic governance is enabled for this DAO."]; + type: "bool"; + }, ]; }; }, @@ -1678,6 +1701,12 @@ export type Futarchy = { option: "publicKey"; }; }, + { + name: "isOptimisticGovernanceEnabled"; + type: { + option: "bool"; + }; + }, ]; }; }, @@ -2198,6 +2227,11 @@ export type Futarchy = { type: "publicKey"; index: false; }, + { + name: "isOptimisticGovernanceEnabled"; + type: "bool"; + index: false; + }, ]; }, { @@ -4254,6 +4288,29 @@ export const IDL: Futarchy = { name: "teamAddress", type: "publicKey", }, + { + name: "activeOptimisticSquadsProposal", + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "activeOptimisticSquadsProposalEnqueuedTimestamp", + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ], + type: { + option: "i64", + }, + }, + { + name: "isOptimisticGovernanceEnabled", + docs: ["Whether optimistic governance is enabled for this DAO."], + type: "bool", + }, ], }, }, @@ -4607,6 +4664,12 @@ export const IDL: Futarchy = { option: "publicKey", }, }, + { + name: "isOptimisticGovernanceEnabled", + type: { + option: "bool", + }, + }, ], }, }, @@ -5127,6 +5190,11 @@ export const IDL: Futarchy = { type: "publicKey", index: false, }, + { + name: "isOptimisticGovernanceEnabled", + type: "bool", + index: false, + }, ], }, { From 81064fd10c43ad796e3d758ac7fc4cb58509502e Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 9 Jan 2026 02:10:06 +0100 Subject: [PATCH 003/100] implementation of initiation of new optimistic governance proposal --- programs/futarchy/src/events.rs | 15 + ...nitiate_vault_spend_optimistic_proposal.rs | 111 +++--- sdk/src/v0.7/types/futarchy.ts | 364 ++++++++++++++++++ 3 files changed, 441 insertions(+), 49 deletions(-) diff --git a/programs/futarchy/src/events.rs b/programs/futarchy/src/events.rs index a718a725b..61f6d409f 100644 --- a/programs/futarchy/src/events.rs +++ b/programs/futarchy/src/events.rs @@ -204,3 +204,18 @@ pub struct CollectMeteoraDammFeesEvent { pub quote_fees_collected: u64, pub base_fees_collected: u64, } + +#[event] +pub struct InitiateVaultSpendOptimisticProposalEvent { + pub common: CommonFields, + pub dao: Pubkey, + pub proposer: Pubkey, + pub squads_proposal: Pubkey, + pub squads_multisig: Pubkey, + pub squads_multisig_vault: Pubkey, + pub amount: u64, + pub recipient: Pubkey, + pub dao_quote_vault_account: Pubkey, + pub recipient_quote_account: Pubkey, + pub enqueued_timestamp: i64, +} diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 241efdc5b..5c05efb3b 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -10,6 +10,7 @@ pub struct InitiateVaultSpendOptimisticProposalParams { pub struct InitiateVaultSpendOptimisticProposal<'info> { #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, + /// CHECK: The squads multisig vault that executes the transaction #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig_vault: UncheckedAccount<'info>, #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = squads_program)] @@ -28,6 +29,7 @@ pub struct InitiateVaultSpendOptimisticProposal<'info> { #[account(address = permissionless_account::id())] pub squads_multisig_permissionless_account: Signer<'info>, + /// CHECK: Used for constraints pub recipient: UncheckedAccount<'info>, #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = recipient)] pub recipient_quote_account: Account<'info, TokenAccount>, @@ -92,17 +94,17 @@ impl InitiateVaultSpendOptimisticProposal<'_> { let Self { squads_multisig, squads_multisig_vault, - squads_spending_limit, + squads_spending_limit: _, squads_proposal, - squads_vault_transaction: squads_transaction, + squads_vault_transaction, dao, payer: _, - system_program: _, + system_program, event_authority: _, program: _, - squads_program: _, + squads_program, proposer, - recipient, + recipient: _, recipient_quote_account, squads_multisig_permissionless_account, token_program, @@ -110,44 +112,35 @@ impl InitiateVaultSpendOptimisticProposal<'_> { } = ctx.accounts; let ix = anchor_spl::token::spl_token::instruction::transfer( - &ctx.accounts.token_program.key(), - &ctx.accounts.dao_quote_vault_account.key(), - &ctx.accounts.recipient_quote_account.key(), - &ctx.accounts.dao.squads_multisig_vault.key(), - &[&ctx.accounts.squads_multisig_vault.key()], + &token_program.key(), + &dao_quote_vault_account.key(), + &recipient_quote_account.key(), + &squads_multisig_vault.key(), + &[&squads_multisig_vault.key()], params.amount, )?; // Compile the transaction message in Squads' format - let transaction_message = - compile_transaction_message(&ctx.accounts.squads_multisig_vault.key(), &[ix])?; + let transaction_message = compile_transaction_message(&squads_multisig_vault.key(), &[ix])?; let transaction_message_bytes = transaction_message.try_to_vec()?; - let dao_nonce = &ctx.accounts.dao.nonce.to_le_bytes(); - let dao_creator_key = ctx.accounts.dao.dao_creator.as_ref(); - let dao_seeds = &[ - b"dao".as_ref(), - dao_creator_key, - dao_nonce, - &[ctx.accounts.dao.pda_bump], - ]; + let dao_nonce = &dao.nonce.to_le_bytes(); + let dao_creator_key = dao.dao_creator.as_ref(); + let dao_seeds = &[b"dao".as_ref(), dao_creator_key, dao_nonce, &[dao.pda_bump]]; let dao_signer = &[&dao_seeds[..]]; // Create the squads transaction squads_multisig_program::cpi::vault_transaction_create( CpiContext::new( - ctx.accounts.squads_program.to_account_info(), + squads_program.to_account_info(), squads_multisig_program::cpi::accounts::VaultTransactionCreate { - creator: ctx - .accounts - .squads_multisig_permissionless_account - .to_account_info(), - multisig: ctx.accounts.squads_multisig.to_account_info(), - rent_payer: ctx.accounts.proposer.to_account_info(), - system_program: ctx.accounts.system_program.to_account_info(), - transaction: ctx.accounts.squads_vault_transaction.to_account_info(), + creator: squads_multisig_permissionless_account.to_account_info(), + multisig: squads_multisig.to_account_info(), + rent_payer: proposer.to_account_info(), + system_program: system_program.to_account_info(), + transaction: squads_vault_transaction.to_account_info(), }, ), squads_multisig_program::VaultTransactionCreateArgs { @@ -157,31 +150,51 @@ impl InitiateVaultSpendOptimisticProposal<'_> { memo: None, }, )?; + + // Reload the squads multisig account to get the latest transaction index + squads_multisig.reload()?; + let transaction_index = squads_multisig.transaction_index; + // Create the squads proposal + squads_multisig_program::cpi::proposal_create( + CpiContext::new_with_signer( + squads_program.to_account_info(), + squads_multisig_program::cpi::accounts::ProposalCreate { + // DAO is the config authority - maybe this needs to be the permissionless account instead? + creator: dao.to_account_info(), + multisig: squads_multisig.to_account_info(), + rent_payer: proposer.to_account_info(), + system_program: system_program.to_account_info(), + proposal: squads_proposal.to_account_info(), + }, + dao_signer, + ), + squads_multisig_program::ProposalCreateArgs { + transaction_index, + draft: false, + }, + )?; // Update the DAO state let clock = Clock::get()?; - ctx.accounts.dao.active_optimistic_squads_proposal = Some(squads_proposal.key()); - ctx.accounts - .dao - .active_optimistic_squads_proposal_enqueued_timestamp = Some(clock.unix_timestamp); - - // emit_cpi!(InitializeProposalEvent { - // common: CommonFields::new(&clock, dao.seq_num), - // proposal: proposal.key(), - // dao: dao.key(), - // question: question.key(), - // base_vault: base_vault.key(), - // quote_vault: quote_vault.key(), - // proposer: proposer.key(), - // number: dao.proposal_count, - // pda_bump: ctx.bumps.proposal, - // duration_in_seconds: proposal.duration_in_seconds, - // squads_proposal: squads_proposal.key(), - // squads_multisig: dao.squads_multisig, - // squads_multisig_vault: dao.squads_multisig_vault, - // }); + dao.active_optimistic_squads_proposal = Some(squads_proposal.key()); + dao.active_optimistic_squads_proposal_enqueued_timestamp = Some(clock.unix_timestamp); + dao.seq_num += 1; + + emit_cpi!(InitiateVaultSpendOptimisticProposalEvent { + common: CommonFields::new(&clock, dao.seq_num), + dao: dao.key(), + proposer: proposer.key(), + squads_proposal: squads_proposal.key(), + squads_multisig: squads_multisig.key(), + squads_multisig_vault: squads_multisig_vault.key(), + amount: params.amount, + recipient: ctx.accounts.recipient.key(), + dao_quote_vault_account: dao_quote_vault_account.key(), + recipient_quote_account: recipient_quote_account.key(), + enqueued_timestamp: clock.unix_timestamp, + }); Ok(()) } diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index adde546ce..5c18c7ea1 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -1170,6 +1170,104 @@ export type Futarchy = { ]; args: []; }, + { + name: "initiateVaultSpendOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsSpendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisigPermissionlessAccount"; + isMut: false; + isSigner: true; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "recipientQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "daoQuoteVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitiateVaultSpendOptimisticProposalParams"; + }; + }, + ]; + }, ]; accounts: [ { @@ -1559,6 +1657,18 @@ export type Futarchy = { ]; }; }, + { + name: "InitiateVaultSpendOptimisticProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, { name: "ProvideLiquidityParams"; type: { @@ -2776,6 +2886,68 @@ export type Futarchy = { }, ]; }, + { + name: "InitiateVaultSpendOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "daoQuoteVaultAccount"; + type: "publicKey"; + index: false; + }, + { + name: "recipientQuoteAccount"; + type: "publicKey"; + index: false; + }, + { + name: "enqueuedTimestamp"; + type: "i64"; + index: false; + }, + ]; + }, ]; errors: [ { @@ -2958,6 +3130,16 @@ export type Futarchy = { name: "InvalidTransactionMessage"; msg: "Failed to compile transaction message for Squads vault transaction"; }, + { + code: 6036; + name: "InvalidRecipient"; + msg: "Invalid recipient"; + }, + { + code: 6037; + name: "OptimisticGovernanceDisabled"; + msg: "Optimistic governance is disabled"; + }, ]; }; @@ -4133,6 +4315,104 @@ export const IDL: Futarchy = { ], args: [], }, + { + name: "initiateVaultSpendOptimisticProposal", + accounts: [ + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsSpendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisigPermissionlessAccount", + isMut: false, + isSigner: true, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "recipientQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "daoQuoteVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitiateVaultSpendOptimisticProposalParams", + }, + }, + ], + }, ], accounts: [ { @@ -4522,6 +4802,18 @@ export const IDL: Futarchy = { ], }, }, + { + name: "InitiateVaultSpendOptimisticProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, { name: "ProvideLiquidityParams", type: { @@ -5739,6 +6031,68 @@ export const IDL: Futarchy = { }, ], }, + { + name: "InitiateVaultSpendOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "daoQuoteVaultAccount", + type: "publicKey", + index: false, + }, + { + name: "recipientQuoteAccount", + type: "publicKey", + index: false, + }, + { + name: "enqueuedTimestamp", + type: "i64", + index: false, + }, + ], + }, ], errors: [ { @@ -5921,5 +6275,15 @@ export const IDL: Futarchy = { name: "InvalidTransactionMessage", msg: "Failed to compile transaction message for Squads vault transaction", }, + { + code: 6036, + name: "InvalidRecipient", + msg: "Invalid recipient", + }, + { + code: 6037, + name: "OptimisticGovernanceDisabled", + msg: "Optimistic governance is disabled", + }, ], }; From 2e8545599eb24a2b6e1796f5a0e05a8214cbe702 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 9 Jan 2026 20:22:57 +0100 Subject: [PATCH 004/100] add finalize optimistic proposal ix --- programs/futarchy/src/error.rs | 4 + programs/futarchy/src/events.rs | 7 ++ .../instructions/collect_meteora_damm_fees.rs | 2 +- .../finalize_optimistic_proposal.rs | 89 +++++++++++++++++++ .../src/instructions/initialize_dao.rs | 3 +- ...nitiate_vault_spend_optimistic_proposal.rs | 28 +++--- programs/futarchy/src/instructions/mod.rs | 2 + .../futarchy/src/instructions/update_dao.rs | 4 +- programs/futarchy/src/lib.rs | 5 ++ programs/futarchy/src/squads.rs | 2 +- programs/futarchy/src/state/dao.rs | 12 ++- sdk/src/v0.7/types/futarchy.ts | 10 +++ 12 files changed, 146 insertions(+), 22 deletions(-) create mode 100644 programs/futarchy/src/instructions/finalize_optimistic_proposal.rs diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index 3a6f26b2b..ffb92cee0 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -80,4 +80,8 @@ pub enum FutarchyError { InvalidRecipient, #[msg("Optimistic governance is disabled")] OptimisticGovernanceDisabled, + #[msg("An active optimistic proposal is already enqueued")] + ActiveOptimisticProposalAlreadyEnqueued, + #[msg("No active optimistic proposal")] + NoActiveOptimisticProposal, } diff --git a/programs/futarchy/src/events.rs b/programs/futarchy/src/events.rs index 61f6d409f..7bddfb429 100644 --- a/programs/futarchy/src/events.rs +++ b/programs/futarchy/src/events.rs @@ -219,3 +219,10 @@ pub struct InitiateVaultSpendOptimisticProposalEvent { pub recipient_quote_account: Pubkey, pub enqueued_timestamp: i64, } + +#[event] +pub struct FinalizeOptimisticProposalEvent { + pub common: CommonFields, + pub dao: Pubkey, + pub squads_proposal: Pubkey, +} diff --git a/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs b/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs index d4125ef05..c15846bcb 100644 --- a/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs +++ b/programs/futarchy/src/instructions/collect_meteora_damm_fees.rs @@ -230,7 +230,7 @@ impl CollectMeteoraDammFees<'_> { // This correctly sets num_writable_signers and num_writable_non_signers // instead of the inverted readonly counts from Solana's Message::serialize() let transaction_message = - compile_transaction_message(&ctx.accounts.squads_multisig_vault.key(), &[ix])?; + compile_squads_transaction_message(&ctx.accounts.squads_multisig_vault.key(), &[ix])?; let transaction_message_bytes = transaction_message.try_to_vec()?; diff --git a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs new file mode 100644 index 000000000..a057df871 --- /dev/null +++ b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs @@ -0,0 +1,89 @@ +use super::*; + +#[derive(Accounts)] +#[event_cpi] +pub struct FinalizeOptimisticProposal<'info> { + #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] + pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, + #[account(mut, address = dao.optimistic_proposal.as_ref().unwrap().squads_proposal)] + pub squads_proposal: Box>, + + #[account(mut)] + pub dao: Box>, + + pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, +} + +impl FinalizeOptimisticProposal<'_> { + pub fn validate(&self) -> Result<()> { + require_keys_eq!(self.squads_proposal.multisig, self.dao.squads_multisig); + + // There should be an active optimistic proposal + let optimistic_proposal = match self.dao.optimistic_proposal { + Some(ref optimistic_proposal) => optimistic_proposal, + None => { + return Err(FutarchyError::NoActiveOptimisticProposal.into()); + } + }; + + // A minimum of proposal duration must have passed since the the optimistic proposal was enqueued + require_gte!( + Clock::get()?.unix_timestamp, + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, + FutarchyError::ProposalDurationTooShort + ); + + // Pool must be in spot state - no active proposals + // Realistically, this should never be hit, but it's here for completeness + match self.dao.amm.state { + PoolState::Spot { spot: _ } => {} + _ => { + return Err(FutarchyError::PoolNotInSpotState.into()); + } + } + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let Self { + squads_multisig, + squads_proposal, + dao, + event_authority: _, + program: _, + squads_program, + } = ctx.accounts; + + let dao_nonce = &dao.nonce.to_le_bytes(); + let dao_creator_key = dao.dao_creator.as_ref(); + let dao_seeds = &[b"dao".as_ref(), dao_creator_key, dao_nonce, &[dao.pda_bump]]; + + let dao_signer = &[&dao_seeds[..]]; + + squads_multisig_program::cpi::proposal_approve( + CpiContext::new_with_signer( + squads_program.to_account_info(), + squads_multisig_program::cpi::accounts::ProposalVote { + proposal: squads_proposal.to_account_info(), + multisig: squads_multisig.to_account_info(), + member: dao.to_account_info(), // DAO can approve the proposal + }, + dao_signer, + ), + squads_multisig_program::ProposalVoteArgs { memo: None }, + )?; + + // Update the DAO state + dao.optimistic_proposal = None; + dao.seq_num += 1; + + emit_cpi!(FinalizeOptimisticProposalEvent { + common: CommonFields::new(&Clock::get()?, dao.seq_num), + dao: dao.key(), + squads_proposal: squads_proposal.key(), + }); + + Ok(()) + } +} diff --git a/programs/futarchy/src/instructions/initialize_dao.rs b/programs/futarchy/src/instructions/initialize_dao.rs index 4e8afc591..2ec22bb4d 100644 --- a/programs/futarchy/src/instructions/initialize_dao.rs +++ b/programs/futarchy/src/instructions/initialize_dao.rs @@ -212,8 +212,7 @@ impl InitializeDao<'_> { }, team_sponsored_pass_threshold_bps, team_address, - active_optimistic_squads_proposal: None, - active_optimistic_squads_proposal_enqueued_timestamp: None, + optimistic_proposal: None, is_optimistic_governance_enabled: false, }); diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 5c05efb3b..f591a749f 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -62,15 +62,18 @@ impl InitiateVaultSpendOptimisticProposal<'_> { } } + // There should be no active optimistic proposal + require!( + self.dao.optimistic_proposal.is_none(), + FutarchyError::ActiveOptimisticProposalAlreadyEnqueued + ); + // A minimum of proposal duration must have passed since the last optimistic proposal was enqueued - match self - .dao - .active_optimistic_squads_proposal_enqueued_timestamp - { - Some(enqueued_timestamp) => { + match self.dao.optimistic_proposal { + Some(ref optimistic_proposal) => { require_gte!( Clock::get()?.unix_timestamp, - enqueued_timestamp + self.dao.seconds_per_proposal as i64, + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, FutarchyError::ProposalDurationTooShort ); } @@ -111,6 +114,7 @@ impl InitiateVaultSpendOptimisticProposal<'_> { dao_quote_vault_account, } = ctx.accounts; + // Prepare the transfer instruction let ix = anchor_spl::token::spl_token::instruction::transfer( &token_program.key(), &dao_quote_vault_account.key(), @@ -121,7 +125,8 @@ impl InitiateVaultSpendOptimisticProposal<'_> { )?; // Compile the transaction message in Squads' format - let transaction_message = compile_transaction_message(&squads_multisig_vault.key(), &[ix])?; + let transaction_message = + compile_squads_transaction_message(&squads_multisig_vault.key(), &[ix])?; let transaction_message_bytes = transaction_message.try_to_vec()?; @@ -160,8 +165,7 @@ impl InitiateVaultSpendOptimisticProposal<'_> { CpiContext::new_with_signer( squads_program.to_account_info(), squads_multisig_program::cpi::accounts::ProposalCreate { - // DAO is the config authority - maybe this needs to be the permissionless account instead? - creator: dao.to_account_info(), + creator: squads_multisig_permissionless_account.to_account_info(), multisig: squads_multisig.to_account_info(), rent_payer: proposer.to_account_info(), system_program: system_program.to_account_info(), @@ -178,8 +182,10 @@ impl InitiateVaultSpendOptimisticProposal<'_> { // Update the DAO state let clock = Clock::get()?; - dao.active_optimistic_squads_proposal = Some(squads_proposal.key()); - dao.active_optimistic_squads_proposal_enqueued_timestamp = Some(clock.unix_timestamp); + dao.optimistic_proposal = Some(OptimisticProposal { + squads_proposal: squads_proposal.key(), + enqueued_timestamp: clock.unix_timestamp, + }); dao.seq_num += 1; emit_cpi!(InitiateVaultSpendOptimisticProposalEvent { diff --git a/programs/futarchy/src/instructions/mod.rs b/programs/futarchy/src/instructions/mod.rs index 4f0886052..0737a5217 100644 --- a/programs/futarchy/src/instructions/mod.rs +++ b/programs/futarchy/src/instructions/mod.rs @@ -4,6 +4,7 @@ pub mod collect_fees; pub mod collect_meteora_damm_fees; pub mod conditional_swap; pub mod execute_spending_limit_change; +pub mod finalize_optimistic_proposal; pub mod finalize_proposal; pub mod initialize_dao; pub mod initialize_proposal; @@ -21,6 +22,7 @@ pub use collect_fees::*; pub use collect_meteora_damm_fees::*; pub use conditional_swap::*; pub use execute_spending_limit_change::*; +pub use finalize_optimistic_proposal::*; pub use finalize_proposal::*; pub use initialize_dao::*; pub use initialize_proposal::*; diff --git a/programs/futarchy/src/instructions/update_dao.rs b/programs/futarchy/src/instructions/update_dao.rs index 2a2e5e667..5e3cca489 100644 --- a/programs/futarchy/src/instructions/update_dao.rs +++ b/programs/futarchy/src/instructions/update_dao.rs @@ -65,9 +65,7 @@ impl UpdateDao<'_> { .team_sponsored_pass_threshold_bps .unwrap_or(dao.team_sponsored_pass_threshold_bps), team_address: dao_params.team_address.unwrap_or(dao.team_address), - active_optimistic_squads_proposal: dao.active_optimistic_squads_proposal, - active_optimistic_squads_proposal_enqueued_timestamp: dao - .active_optimistic_squads_proposal_enqueued_timestamp, + optimistic_proposal: dao.optimistic_proposal.clone(), is_optimistic_governance_enabled: dao_params .is_optimistic_governance_enabled .unwrap_or(dao.is_optimistic_governance_enabled), diff --git a/programs/futarchy/src/lib.rs b/programs/futarchy/src/lib.rs index 37494c8f6..89d2ab908 100644 --- a/programs/futarchy/src/lib.rs +++ b/programs/futarchy/src/lib.rs @@ -157,4 +157,9 @@ pub mod futarchy { ) -> Result<()> { InitiateVaultSpendOptimisticProposal::handle(ctx, params) } + + #[access_control(ctx.accounts.validate())] + pub fn finalize_optimistic_proposal(ctx: Context) -> Result<()> { + FinalizeOptimisticProposal::handle(ctx) + } } diff --git a/programs/futarchy/src/squads.rs b/programs/futarchy/src/squads.rs index ef85474c5..9a56b9a2e 100644 --- a/programs/futarchy/src/squads.rs +++ b/programs/futarchy/src/squads.rs @@ -8,7 +8,7 @@ use crate::FutarchyError; /// This is necessary because Solana's Message::serialize() uses a different header format /// (num_readonly_signed_accounts, num_readonly_unsigned_accounts) than Squads expects /// (num_writable_signers, num_writable_non_signers). -pub fn compile_transaction_message( +pub fn compile_squads_transaction_message( vault_key: &Pubkey, instructions: &[anchor_lang::solana_program::instruction::Instruction], ) -> Result { diff --git a/programs/futarchy/src/state/dao.rs b/programs/futarchy/src/state/dao.rs index 61248646a..dfed8ac6b 100644 --- a/programs/futarchy/src/state/dao.rs +++ b/programs/futarchy/src/state/dao.rs @@ -56,12 +56,16 @@ pub struct Dao { /// Can be negative to allow for team-sponsored proposals to pass by default. pub team_sponsored_pass_threshold_bps: i16, pub team_address: Pubkey, + pub optimistic_proposal: Option, + pub is_optimistic_governance_enabled: bool, +} + +#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, PartialEq, Eq, InitSpace)] +pub struct OptimisticProposal { /// The squads proposal currently enqueued for execution if not challenged by a new proposal. - pub active_optimistic_squads_proposal: Option, + pub squads_proposal: Pubkey, /// The timestamp when the active optimistic squads proposal was enqueued. - pub active_optimistic_squads_proposal_enqueued_timestamp: Option, - /// Whether optimistic governance is enabled for this DAO. - pub is_optimistic_governance_enabled: bool, + pub enqueued_timestamp: i64, } #[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, PartialEq, Eq, InitSpace)] diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 5c18c7ea1..10c59cee6 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -3140,6 +3140,11 @@ export type Futarchy = { name: "OptimisticGovernanceDisabled"; msg: "Optimistic governance is disabled"; }, + { + code: 6038; + name: "ActiveOptimisticProposalAlreadyEnqueued"; + msg: "An active optimistic proposal is already enqueued"; + }, ]; }; @@ -6285,5 +6290,10 @@ export const IDL: Futarchy = { name: "OptimisticGovernanceDisabled", msg: "Optimistic governance is disabled", }, + { + code: 6038, + name: "ActiveOptimisticProposalAlreadyEnqueued", + msg: "An active optimistic proposal is already enqueued", + }, ], }; From 7f458eae0355a94d8e0b26e1e0632fdddd41aa76 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 9 Jan 2026 20:47:39 +0100 Subject: [PATCH 005/100] launch_proposal should only be able to challenge an optimistic proposal if one exists --- .../src/instructions/launch_proposal.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/programs/futarchy/src/instructions/launch_proposal.rs b/programs/futarchy/src/instructions/launch_proposal.rs index 3d4d793d6..68f290f44 100644 --- a/programs/futarchy/src/instructions/launch_proposal.rs +++ b/programs/futarchy/src/instructions/launch_proposal.rs @@ -51,6 +51,16 @@ impl LaunchProposal<'_> { ); } + // If there is an active optimistic proposal, it must be for the same squads proposal + // as the futarchy proposal we're launching, thus challenging the optimistic proposal. + // This follows the logic that a DAO can have only one proposal active at a time. + if let Some(optimistic_proposal) = &self.dao.optimistic_proposal { + require_keys_eq!( + optimistic_proposal.squads_proposal, + self.proposal.squads_proposal + ); + } + Ok(()) } @@ -139,6 +149,14 @@ impl LaunchProposal<'_> { proposal.state = ProposalState::Pending; proposal.timestamp_enqueued = clock.unix_timestamp; + // Update the DAO state + if dao.optimistic_proposal.is_some() { + // The optimistic proposal is being challenged, so we are moving it into the futarchy proposal + // This means that the optimistic proposal now has to pass a decision market in order to be approved/executed + // verify() ensures that the optimistic proposal and squads proposal are the same + dao.optimistic_proposal = None; + } + dao.seq_num += 1; emit_cpi!(LaunchProposalEvent { From 63ed3338dc1d66715edaa55c3d811861ffe1e02d Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 9 Jan 2026 22:25:48 +0100 Subject: [PATCH 006/100] minor cleanups --- .../finalize_optimistic_proposal.rs | 2 +- ...nitiate_vault_spend_optimistic_proposal.rs | 37 +-- sdk/src/v0.7/types/futarchy.ts | 248 ++++++++++++++---- 3 files changed, 220 insertions(+), 67 deletions(-) diff --git a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs index a057df871..fac40a2b4 100644 --- a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs @@ -8,7 +8,7 @@ pub struct FinalizeOptimisticProposal<'info> { #[account(mut, address = dao.optimistic_proposal.as_ref().unwrap().squads_proposal)] pub squads_proposal: Box>, - #[account(mut)] + #[account(mut, has_one = squads_multisig)] pub dao: Box>, pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index f591a749f..e463d3ee1 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -10,35 +10,42 @@ pub struct InitiateVaultSpendOptimisticProposalParams { pub struct InitiateVaultSpendOptimisticProposal<'info> { #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, + /// CHECK: The squads multisig vault that executes the transaction #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig_vault: UncheckedAccount<'info>, - #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = squads_program)] + + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_spending_limit: Account<'info, squads_multisig_program::SpendingLimit>, - // Probably need to use unchecked account, as these are not yet initialized - #[account(mut)] - pub squads_proposal: Box>, + + /// CHECK: Squads multisig proposal, initialized by squads multisig program, checked by squads multisig program #[account(mut)] - pub squads_vault_transaction: Box>, + pub squads_proposal: UncheckedAccount<'info>, + /// CHECK: Squads multisig vault transaction, initialized by squads multisig program, checked by squads multisig program #[account(mut)] - pub dao: Box>, - #[account(mut, address = dao.team_address)] - pub proposer: Signer<'info>, + pub squads_vault_transaction: UncheckedAccount<'info>, #[account(address = permissionless_account::id())] pub squads_multisig_permissionless_account: Signer<'info>, + #[account(mut, has_one = squads_multisig, has_one = squads_multisig_vault)] + pub dao: Box>, + #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = dao.squads_multisig_vault)] + pub dao_quote_vault_account: Account<'info, TokenAccount>, + + // Only the team can initiate an optimistic proposal + #[account(mut, address = dao.team_address)] + pub proposer: Signer<'info>, + /// CHECK: Used for constraints pub recipient: UncheckedAccount<'info>, #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = recipient)] pub recipient_quote_account: Account<'info, TokenAccount>, - #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = dao.squads_multisig_vault)] - pub dao_quote_vault_account: Account<'info, TokenAccount>, - #[account(mut)] pub payer: Signer<'info>, + pub system_program: Program<'info, System>, pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, pub token_program: Program<'info, Token>, @@ -46,15 +53,13 @@ pub struct InitiateVaultSpendOptimisticProposal<'info> { impl InitiateVaultSpendOptimisticProposal<'_> { pub fn validate(&self, params: &InitiateVaultSpendOptimisticProposalParams) -> Result<()> { - require_keys_eq!(self.squads_proposal.multisig, self.dao.squads_multisig); - // Optimistic governance must be enabled require!( self.dao.is_optimistic_governance_enabled, FutarchyError::OptimisticGovernanceDisabled ); - // Pool must be in spot state - no active proposals + // Pool must be in spot state - no active proposal match self.dao.amm.state { PoolState::Spot { spot: _ } => {} _ => { @@ -115,7 +120,7 @@ impl InitiateVaultSpendOptimisticProposal<'_> { } = ctx.accounts; // Prepare the transfer instruction - let ix = anchor_spl::token::spl_token::instruction::transfer( + let transfer_ix = anchor_spl::token::spl_token::instruction::transfer( &token_program.key(), &dao_quote_vault_account.key(), &recipient_quote_account.key(), @@ -126,7 +131,7 @@ impl InitiateVaultSpendOptimisticProposal<'_> { // Compile the transaction message in Squads' format let transaction_message = - compile_squads_transaction_message(&squads_multisig_vault.key(), &[ix])?; + compile_squads_transaction_message(&squads_multisig_vault.key(), &[transfer_ix])?; let transaction_message_bytes = transaction_message.try_to_vec()?; diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 10c59cee6..d9d95cdc1 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -1185,7 +1185,7 @@ export type Futarchy = { }, { name: "squadsSpendingLimit"; - isMut: true; + isMut: false; isSigner: false; }, { @@ -1198,19 +1198,24 @@ export type Futarchy = { isMut: true; isSigner: false; }, + { + name: "squadsMultisigPermissionlessAccount"; + isMut: false; + isSigner: true; + }, { name: "dao"; isMut: true; isSigner: false; }, { - name: "proposer"; + name: "daoQuoteVaultAccount"; isMut: true; - isSigner: true; + isSigner: false; }, { - name: "squadsMultisigPermissionlessAccount"; - isMut: false; + name: "proposer"; + isMut: true; isSigner: true; }, { @@ -1223,11 +1228,6 @@ export type Futarchy = { isMut: true; isSigner: false; }, - { - name: "daoQuoteVaultAccount"; - isMut: true; - isSigner: false; - }, { name: "payer"; isMut: true; @@ -1268,6 +1268,42 @@ export type Futarchy = { }, ]; }, + { + name: "finalizeOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1424,26 +1460,15 @@ export type Futarchy = { type: "publicKey"; }, { - name: "activeOptimisticSquadsProposal"; - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "activeOptimisticSquadsProposalEnqueuedTimestamp"; - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ]; + name: "optimisticProposal"; type: { - option: "i64"; + option: { + defined: "OptimisticProposal"; + }; }; }, { name: "isOptimisticGovernanceEnabled"; - docs: ["Whether optimistic governance is enabled for this DAO."]; type: "bool"; }, ]; @@ -1843,6 +1868,28 @@ export type Futarchy = { ]; }; }, + { + name: "OptimisticProposal"; + type: { + kind: "struct"; + fields: [ + { + name: "squadsProposal"; + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ]; + type: "publicKey"; + }, + { + name: "enqueuedTimestamp"; + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ]; + type: "i64"; + }, + ]; + }; + }, { name: "InitialSpendingLimit"; type: { @@ -2948,6 +2995,28 @@ export type Futarchy = { }, ]; }, + { + name: "FinalizeOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + ]; + }, ]; errors: [ { @@ -3145,6 +3214,11 @@ export type Futarchy = { name: "ActiveOptimisticProposalAlreadyEnqueued"; msg: "An active optimistic proposal is already enqueued"; }, + { + code: 6039; + name: "NoActiveOptimisticProposal"; + msg: "No active optimistic proposal"; + }, ]; }; @@ -4335,7 +4409,7 @@ export const IDL: Futarchy = { }, { name: "squadsSpendingLimit", - isMut: true, + isMut: false, isSigner: false, }, { @@ -4348,19 +4422,24 @@ export const IDL: Futarchy = { isMut: true, isSigner: false, }, + { + name: "squadsMultisigPermissionlessAccount", + isMut: false, + isSigner: true, + }, { name: "dao", isMut: true, isSigner: false, }, { - name: "proposer", + name: "daoQuoteVaultAccount", isMut: true, - isSigner: true, + isSigner: false, }, { - name: "squadsMultisigPermissionlessAccount", - isMut: false, + name: "proposer", + isMut: true, isSigner: true, }, { @@ -4373,11 +4452,6 @@ export const IDL: Futarchy = { isMut: true, isSigner: false, }, - { - name: "daoQuoteVaultAccount", - isMut: true, - isSigner: false, - }, { name: "payer", isMut: true, @@ -4418,6 +4492,42 @@ export const IDL: Futarchy = { }, ], }, + { + name: "finalizeOptimisticProposal", + accounts: [ + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { @@ -4574,26 +4684,15 @@ export const IDL: Futarchy = { type: "publicKey", }, { - name: "activeOptimisticSquadsProposal", - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "activeOptimisticSquadsProposalEnqueuedTimestamp", - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ], + name: "optimisticProposal", type: { - option: "i64", + option: { + defined: "OptimisticProposal", + }, }, }, { name: "isOptimisticGovernanceEnabled", - docs: ["Whether optimistic governance is enabled for this DAO."], type: "bool", }, ], @@ -4993,6 +5092,28 @@ export const IDL: Futarchy = { ], }, }, + { + name: "OptimisticProposal", + type: { + kind: "struct", + fields: [ + { + name: "squadsProposal", + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ], + type: "publicKey", + }, + { + name: "enqueuedTimestamp", + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ], + type: "i64", + }, + ], + }, + }, { name: "InitialSpendingLimit", type: { @@ -6098,6 +6219,28 @@ export const IDL: Futarchy = { }, ], }, + { + name: "FinalizeOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + ], + }, ], errors: [ { @@ -6295,5 +6438,10 @@ export const IDL: Futarchy = { name: "ActiveOptimisticProposalAlreadyEnqueued", msg: "An active optimistic proposal is already enqueued", }, + { + code: 6039, + name: "NoActiveOptimisticProposal", + msg: "No active optimistic proposal", + }, ], }; From 8606360e1b2bce4a40fee4e76f12909ff4b06257 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 10 Jan 2026 01:52:47 +0100 Subject: [PATCH 007/100] tests for optimistic vault transaction proposal initiation --- sdk/src/v0.6/types/futarchy.ts | 780 +++++++++++++++--- sdk/src/v0.7/FutarchyClient.ts | 89 ++ tests/futarchy/main.test.ts | 7 + tests/futarchy/unit/initializeDao.test.ts | 17 + ...itiateVaultSpendOptimisticProposal.test.ts | 276 +++++++ tests/integration/fullLaunch.test.ts | 1 + tests/integration/fullLaunch_v7.test.ts | 1 + 7 files changed, 1076 insertions(+), 95 deletions(-) create mode 100644 tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts diff --git a/sdk/src/v0.6/types/futarchy.ts b/sdk/src/v0.6/types/futarchy.ts index 19b1d17ff..d9d95cdc1 100644 --- a/sdk/src/v0.6/types/futarchy.ts +++ b/sdk/src/v0.6/types/futarchy.ts @@ -1170,6 +1170,140 @@ export type Futarchy = { ]; args: []; }, + { + name: "initiateVaultSpendOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsSpendingLimit"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigPermissionlessAccount"; + isMut: false; + isSigner: true; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoQuoteVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: true; + isSigner: true; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "recipientQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitiateVaultSpendOptimisticProposalParams"; + }; + }, + ]; + }, + { + name: "finalizeOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1325,6 +1459,18 @@ export type Futarchy = { name: "teamAddress"; type: "publicKey"; }, + { + name: "optimisticProposal"; + type: { + option: { + defined: "OptimisticProposal"; + }; + }; + }, + { + name: "isOptimisticGovernanceEnabled"; + type: "bool"; + }, ]; }; }, @@ -1536,6 +1682,18 @@ export type Futarchy = { ]; }; }, + { + name: "InitiateVaultSpendOptimisticProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, { name: "ProvideLiquidityParams"; type: { @@ -1678,6 +1836,12 @@ export type Futarchy = { option: "publicKey"; }; }, + { + name: "isOptimisticGovernanceEnabled"; + type: { + option: "bool"; + }; + }, ]; }; }, @@ -1704,6 +1868,28 @@ export type Futarchy = { ]; }; }, + { + name: "OptimisticProposal"; + type: { + kind: "struct"; + fields: [ + { + name: "squadsProposal"; + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ]; + type: "publicKey"; + }, + { + name: "enqueuedTimestamp"; + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ]; + type: "i64"; + }, + ]; + }; + }, { name: "InitialSpendingLimit"; type: { @@ -2198,6 +2384,11 @@ export type Futarchy = { type: "publicKey"; index: false; }, + { + name: "isOptimisticGovernanceEnabled"; + type: "bool"; + index: false; + }, ]; }, { @@ -2742,6 +2933,90 @@ export type Futarchy = { }, ]; }, + { + name: "InitiateVaultSpendOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "daoQuoteVaultAccount"; + type: "publicKey"; + index: false; + }, + { + name: "recipientQuoteAccount"; + type: "publicKey"; + index: false; + }, + { + name: "enqueuedTimestamp"; + type: "i64"; + index: false; + }, + ]; + }, + { + name: "FinalizeOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + ]; + }, ]; errors: [ { @@ -2924,6 +3199,26 @@ export type Futarchy = { name: "InvalidTransactionMessage"; msg: "Failed to compile transaction message for Squads vault transaction"; }, + { + code: 6036; + name: "InvalidRecipient"; + msg: "Invalid recipient"; + }, + { + code: 6037; + name: "OptimisticGovernanceDisabled"; + msg: "Optimistic governance is disabled"; + }, + { + code: 6038; + name: "ActiveOptimisticProposalAlreadyEnqueued"; + msg: "An active optimistic proposal is already enqueued"; + }, + { + code: 6039; + name: "NoActiveOptimisticProposal"; + msg: "No active optimistic proposal"; + }, ]; }; @@ -3955,130 +4250,264 @@ export const IDL: Futarchy = { name: "collectMeteoraDammFees", accounts: [ { - name: "dao", + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigPermissionlessAccount", + isMut: false, + isSigner: true, + }, + { + name: "meteoraClaimPositionFeesAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "pool", + isMut: false, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "tokenAAccount", + isMut: true, + isSigner: false, + docs: ["Token account of base tokens recipient"], + }, + { + name: "tokenBAccount", + isMut: true, + isSigner: false, + docs: ["Token account of quote tokens recipient"], + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenAMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenBMint", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: false, + isSigner: false, + }, + { + name: "owner", + isMut: false, + isSigner: false, + }, + { + name: "tokenAProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenBProgram", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "initiateVaultSpendOptimisticProposal", + accounts: [ + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsSpendingLimit", + isMut: false, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigPermissionlessAccount", + isMut: false, + isSigner: true, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoQuoteVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: true, + isSigner: true, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "recipientQuoteAccount", isMut: true, isSigner: false, }, { - name: "admin", + name: "payer", isMut: true, isSigner: true, }, { - name: "squadsMultisig", - isMut: true, + name: "systemProgram", + isMut: false, isSigner: false, }, { - name: "squadsMultisigVault", + name: "squadsProgram", isMut: false, isSigner: false, }, { - name: "squadsMultisigVaultTransaction", - isMut: true, + name: "tokenProgram", + isMut: false, isSigner: false, }, { - name: "squadsMultisigProposal", - isMut: true, + name: "eventAuthority", + isMut: false, isSigner: false, }, { - name: "squadsMultisigPermissionlessAccount", + name: "program", isMut: false, - isSigner: true, + isSigner: false, }, + ], + args: [ { - name: "meteoraClaimPositionFeesAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: false, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAAccount", - isMut: true, - isSigner: false, - docs: ["Token account of base tokens recipient"], - }, - { - name: "tokenBAccount", - isMut: true, - isSigner: false, - docs: ["Token account of quote tokens recipient"], - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: false, - isSigner: false, - }, - { - name: "owner", - isMut: false, - isSigner: false, - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - }, - ], + name: "params", + type: { + defined: "InitiateVaultSpendOptimisticProposalParams", + }, }, + ], + }, + { + name: "finalizeOptimisticProposal", + accounts: [ { - name: "systemProgram", - isMut: false, + name: "squadsMultisig", + isMut: true, isSigner: false, }, { - name: "tokenProgram", - isMut: false, + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, isSigner: false, }, { @@ -4254,6 +4683,18 @@ export const IDL: Futarchy = { name: "teamAddress", type: "publicKey", }, + { + name: "optimisticProposal", + type: { + option: { + defined: "OptimisticProposal", + }, + }, + }, + { + name: "isOptimisticGovernanceEnabled", + type: "bool", + }, ], }, }, @@ -4465,6 +4906,18 @@ export const IDL: Futarchy = { ], }, }, + { + name: "InitiateVaultSpendOptimisticProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, { name: "ProvideLiquidityParams", type: { @@ -4607,6 +5060,12 @@ export const IDL: Futarchy = { option: "publicKey", }, }, + { + name: "isOptimisticGovernanceEnabled", + type: { + option: "bool", + }, + }, ], }, }, @@ -4633,6 +5092,28 @@ export const IDL: Futarchy = { ], }, }, + { + name: "OptimisticProposal", + type: { + kind: "struct", + fields: [ + { + name: "squadsProposal", + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ], + type: "publicKey", + }, + { + name: "enqueuedTimestamp", + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ], + type: "i64", + }, + ], + }, + }, { name: "InitialSpendingLimit", type: { @@ -5127,6 +5608,11 @@ export const IDL: Futarchy = { type: "publicKey", index: false, }, + { + name: "isOptimisticGovernanceEnabled", + type: "bool", + index: false, + }, ], }, { @@ -5671,6 +6157,90 @@ export const IDL: Futarchy = { }, ], }, + { + name: "InitiateVaultSpendOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "daoQuoteVaultAccount", + type: "publicKey", + index: false, + }, + { + name: "recipientQuoteAccount", + type: "publicKey", + index: false, + }, + { + name: "enqueuedTimestamp", + type: "i64", + index: false, + }, + ], + }, + { + name: "FinalizeOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + ], + }, ], errors: [ { @@ -5853,5 +6423,25 @@ export const IDL: Futarchy = { name: "InvalidTransactionMessage", msg: "Failed to compile transaction message for Squads vault transaction", }, + { + code: 6036, + name: "InvalidRecipient", + msg: "Invalid recipient", + }, + { + code: 6037, + name: "OptimisticGovernanceDisabled", + msg: "Optimistic governance is disabled", + }, + { + code: 6038, + name: "ActiveOptimisticProposalAlreadyEnqueued", + msg: "An active optimistic proposal is already enqueued", + }, + { + code: 6039, + name: "NoActiveOptimisticProposal", + msg: "No active optimistic proposal", + }, ], }; diff --git a/sdk/src/v0.7/FutarchyClient.ts b/sdk/src/v0.7/FutarchyClient.ts index a9e73931d..1c600ad8a 100644 --- a/sdk/src/v0.7/FutarchyClient.ts +++ b/sdk/src/v0.7/FutarchyClient.ts @@ -1115,4 +1115,93 @@ export class FutarchyClient { squadsProgram: SQUADS_PROGRAM_ID, }); } + + initiateVaultSpendOptimisticProposalIx({ + dao, + quoteMint = MAINNET_USDC, + amount, + recipient, + transactionIndex, + proposer = this.provider.publicKey, + payer = this.provider.publicKey, + }: { + dao: PublicKey; + quoteMint?: PublicKey; + amount: BN; + recipient: PublicKey; + transactionIndex: bigint; + proposer?: PublicKey; + payer?: PublicKey; + }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + const squadsSpendingLimit = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + const squadsProposal = multisig.getProposalPda({ + multisigPda, + transactionIndex, + })[0]; + const squadsVaultTransaction = multisig.getTransactionPda({ + multisigPda, + index: transactionIndex, + })[0]; + + return this.autocrat.methods + .initiateVaultSpendOptimisticProposal({ amount }) + .accounts({ + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsSpendingLimit, + squadsProposal, + squadsVaultTransaction, + squadsMultisigPermissionlessAccount: PERMISSIONLESS_ACCOUNT.publicKey, + dao, + daoQuoteVaultAccount: getAssociatedTokenAddressSync( + quoteMint, + squadsMultisigVault, + true, + ), + proposer, + recipient, + recipientQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + recipient, + true, + ), + payer, + systemProgram: SystemProgram.programId, + squadsProgram: SQUADS_PROGRAM_ID, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, recipient, true), + recipient, + quoteMint, + ), + ]); + } + + finalizeOptimisticProposalIx({ + dao, + squadsProposal, + }: { + dao: PublicKey; + squadsProposal: PublicKey; + }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + + return this.autocrat.methods.finalizeOptimisticProposal().accounts({ + squadsMultisig: multisigPda, + squadsProposal, + dao, + squadsProgram: SQUADS_PROGRAM_ID, + }); + } } diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index 37478c3ac..e651d1488 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -9,6 +9,8 @@ import conditionalSwap from "./unit/conditionalSwap.test.js"; import executeSpendingLimitChange from "./unit/executeSpendingLimitChange.test.js"; +import initiateVaultSpendOptimisticProposal from "./unit/initiateVaultSpendOptimisticProposal.test.js"; + import collectMeteoraDammFees from "./unit/collectMeteoraDammFees.test.js"; import { PublicKey } from "@solana/web3.js"; import { @@ -50,6 +52,11 @@ export default function suite() { describe("#collect_meteora_damm_fees", collectMeteoraDammFees); + describe( + "#initiate_vault_spend_optimistic_proposal", + initiateVaultSpendOptimisticProposal, + ); + // describe("full proposal", fullProposal); // describe("proposal with a squads batch tx", proposalBatchTx); describe("futarchy amm", futarchyAmm); diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 06948538b..ebf69601d 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -36,6 +36,8 @@ export default function suite() { passThresholdBps: 300, nonce: new BN(1337), initialSpendingLimit: null, + teamAddress: this.payer.publicKey, + teamSponsoredPassThresholdBps: 123, }, }) .preInstructions([ @@ -71,6 +73,12 @@ export default function suite() { assert.equal(storedDao.passThresholdBps, 300); assert.isNull(storedDao.initialSpendingLimit); + assert.isTrue(storedDao.teamAddress.equals(this.payer.publicKey)); + assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); + + assert.isNull(storedDao.optimisticProposal); + assert.isFalse(storedDao.isOptimisticGovernanceEnabled); + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const squadsMultisigVault = multisig.getVaultPda({ multisigPda, @@ -131,6 +139,8 @@ export default function suite() { amountPerMonth: new BN(10_000 * 10 ** 6), members: [spender.publicKey], }, + teamSponsoredPassThresholdBps: 123, + teamAddress: this.payer.publicKey, }, }) .rpc(); @@ -175,6 +185,10 @@ export default function suite() { assert.equal(storedSpendingLimit.members.length, 1); assert.ok(storedSpendingLimit.members[0].equals(spender.publicKey)); assert.equal(storedSpendingLimit.destinations.length, 0); + assert.isTrue(storedDao.teamAddress.equals(this.payer.publicKey)); + assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); + assert.isNull(storedDao.optimisticProposal); + assert.isFalse(storedDao.isOptimisticGovernanceEnabled); }); it("doesn't allow DAOs with proposal duration less than TWAP start delay", async function () { @@ -197,6 +211,9 @@ export default function suite() { secondsPerProposal: 5000, nonce: new BN(1338), initialSpendingLimit: null, + baseToStake: new BN(1000), + teamSponsoredPassThresholdBps: 123, + teamAddress: this.payer.publicKey, }, }) .rpc() diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts new file mode 100644 index 000000000..97df1ede0 --- /dev/null +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -0,0 +1,276 @@ +import { + PERMISSIONLESS_ACCOUNT, + PriceMath, +} from "@metadaoproject/futarchy/v0.7"; +import { ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; +import BN from "bn.js"; +import { expectError } from "../../utils.js"; +import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { assert } from "chai"; +import * as squads from "@sqds/multisig"; + +const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); + +export default function suite() { + let META: PublicKey, dao: PublicKey, spendingLimit: BN; + let setOptimisticGovernanceEnabled: ( + dao: PublicKey, + enabled: boolean, + ) => Promise; + + beforeEach(async function () { + setOptimisticGovernanceEnabled = async ( + dao: PublicKey, + enabled: boolean, + ) => { + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + }; + META = await this.createMint(this.payer.publicKey, 9); + spendingLimit = new BN(10_000); + // Create payer's token accounts for both mints + await this.createTokenAccount(META, this.payer.publicKey); + + // Mint tokens to payer's accounts + await this.mintTo(META, this.payer.publicKey, this.payer, 100 * 10 ** 9); + + const nonce = new BN(Math.floor(Math.random() * 1000000)); + + await this.futarchy + .initializeDaoIx({ + baseMint: META, + quoteMint: MAINNET_USDC, + params: { + secondsPerProposal: 60 * 60 * 24 * 3, + twapStartDelaySeconds: 60 * 60 * 24, + twapInitialObservation: THOUSAND_BUCK_PRICE, + twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), + minQuoteFutarchicLiquidity: new BN(10_000), + minBaseFutarchicLiquidity: new BN(10_000), + passThresholdBps: 300, + nonce, + initialSpendingLimit: { + amountPerMonth: spendingLimit, + members: [this.payer.publicKey], + }, + baseToStake: new BN(0), + teamSponsoredPassThresholdBps: 0, + teamAddress: this.payer.publicKey, + }, + provideLiquidity: true, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + [dao] = getDaoAddr({ + nonce, + daoCreator: this.payer.publicKey, + }); + + const daoAccount = await this.futarchy.getDao(dao); + + console.log("daoAccount", JSON.stringify(daoAccount, null, 2)); + + const daoQuoteVaultAddress = getAssociatedTokenAddressSync( + MAINNET_USDC, + daoAccount.squadsMultisigVault, + true, + ); + + await this.createTokenAccount(MAINNET_USDC, daoAccount.squadsMultisigVault); + + // const balance = await this.getTokenBalance(MAINNET_USDC, daoQuoteVaultAddress); + // console.log("balance", balance.toString()); + + await this.transfer( + MAINNET_USDC, + this.payer, + daoAccount.squadsMultisigVault, + 100_000 * 1_000_000, + ); + + await setOptimisticGovernanceEnabled(dao, true); + }); + + it("can initiate a vault spend optimistic proposal if the DAO has optimistic governance enabled", async function () { + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + const daoAccount = await this.futarchy.getDao(dao); + + assert.exists(daoAccount.optimisticProposal); + + const clock = await this.banksClient.getClock(); + assert.equal( + daoAccount.optimisticProposal.enqueuedTimestamp.toString(), + clock.unixTimestamp.toString(), + ); + + const [expectedSquadsProposal] = squads.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + }); + assert.equal( + expectedSquadsProposal.toBase58(), + daoAccount.optimisticProposal.squadsProposal.toBase58(), + ); + }); + + it("can't initiate a vault spend optimistic proposal if the DAO doesn't have optimistic governance enabled", async function () { + await setOptimisticGovernanceEnabled(dao, false); + + const callbacks = expectError( + "OptimisticGovernanceDisabled", + "DAO doesn't have optimistic governance enabled", + ); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 0n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can't initiate a vault spend optimistic proposal if the DAO is not in spot state", async function () { + const daoAccount = await this.futarchy.getDao(dao); + const dummyMarket = { + baseProtocolFeeBalance: new BN(0), + quoteProtocolFeeBalance: new BN(0), + baseReserves: new BN(0), + quoteReserves: new BN(0), + oracle: { + aggregator: new BN(0), + lastUpdatedTimestamp: new BN(0), + createdAtTimestamp: new BN(0), + lastPrice: new BN(0), + lastObservation: new BN(0), + maxObservationChangePerUpdate: new BN(0), + initialObservation: new BN(0), + startDelaySeconds: 0, + }, + }; + + daoAccount.amm.state = { + futarchy: { + spot: dummyMarket, + pass: dummyMarket, + fail: dummyMarket, + }, + }; + + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + + const callbacks = expectError( + "PoolNotInSpotState", + "Pool is not in spot state", + ); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can't initialize a vault spend optimistic proposal if the DAO has an active optimistic proposal", async function () { + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + const callbacks = expectError( + "ActiveOptimisticProposalAlreadyEnqueued", + "An active optimistic proposal is already enqueued", + ); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .preInstructions([ + // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), + ]) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can initialize a vault spend optimistic proposal if the amount is less than or equal to 3 times the spending limit", async function () { + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: spendingLimit.muln(3), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + }); + + it("can't initialize a vault spend optimistic proposal if the amount is greater than 3 times the spending limit", async function () { + const callbacks = expectError( + "InvalidAmount", + "Amount is greater than 3 times the spending limit", + ); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: spendingLimit.muln(3).addn(1), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .preInstructions([ + // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), + ]) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); +} diff --git a/tests/integration/fullLaunch.test.ts b/tests/integration/fullLaunch.test.ts index 5e44ba320..a6b8ad681 100644 --- a/tests/integration/fullLaunch.test.ts +++ b/tests/integration/fullLaunch.test.ts @@ -380,6 +380,7 @@ export default async function suite() { minBaseFutarchicLiquidity: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: false, }, }) .instruction(); diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index af8af6e0c..4a0adeb1b 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -424,6 +424,7 @@ export default async function suite() { minBaseFutarchicLiquidity: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: false, }, }) .instruction(); From 6702eaf5fa333fe5e1574dc63c74122db2303f08 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 10 Jan 2026 02:41:55 +0100 Subject: [PATCH 008/100] optimistic proposal finalization tests --- .../finalize_optimistic_proposal.rs | 20 +- tests/futarchy/main.test.ts | 5 +- .../unit/finalizeOptimisticProposal.test.ts | 281 ++++++++++++++++++ ...itiateVaultSpendOptimisticProposal.test.ts | 14 +- 4 files changed, 295 insertions(+), 25 deletions(-) create mode 100644 tests/futarchy/unit/finalizeOptimisticProposal.test.ts diff --git a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs index fac40a2b4..a8dcbb092 100644 --- a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs @@ -18,23 +18,21 @@ impl FinalizeOptimisticProposal<'_> { pub fn validate(&self) -> Result<()> { require_keys_eq!(self.squads_proposal.multisig, self.dao.squads_multisig); - // There should be an active optimistic proposal - let optimistic_proposal = match self.dao.optimistic_proposal { - Some(ref optimistic_proposal) => optimistic_proposal, - None => { - return Err(FutarchyError::NoActiveOptimisticProposal.into()); - } - }; - // A minimum of proposal duration must have passed since the the optimistic proposal was enqueued + // We know that the optimistic proposal is not None, because the address constraint would have already panicked require_gte!( Clock::get()?.unix_timestamp, - optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, - FutarchyError::ProposalDurationTooShort + self.dao + .optimistic_proposal + .as_ref() + .unwrap() + .enqueued_timestamp + + self.dao.seconds_per_proposal as i64, + FutarchyError::ProposalTooYoung ); // Pool must be in spot state - no active proposals - // Realistically, this should never be hit, but it's here for completeness + // This should never be hit, but it's here for completeness match self.dao.amm.state { PoolState::Spot { spot: _ } => {} _ => { diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index e651d1488..48005924b 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -9,9 +9,11 @@ import conditionalSwap from "./unit/conditionalSwap.test.js"; import executeSpendingLimitChange from "./unit/executeSpendingLimitChange.test.js"; +import collectMeteoraDammFees from "./unit/collectMeteoraDammFees.test.js"; + import initiateVaultSpendOptimisticProposal from "./unit/initiateVaultSpendOptimisticProposal.test.js"; +import finalizeOptimisticProposal from "./unit/finalizeOptimisticProposal.test.js"; -import collectMeteoraDammFees from "./unit/collectMeteoraDammFees.test.js"; import { PublicKey } from "@solana/web3.js"; import { LAUNCHPAD_PROGRAM_ID, @@ -56,6 +58,7 @@ export default function suite() { "#initiate_vault_spend_optimistic_proposal", initiateVaultSpendOptimisticProposal, ); + describe.only("#finalize_optimistic_proposal", finalizeOptimisticProposal); // describe("full proposal", fullProposal); // describe("proposal with a squads batch tx", proposalBatchTx); diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts new file mode 100644 index 000000000..a25481887 --- /dev/null +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -0,0 +1,281 @@ +import { + PERMISSIONLESS_ACCOUNT, + PriceMath, +} from "@metadaoproject/futarchy/v0.7"; +import { + ComputeBudgetProgram, + PublicKey, + Transaction, + TransactionMessage, +} from "@solana/web3.js"; +import BN from "bn.js"; +import { expectError } from "../../utils.js"; +import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { + createTransferInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import { assert } from "chai"; +import * as squads from "@sqds/multisig"; + +const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); + +export default function suite() { + let META: PublicKey, + dao: PublicKey, + spendingLimit: BN, + transferAmount: bigint; + let setOptimisticGovernanceEnabled: ( + dao: PublicKey, + enabled: boolean, + ) => Promise; + + beforeEach(async function () { + setOptimisticGovernanceEnabled = async ( + dao: PublicKey, + enabled: boolean, + ) => { + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + }; + META = await this.createMint(this.payer.publicKey, 9); + spendingLimit = new BN(10_000); + transferAmount = 1000n; + // Create payer's token accounts for both mints + await this.createTokenAccount(META, this.payer.publicKey); + + // Mint tokens to payer's accounts + await this.mintTo(META, this.payer.publicKey, this.payer, 100 * 10 ** 9); + + const nonce = new BN(Math.floor(Math.random() * 1000000)); + + await this.futarchy + .initializeDaoIx({ + baseMint: META, + quoteMint: MAINNET_USDC, + params: { + secondsPerProposal: 60 * 60 * 24 * 3, + twapStartDelaySeconds: 60 * 60 * 24, + twapInitialObservation: THOUSAND_BUCK_PRICE, + twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), + minQuoteFutarchicLiquidity: new BN(10_000), + minBaseFutarchicLiquidity: new BN(10_000), + passThresholdBps: 300, + nonce, + initialSpendingLimit: { + amountPerMonth: spendingLimit, + members: [this.payer.publicKey], + }, + baseToStake: new BN(0), + teamSponsoredPassThresholdBps: 0, + teamAddress: this.payer.publicKey, + }, + provideLiquidity: true, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + [dao] = getDaoAddr({ + nonce, + daoCreator: this.payer.publicKey, + }); + + const daoAccount = await this.futarchy.getDao(dao); + + await this.createTokenAccount(MAINNET_USDC, daoAccount.squadsMultisigVault); + + await this.transfer( + MAINNET_USDC, + this.payer, + daoAccount.squadsMultisigVault, + 100_000 * 1_000_000, + ); + + await setOptimisticGovernanceEnabled(dao, true); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(transferAmount), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + }); + + it("can finalize a vault spend optimistic proposal and execute the squads proposal afterwards", async function () { + this.advanceBySeconds(60 * 60 * 24 * 3); + + let daoAccount = await this.futarchy.getDao(dao); + + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: daoAccount.optimisticProposal.squadsProposal, + }) + .rpc(); + + daoAccount = await this.futarchy.getDao(dao); + + assert.notExists(daoAccount.optimisticProposal); + + const payerUsdcBalanceBefore = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + + // Confirm that we can execute the squads proposal + const txExecuteIx = await squads.instructions.vaultTransactionExecute({ + connection: this.squadsConnection, + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + member: PERMISSIONLESS_ACCOUNT.publicKey, + }); + + const txExecute = new Transaction().add(txExecuteIx.instruction); + txExecute.recentBlockhash = ( + await this.banksClient.getLatestBlockhash() + )[0]; + txExecute.feePayer = this.payer.publicKey; + txExecute.sign(this.payer, PERMISSIONLESS_ACCOUNT); + + await this.banksClient.processTransaction(txExecute); + + const payerUsdcBalanceAfter = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + assert.equal( + payerUsdcBalanceAfter, + payerUsdcBalanceBefore + transferAmount, + ); + }); + + it("can't finalize a vault spend optimistic proposal if the proposal account is not the same as the optimistic proposal", async function () { + const daoAccount = await this.futarchy.getDao(dao); + + let transferIx = createTransferInstruction( + getAssociatedTokenAddressSync( + MAINNET_USDC, + daoAccount.squadsMultisigVault, + true, + ), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + daoAccount.squadsMultisigVault, + 123, + ); + + let transactionMessage = new TransactionMessage({ + payerKey: this.payer.publicKey, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: [transferIx], + }); + + const dupeProposalTx = new Transaction().add( + squads.instructions.vaultTransactionCreate({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 2n, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage: transactionMessage, + }), + squads.instructions.proposalCreate({ + multisigPda: daoAccount.squadsMultisig, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + transactionIndex: 2n, + isDraft: false, + }), + ); + + dupeProposalTx.recentBlockhash = ( + await this.banksClient.getLatestBlockhash() + )[0]; + dupeProposalTx.feePayer = this.payer.publicKey; + dupeProposalTx.sign(this.payer, PERMISSIONLESS_ACCOUNT); + + await this.banksClient.processTransaction(dupeProposalTx); + + const callbacks = expectError( + "ConstraintAddress", + "An address constraint was violated", + ); + + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: squads.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 2n, + })[0], + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can't finalize a vault spend optimistic proposal if the proposal is too young", async function () { + const daoAccount = await this.futarchy.getDao(dao); + + const callbacks = expectError( + "ProposalTooYoung", + "Proposal is too young to be executed or rejected", + ); + + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: daoAccount.optimisticProposal.squadsProposal, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can't finalize a vault spend optimistic proposal if there is no active optimistic proposal", async function () { + this.advanceBySeconds(60 * 60 * 24 * 3); + + const daoAccount = await this.futarchy.getDao(dao); + + // Finalize the running optimistic proposal + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: daoAccount.optimisticProposal.squadsProposal, + }) + .rpc(); + + try { + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: daoAccount.optimisticProposal.squadsProposal, + }) + .preInstructions([ + // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + assert.fail("Should have thrown error"); + } catch (error) { + const logsAggregated = error.logs.map((log: string) => log).join("\n"); + assert.include( + logsAggregated, + "panicked at 'called `Option::unwrap()` on a `None` value'", + ); + } + }); +} diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 97df1ede0..f19a643d1 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -6,7 +6,6 @@ import { ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { assert } from "chai"; import * as squads from "@sqds/multisig"; @@ -81,19 +80,8 @@ export default function suite() { const daoAccount = await this.futarchy.getDao(dao); - console.log("daoAccount", JSON.stringify(daoAccount, null, 2)); - - const daoQuoteVaultAddress = getAssociatedTokenAddressSync( - MAINNET_USDC, - daoAccount.squadsMultisigVault, - true, - ); - await this.createTokenAccount(MAINNET_USDC, daoAccount.squadsMultisigVault); - // const balance = await this.getTokenBalance(MAINNET_USDC, daoQuoteVaultAddress); - // console.log("balance", balance.toString()); - await this.transfer( MAINNET_USDC, this.payer, @@ -104,7 +92,7 @@ export default function suite() { await setOptimisticGovernanceEnabled(dao, true); }); - it("can initiate a vault spend optimistic proposal if the DAO has optimistic governance enabled", async function () { + it("can initiate a vault spend optimistic proposal", async function () { await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, From 69a4b618a1abe01dda2c1621f4147f9f549793fb Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 10 Jan 2026 04:03:01 +0100 Subject: [PATCH 009/100] prevent initialization of futarchy proposal when optimistic governance proposal has already passed but not been finalized yet --- programs/futarchy/src/error.rs | 2 + .../src/instructions/initialize_proposal.rs | 13 + .../src/instructions/launch_proposal.rs | 7 + sdk/src/v0.7/types/futarchy.ts | 10 + tests/futarchy/main.test.ts | 5 +- .../futarchy/unit/initializeProposal.test.ts | 107 ++++++++- tests/futarchy/unit/launchProposal.test.ts | 224 ++++++++++++++++++ tests/integration/fullLaunch_v7.test.ts | 3 +- 8 files changed, 361 insertions(+), 10 deletions(-) create mode 100644 tests/futarchy/unit/launchProposal.test.ts diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index ffb92cee0..2e62d84e4 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -84,4 +84,6 @@ pub enum FutarchyError { ActiveOptimisticProposalAlreadyEnqueued, #[msg("No active optimistic proposal")] NoActiveOptimisticProposal, + #[msg("Optimistic proposal has already passed")] + OptimisticProposalAlreadyPassed, } diff --git a/programs/futarchy/src/instructions/initialize_proposal.rs b/programs/futarchy/src/instructions/initialize_proposal.rs index 9393d25cf..694a526ce 100644 --- a/programs/futarchy/src/instructions/initialize_proposal.rs +++ b/programs/futarchy/src/instructions/initialize_proposal.rs @@ -36,6 +36,19 @@ pub struct InitializeProposal<'info> { impl InitializeProposal<'_> { pub fn validate(&self) -> Result<()> { + // If we're trying to initialize a proposal for an optimistic proposal that has already passed due to age, we should error + // This is because the optimistic proposal's Squads proposal will eventually have to be executed + match self.dao.optimistic_proposal { + Some(ref optimistic_proposal) => { + require_gt!( + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, + Clock::get()?.unix_timestamp, + FutarchyError::OptimisticProposalAlreadyPassed + ); + } + None => {} + } + require_eq!( self.question.num_outcomes(), 2, diff --git a/programs/futarchy/src/instructions/launch_proposal.rs b/programs/futarchy/src/instructions/launch_proposal.rs index 68f290f44..abd5d58e3 100644 --- a/programs/futarchy/src/instructions/launch_proposal.rs +++ b/programs/futarchy/src/instructions/launch_proposal.rs @@ -59,6 +59,13 @@ impl LaunchProposal<'_> { optimistic_proposal.squads_proposal, self.proposal.squads_proposal ); + + // The optimistic proposal must be younger than seconds_per_proposal, otherwise it is considered passed and must be finalized + require_gt!( + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, + Clock::get()?.unix_timestamp, + FutarchyError::OptimisticProposalAlreadyPassed + ); } Ok(()) diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index d9d95cdc1..26165b29d 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -3219,6 +3219,11 @@ export type Futarchy = { name: "NoActiveOptimisticProposal"; msg: "No active optimistic proposal"; }, + { + code: 6040; + name: "OptimisticProposalAlreadyPassed"; + msg: "Optimistic proposal has already passed"; + }, ]; }; @@ -6443,5 +6448,10 @@ export const IDL: Futarchy = { name: "NoActiveOptimisticProposal", msg: "No active optimistic proposal", }, + { + code: 6040, + name: "OptimisticProposalAlreadyPassed", + msg: "Optimistic proposal has already passed", + }, ], }; diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index 48005924b..bae7c48a3 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -2,6 +2,7 @@ import futarchyAmm from "./integration/futarchyAmm.test.js"; import initializeDao from "./unit/initializeDao.test.js"; import initializeProposal from "./unit/initializeProposal.test.js"; +import launchProposal from "./unit/launchProposal.test.js"; import finalizeProposal from "./unit/finalizeProposal.test.js"; import collectFees from "./unit/collectFees.test.js"; @@ -46,6 +47,7 @@ export default function suite() { }); describe("#initialize_dao", initializeDao); describe("#initialize_proposal", initializeProposal); + describe("#launch_proposal", launchProposal); describe("#finalize_proposal", finalizeProposal); describe("#collect_fees", collectFees); @@ -58,8 +60,7 @@ export default function suite() { "#initiate_vault_spend_optimistic_proposal", initiateVaultSpendOptimisticProposal, ); - describe.only("#finalize_optimistic_proposal", finalizeOptimisticProposal); - + describe("#finalize_optimistic_proposal", finalizeOptimisticProposal); // describe("full proposal", fullProposal); // describe("proposal with a squads batch tx", proposalBatchTx); describe("futarchy amm", futarchyAmm); diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 56514e700..6f4525658 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -1,10 +1,16 @@ import { + getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy/v0.6"; -import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; +} from "@metadaoproject/futarchy/v0.7"; +import { + ComputeBudgetProgram, + PublicKey, + Transaction, + TransactionMessage, +} from "@solana/web3.js"; import BN from "bn.js"; -import { setupBasicDao } from "../../utils.js"; +import { expectError, setupBasicDao } from "../../utils.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; const { Permissions, Permission } = multisig.types; @@ -14,7 +20,29 @@ const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; + let setOptimisticGovernanceEnabled: ( + dao: PublicKey, + enabled: boolean, + ) => Promise; + beforeEach(async function () { + setOptimisticGovernanceEnabled = async ( + dao: PublicKey, + enabled: boolean, + ) => { + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + }; + META = await this.createMint(this.payer.publicKey, 9); USDC = await this.createMint(this.payer.publicKey, 6); @@ -31,10 +59,39 @@ export default function suite() { 100_000 * 1_000_000, ); - dao = await setupBasicDao({ - context: this, - baseMint: META, - quoteMint: USDC, + const nonce = new BN(Math.floor(Math.random() * 1000000)); + + await this.futarchy + .initializeDaoIx({ + baseMint: META, + quoteMint: USDC, + params: { + secondsPerProposal: 60 * 60 * 24 * 3, + twapStartDelaySeconds: 60 * 60 * 24, + twapInitialObservation: THOUSAND_BUCK_PRICE, + twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), + minQuoteFutarchicLiquidity: new BN(10_000), + minBaseFutarchicLiquidity: new BN(10_000), + passThresholdBps: 300, + nonce, + initialSpendingLimit: { + amountPerMonth: new BN(10_000), + members: [this.payer.publicKey], + }, + baseToStake: new BN(0), + teamSponsoredPassThresholdBps: 0, + teamAddress: this.payer.publicKey, + }, + provideLiquidity: true, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + [dao] = getDaoAddr({ + nonce, + daoCreator: this.payer.publicKey, }); }); @@ -51,6 +108,10 @@ export default function suite() { twapMaxObservationChangePerUpdate: null, minQuoteFutarchicLiquidity: null, minBaseFutarchicLiquidity: null, + twapStartDelaySeconds: null, + teamSponsoredPassThresholdBps: null, + teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); @@ -124,4 +185,36 @@ export default function suite() { const storedDao = await this.futarchy.getDao(dao); assert.equal(storedDao.proposalCount, 1); }); + + it("doesn't allow challenging an optimistic proposal which has already passed due to age", async function () { + let daoAccount = await this.futarchy.getDao(dao); + + await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); + + await setOptimisticGovernanceEnabled(dao, true); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 1n, + quoteMint: USDC, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + daoAccount = await this.futarchy.getDao(dao); + + this.advanceBySeconds(daoAccount.secondsPerProposal); + + const callbacks = expectError( + "OptimisticProposalAlreadyPassed", + "Optimistic proposal has already passed", + ); + + await this.futarchy + .initializeProposal(dao, daoAccount.optimisticProposal.squadsProposal) + .then(callbacks[0], callbacks[1]); + }); } diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts new file mode 100644 index 000000000..3cf4e3f6c --- /dev/null +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -0,0 +1,224 @@ +import { + getProposalAddrV2, + PERMISSIONLESS_ACCOUNT, + PriceMath, +} from "@metadaoproject/futarchy/v0.7"; +import { + ComputeBudgetProgram, + PublicKey, + Transaction, + TransactionMessage, +} from "@solana/web3.js"; +import BN from "bn.js"; +import { expectError } from "../../utils.js"; +import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { + createTransferInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import { assert } from "chai"; +import * as squads from "@sqds/multisig"; +import { mintToOverride } from "spl-token-bankrun"; + +const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); + +export default function suite() { + let META: PublicKey, + dao: PublicKey, + spendingLimit: BN, + transferAmount: bigint; + let setOptimisticGovernanceEnabled: ( + dao: PublicKey, + enabled: boolean, + ) => Promise; + + beforeEach(async function () { + setOptimisticGovernanceEnabled = async ( + dao: PublicKey, + enabled: boolean, + ) => { + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + }; + META = await this.createMint(this.payer.publicKey, 9); + spendingLimit = new BN(10_000); + transferAmount = 1000n; + // Create payer's token accounts for both mints + await this.createTokenAccount(META, this.payer.publicKey); + + // Mint tokens to payer's accounts + await this.mintTo(META, this.payer.publicKey, this.payer, 100 * 10 ** 9); + + const nonce = new BN(Math.floor(Math.random() * 1000000)); + + await this.futarchy + .initializeDaoIx({ + baseMint: META, + quoteMint: MAINNET_USDC, + params: { + secondsPerProposal: 60 * 60 * 24 * 3, + twapStartDelaySeconds: 60 * 60 * 24, + twapInitialObservation: THOUSAND_BUCK_PRICE, + twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), + minQuoteFutarchicLiquidity: new BN(0), + minBaseFutarchicLiquidity: new BN(0), + passThresholdBps: 300, + nonce, + initialSpendingLimit: { + amountPerMonth: spendingLimit, + members: [this.payer.publicKey], + }, + baseToStake: new BN(0), + teamSponsoredPassThresholdBps: 0, + teamAddress: this.payer.publicKey, + }, + provideLiquidity: true, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + [dao] = getDaoAddr({ + nonce, + daoCreator: this.payer.publicKey, + }); + + const daoAccount = await this.futarchy.getDao(dao); + + await this.createTokenAccount(MAINNET_USDC, daoAccount.squadsMultisigVault); + + await this.transfer( + MAINNET_USDC, + this.payer, + daoAccount.squadsMultisigVault, + 100_000 * 1_000_000, + ); + + // Mint an extra 1M META tokens to the payer's account for staking to proposals + await mintToOverride( + this.context, + getAssociatedTokenAddressSync(META, this.payer.publicKey), + 1_000_000n * 10n ** 6n, + ); + }); + + it("can challenge an optimistic proposal by launching a new futarchy proposal using the same squads proposal", async function () { + await setOptimisticGovernanceEnabled(dao, true); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(transferAmount), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + let daoAccount = await this.futarchy.getDao(dao); + + assert.exists(daoAccount.optimisticProposal); + + const [squadsProposal] = squads.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + }); + + await this.futarchy.initializeProposal(dao, squadsProposal); + + const [proposal] = getProposalAddrV2({ squadsProposal }); + + await this.futarchy + .stakeToProposalIx({ + amount: new BN(1_000_000 * 10 ** 6), + proposal, + dao, + baseMint: META, + }) + .rpc(); + + await this.futarchy + .launchProposalIx({ + proposal, + dao, + baseMint: META, + quoteMint: MAINNET_USDC, + }) + .rpc(); + + // Assert that the optimistic proposal has been migrated to the futarchy proposal + daoAccount = await this.futarchy.getDao(dao); + assert.notExists(daoAccount.optimisticProposal); + + const proposalAccount = await this.futarchy.getProposal(proposal); + assert.exists(proposalAccount.state.pending); + assert.equal( + proposalAccount.squadsProposal.toBase58(), + squadsProposal.toBase58(), + ); + }); + + it("can't challenge an optimistic proposal if it has already passed due to age", async function () { + await setOptimisticGovernanceEnabled(dao, true); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(transferAmount), + recipient: this.payer.publicKey, + transactionIndex: 1n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + let daoAccount = await this.futarchy.getDao(dao); + + assert.exists(daoAccount.optimisticProposal); + + const [squadsProposal] = squads.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + }); + + // Initialize the futarchy proposal before the optimistic proposal is auto-approved + await this.futarchy.initializeProposal(dao, squadsProposal); + + this.advanceBySeconds(daoAccount.secondsPerProposal); + + const [proposal] = getProposalAddrV2({ squadsProposal }); + + await this.futarchy + .stakeToProposalIx({ + amount: new BN(1_000_000 * 10 ** 6), + proposal, + dao, + baseMint: META, + }) + .rpc(); + + const callbacks = expectError( + "OptimisticProposalAlreadyPassed", + "Optimistic proposal has already passed", + ); + + await this.futarchy + .launchProposalIx({ + proposal, + dao, + baseMint: META, + quoteMint: MAINNET_USDC, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); +} diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index 4a0adeb1b..c393e93b3 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -424,7 +424,7 @@ export default async function suite() { minBaseFutarchicLiquidity: null, teamSponsoredPassThresholdBps: null, teamAddress: null, - isOptimisticGovernanceEnabled: false, + isOptimisticGovernanceEnabled: true, }, }) .instruction(); @@ -579,6 +579,7 @@ export default async function suite() { const storedDao2 = await this.futarchy.getDao(dao); assert.equal(storedDao2.passThresholdBps, 500); + assert.isTrue(storedDao2.isOptimisticGovernanceEnabled); const storedMeta = await this.getMint(META); From 27962d092218ea1030d599fdd10a9b9c9d9d1f5b Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 10 Jan 2026 04:05:46 +0100 Subject: [PATCH 010/100] add missing check --- .../src/instructions/initialize_proposal.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/programs/futarchy/src/instructions/initialize_proposal.rs b/programs/futarchy/src/instructions/initialize_proposal.rs index 694a526ce..05737295d 100644 --- a/programs/futarchy/src/instructions/initialize_proposal.rs +++ b/programs/futarchy/src/instructions/initialize_proposal.rs @@ -36,15 +36,18 @@ pub struct InitializeProposal<'info> { impl InitializeProposal<'_> { pub fn validate(&self) -> Result<()> { - // If we're trying to initialize a proposal for an optimistic proposal that has already passed due to age, we should error + // If we're trying to challenge an optimistic proposal that has already passed due to age, we should error // This is because the optimistic proposal's Squads proposal will eventually have to be executed match self.dao.optimistic_proposal { Some(ref optimistic_proposal) => { - require_gt!( - optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, - Clock::get()?.unix_timestamp, - FutarchyError::OptimisticProposalAlreadyPassed - ); + if optimistic_proposal.squads_proposal == self.squads_proposal.key() { + require_gt!( + optimistic_proposal.enqueued_timestamp + + self.dao.seconds_per_proposal as i64, + Clock::get()?.unix_timestamp, + FutarchyError::OptimisticProposalAlreadyPassed + ); + } } None => {} } From 2aa4420301249ca1d1299a329d6171d557b40d30 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 10 Jan 2026 15:35:31 +0100 Subject: [PATCH 011/100] team can't sponsor a challenge to an optimistic governance proposal --- programs/futarchy/src/error.rs | 2 ++ programs/futarchy/src/instructions/sponsor_proposal.rs | 9 +++++++++ sdk/src/v0.7/types/futarchy.ts | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index 2e62d84e4..8c38acbcc 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -86,4 +86,6 @@ pub enum FutarchyError { NoActiveOptimisticProposal, #[msg("Optimistic proposal has already passed")] OptimisticProposalAlreadyPassed, + #[msg("Team cannot sponsor a challenge to an optimistic proposal")] + CannotSponsorOptimisticProposalChallenge, } diff --git a/programs/futarchy/src/instructions/sponsor_proposal.rs b/programs/futarchy/src/instructions/sponsor_proposal.rs index 725aa6292..9e2a73a26 100644 --- a/programs/futarchy/src/instructions/sponsor_proposal.rs +++ b/programs/futarchy/src/instructions/sponsor_proposal.rs @@ -23,6 +23,15 @@ impl SponsorProposal<'_> { FutarchyError::ProposalAlreadySponsored ); + // Team cannot sponsor a challenge to an optimistic proposal + if let Some(optimistic_proposal) = &self.dao.optimistic_proposal { + require_keys_neq!( + optimistic_proposal.squads_proposal, + self.proposal.squads_proposal, + FutarchyError::CannotSponsorOptimisticProposalChallenge + ); + } + Ok(()) } diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 26165b29d..8a78913c9 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -3224,6 +3224,11 @@ export type Futarchy = { name: "OptimisticProposalAlreadyPassed"; msg: "Optimistic proposal has already passed"; }, + { + code: 6041; + name: "CannotSponsorOptimisticProposalChallenge"; + msg: "Team cannot sponsor a challenge to an optimistic proposal"; + }, ]; }; @@ -6453,5 +6458,10 @@ export const IDL: Futarchy = { name: "OptimisticProposalAlreadyPassed", msg: "Optimistic proposal has already passed", }, + { + code: 6041, + name: "CannotSponsorOptimisticProposalChallenge", + msg: "Team cannot sponsor a challenge to an optimistic proposal", + }, ], }; From 0d55d111123318ba6794420c859430ff628b1108 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 16 Jan 2026 15:24:42 -0800 Subject: [PATCH 012/100] work-in-progress PR comments --- programs/futarchy/src/error.rs | 2 ++ .../finalize_optimistic_proposal.rs | 10 +++--- .../src/instructions/initialize_proposal.rs | 21 +++++------ ...nitiate_vault_spend_optimistic_proposal.rs | 35 +++++++++---------- sdk/src/v0.7/types/futarchy.ts | 10 ++++++ 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index 8c38acbcc..97823dfec 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -88,4 +88,6 @@ pub enum FutarchyError { OptimisticProposalAlreadyPassed, #[msg("Team cannot sponsor a challenge to an optimistic proposal")] CannotSponsorOptimisticProposalChallenge, + #[msg("Invalid spending limit mint. Must be the same as the DAO's quote mint")] + InvalidSpendingLimitMint, } diff --git a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs index a8dcbb092..164e3d66b 100644 --- a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs @@ -33,12 +33,10 @@ impl FinalizeOptimisticProposal<'_> { // Pool must be in spot state - no active proposals // This should never be hit, but it's here for completeness - match self.dao.amm.state { - PoolState::Spot { spot: _ } => {} - _ => { - return Err(FutarchyError::PoolNotInSpotState.into()); - } - } + require!( + matches!(self.dao.amm.state, PoolState::Spot { .. }), + FutarchyError::PoolNotInSpotState + ); Ok(()) } diff --git a/programs/futarchy/src/instructions/initialize_proposal.rs b/programs/futarchy/src/instructions/initialize_proposal.rs index 05737295d..19265fd5d 100644 --- a/programs/futarchy/src/instructions/initialize_proposal.rs +++ b/programs/futarchy/src/instructions/initialize_proposal.rs @@ -37,19 +37,16 @@ pub struct InitializeProposal<'info> { impl InitializeProposal<'_> { pub fn validate(&self) -> Result<()> { // If we're trying to challenge an optimistic proposal that has already passed due to age, we should error - // This is because the optimistic proposal's Squads proposal will eventually have to be executed - match self.dao.optimistic_proposal { - Some(ref optimistic_proposal) => { - if optimistic_proposal.squads_proposal == self.squads_proposal.key() { - require_gt!( - optimistic_proposal.enqueued_timestamp - + self.dao.seconds_per_proposal as i64, - Clock::get()?.unix_timestamp, - FutarchyError::OptimisticProposalAlreadyPassed - ); - } + // In the case of an already-optimistically-passed proposal, the optimistic proposal can be cleared + // from the DAO state by finalizing the optimistic proposal (finalize_optimistic_proposal) + if let Some(ref optimistic_proposal) = self.dao.optimistic_proposal { + if optimistic_proposal.squads_proposal == self.squads_proposal.key() { + require_gt!( + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, + Clock::get()?.unix_timestamp, + FutarchyError::OptimisticProposalAlreadyPassed + ); } - None => {} } require_eq!( diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index e463d3ee1..28b6e074f 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -60,12 +60,10 @@ impl InitiateVaultSpendOptimisticProposal<'_> { ); // Pool must be in spot state - no active proposal - match self.dao.amm.state { - PoolState::Spot { spot: _ } => {} - _ => { - return Err(FutarchyError::PoolNotInSpotState.into()); - } - } + require!( + matches!(self.dao.amm.state, PoolState::Spot { spot: _ }), + FutarchyError::PoolNotInSpotState + ); // There should be no active optimistic proposal require!( @@ -73,21 +71,22 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::ActiveOptimisticProposalAlreadyEnqueued ); - // A minimum of proposal duration must have passed since the last optimistic proposal was enqueued - match self.dao.optimistic_proposal { - Some(ref optimistic_proposal) => { - require_gte!( - Clock::get()?.unix_timestamp, - optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, - FutarchyError::ProposalDurationTooShort - ); - } - None => {} - }; + // No existing optimistic proposal can be present. If one has passed, it can be finalized (finalize_optimistic_proposal) + require!( + self.dao.optimistic_proposal.is_none(), + FutarchyError::ProposalDurationTooShort + ); + + // Spending limit mint must be the same as the DAO's quote mint + require_eq!( + self.squads_spending_limit.mint, + self.dao.quote_mint, + FutarchyError::InvalidSpendingLimitMint + ); // Amount must be less than or equal to 3 times the spending limit require_gte!( - self.squads_spending_limit.amount.checked_mul(3).unwrap(), + self.squads_spending_limit.amount * 3, params.amount, FutarchyError::InvalidAmount ); diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 8a78913c9..d932e3b4e 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -3229,6 +3229,11 @@ export type Futarchy = { name: "CannotSponsorOptimisticProposalChallenge"; msg: "Team cannot sponsor a challenge to an optimistic proposal"; }, + { + code: 6042; + name: "InvalidSpendingLimitMint"; + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; + }, ]; }; @@ -6463,5 +6468,10 @@ export const IDL: Futarchy = { name: "CannotSponsorOptimisticProposalChallenge", msg: "Team cannot sponsor a challenge to an optimistic proposal", }, + { + code: 6042, + name: "InvalidSpendingLimitMint", + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", + }, ], }; From c98ce2e13da18bf16fd3fdf667d6dd7a9c72de91 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 16 Jan 2026 16:03:48 -0800 Subject: [PATCH 013/100] address review comments --- .../src/instructions/launch_proposal.rs | 23 ++- .../src/instructions/sponsor_proposal.rs | 9 - ...itiateVaultSpendOptimisticProposal.test.ts | 183 +++++++++++++++++- tests/futarchy/unit/launchProposal.test.ts | 2 + 4 files changed, 201 insertions(+), 16 deletions(-) diff --git a/programs/futarchy/src/instructions/launch_proposal.rs b/programs/futarchy/src/instructions/launch_proposal.rs index 9db37fcaf..f6f87ef11 100644 --- a/programs/futarchy/src/instructions/launch_proposal.rs +++ b/programs/futarchy/src/instructions/launch_proposal.rs @@ -72,6 +72,17 @@ impl LaunchProposal<'_> { ); } + // Can only launch a proposal if the underlying squads proposal is active + // This check exists mainly to prevent a situation where we try to launch a proposal for a passed optimistic proposal. + // However, it also applies in general, to prevent a situation where we enter futarchy with an invalid squads proposal state, thus bricking it. + require!( + matches!( + self.squads_proposal.status, + squads_multisig_program::ProposalStatus::Active { .. } + ), + FutarchyError::InvalidSquadsProposalStatus + ); + // Ensure the squads proposal is not invalidated by a previous config transaction require_gt!( self.squads_proposal.transaction_index, @@ -168,14 +179,16 @@ impl LaunchProposal<'_> { proposal.state = ProposalState::Pending; proposal.timestamp_enqueued = clock.unix_timestamp; - // Update the DAO state + // If this is moving an optimistic proposal into the futarchy proposal, the futarchy proposal will be treated as team-sponsored (lower pass threshold) if dao.optimistic_proposal.is_some() { - // The optimistic proposal is being challenged, so we are moving it into the futarchy proposal - // This means that the optimistic proposal now has to pass a decision market in order to be approved/executed - // verify() ensures that the optimistic proposal and squads proposal are the same - dao.optimistic_proposal = None; + proposal.is_team_sponsored = true; } + // Update the DAO state + // There either is no optimistic proposal, or the optimistic proposal is being moved into the futarchy proposal + // This means that the optimistic proposal now has to pass a decision market in order to be approved/executed + dao.optimistic_proposal = None; + dao.seq_num += 1; emit_cpi!(LaunchProposalEvent { diff --git a/programs/futarchy/src/instructions/sponsor_proposal.rs b/programs/futarchy/src/instructions/sponsor_proposal.rs index 9e2a73a26..725aa6292 100644 --- a/programs/futarchy/src/instructions/sponsor_proposal.rs +++ b/programs/futarchy/src/instructions/sponsor_proposal.rs @@ -23,15 +23,6 @@ impl SponsorProposal<'_> { FutarchyError::ProposalAlreadySponsored ); - // Team cannot sponsor a challenge to an optimistic proposal - if let Some(optimistic_proposal) = &self.dao.optimistic_proposal { - require_keys_neq!( - optimistic_proposal.squads_proposal, - self.proposal.squads_proposal, - FutarchyError::CannotSponsorOptimisticProposalChallenge - ); - } - Ok(()) } diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index f19a643d1..5d9333b2e 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -54,8 +54,8 @@ export default function suite() { twapStartDelaySeconds: 60 * 60 * 24, twapInitialObservation: THOUSAND_BUCK_PRICE, twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), - minQuoteFutarchicLiquidity: new BN(10_000), - minBaseFutarchicLiquidity: new BN(10_000), + minQuoteFutarchicLiquidity: new BN(1), + minBaseFutarchicLiquidity: new BN(1), passThresholdBps: 300, nonce, initialSpendingLimit: { @@ -89,6 +89,16 @@ export default function suite() { 100_000 * 1_000_000, ); + await this.futarchy + .provideLiquidityIx({ + dao, + baseMint: META, + quoteMint: MAINNET_USDC, + maxBaseAmount: new BN(100_000 * 10 ** 6), + quoteAmount: new BN(100_000 * 10 ** 6), + }) + .rpc(); + await setOptimisticGovernanceEnabled(dao, true); }); @@ -123,6 +133,175 @@ export default function suite() { ); }); + it("can still initiate a vault spend optimistic proposal after a DAO changes their spending limit", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const daoSpendingLimitPda = squads.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + + const removeSpendingLimitIx = + squads.instructions.multisigRemoveSpendingLimit({ + multisigPda, + configAuthority: dao, + spendingLimit: daoSpendingLimitPda, + rentCollector: this.payer.publicKey, + memo: "", + }); + + const addSpendingLimitIx = squads.instructions.multisigAddSpendingLimit({ + multisigPda, + spendingLimit: daoSpendingLimitPda, + configAuthority: dao, + rentPayer: this.payer.publicKey, + createKey: dao, + vaultIndex: 0, + mint: MAINNET_USDC, + amount: BigInt(spendingLimit.muln(3).toString()), // 30,000 USDC + period: squads.types.Period.Month, + members: [this.payer.publicKey], // Only the DAO can use this spending limit + destinations: [], // No specific destinations + memo: "", + }); + + const { proposal, squadsProposal } = await this.initializeAndLaunchProposal( + { + dao, + instructions: [removeSpendingLimitIx, addSpendingLimitIx], + }, + ); + + const { question, quoteVault } = this.futarchy.getProposalPdas( + proposal, + META, + MAINNET_USDC, + dao, + ); + + await this.conditionalVault + .splitTokensIx( + question, + quoteVault, + MAINNET_USDC, + new BN(11_000 * 1_000_000), + 2, + ) + .rpc(); + + // Trade heavily on pass market to make it pass + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: MAINNET_USDC, + proposal, + market: "pass", + swapType: "buy", + inputAmount: new BN(10_000 * 1_000_000), + minOutputAmount: new BN(0), + }) + .rpc(); + + // Crank TWAP to build up price history + for (let i = 0; i < 100; i++) { + this.advanceBySeconds(10_000); + + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: MAINNET_USDC, + proposal, + market: "pass", + swapType: "buy", + inputAmount: new BN(10), + minOutputAmount: new BN(0), + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitPrice({ microLamports: i }), + ]) + .rpc(); + } + + // Finalize the proposal + await this.futarchy.finalizeProposal(proposal); + + const storedProposal = await this.futarchy.getProposal(proposal); + assert.exists(storedProposal.state.passed); + + const [vaultTransactionPda] = squads.getTransactionPda({ + multisigPda: multisigPda, + index: 1n, + }); + + const transactionAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + vaultTransactionPda, + ); + + const [vaultPda] = squads.getVaultPda({ + multisigPda, + index: transactionAccount.vaultIndex, + programId: squads.PROGRAM_ID, + }); + + const { accountMetas } = await squads.utils.accountsForTransactionExecute({ + connection: this.squadsConnection, + message: transactionAccount.message, + ephemeralSignerBumps: [...transactionAccount.ephemeralSignerBumps], + vaultPda, + transactionPda: vaultTransactionPda, + programId: squads.PROGRAM_ID, + }); + + await this.futarchy.autocrat.methods + .executeSpendingLimitChange() + .accounts({ + squadsMultisig: multisigPda, + proposal, + dao, + squadsProposal, + squadsMultisigProgram: squads.PROGRAM_ID, + vaultTransaction: vaultTransactionPda, + }) + .remainingAccounts( + accountMetas.map((meta) => + meta.pubkey.equals(dao) ? { ...meta, isSigner: false } : meta, + ), + ) + .rpc(); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 2n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + const daoAccount = await this.futarchy.getDao(dao); + + assert.exists(daoAccount.optimisticProposal); + + const clock = await this.banksClient.getClock(); + assert.equal( + daoAccount.optimisticProposal.enqueuedTimestamp.toString(), + clock.unixTimestamp.toString(), + ); + + const [expectedSquadsProposal] = squads.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 2n, + }); + assert.equal( + expectedSquadsProposal.toBase58(), + daoAccount.optimisticProposal.squadsProposal.toBase58(), + ); + }); + it("can't initiate a vault spend optimistic proposal if the DAO doesn't have optimistic governance enabled", async function () { await setOptimisticGovernanceEnabled(dao, false); diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index 3cf4e3f6c..f2209a3c7 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -153,6 +153,7 @@ export default function suite() { dao, baseMint: META, quoteMint: MAINNET_USDC, + squadsProposal, }) .rpc(); @@ -217,6 +218,7 @@ export default function suite() { dao, baseMint: META, quoteMint: MAINNET_USDC, + squadsProposal, }) .rpc() .then(callbacks[0], callbacks[1]); From 484e7adc263ebffda9e581a128aed0da2726dfa2 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 16 Jan 2026 17:02:19 -0800 Subject: [PATCH 014/100] reintroduce resize_dao crankable instruction with scripts --- Anchor.toml | 2 + programs/futarchy/src/instructions/mod.rs | 2 + .../futarchy/src/instructions/resize_dao.rs | 83 ++++ programs/futarchy/src/lib.rs | 4 + programs/futarchy/src/state/dao.rs | 56 +++ scripts/v0.6/dumpDaos.ts | 90 ++++ scripts/v0.6/migrateDaos.ts | 133 +++++ sdk/src/v0.6/types/futarchy.ts | 466 ++++++++++++++++++ sdk/src/v0.7/types/futarchy.ts | 314 ++++++++++++ 9 files changed, 1150 insertions(+) create mode 100644 programs/futarchy/src/instructions/resize_dao.rs create mode 100644 scripts/v0.6/dumpDaos.ts create mode 100644 scripts/v0.6/migrateDaos.ts diff --git a/Anchor.toml b/Anchor.toml index 10a9ab039..1ade3f213 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -50,6 +50,8 @@ v06-create-dao = "yarn run tsx scripts/v0.6/createDao.ts" v06-provide-liquidity = "yarn run tsx scripts/v0.6/provideLiquidity.ts" v06-collect-meteora-damm-fees = "yarn run tsx scripts/v0.6/collectMeteoraDammFees.ts" v06-return-funds = "yarn run tsx scripts/v0.6/returnFunds.ts" +v06-dump-daos = "yarn run tsx scripts/v0.6/dumpDaos.ts" +v06-migrate-daos = "yarn run tsx scripts/v0.6/migrateDaos.ts" v07-collect-meteora-damm-fees = "yarn run tsx scripts/v0.7/collectMeteoraDammFees.ts" v07-launch-template = "yarn run tsx scripts/v0.7/launchTemplate.ts" v07-start-launch = "yarn run tsx scripts/v0.7/startLaunch.ts" diff --git a/programs/futarchy/src/instructions/mod.rs b/programs/futarchy/src/instructions/mod.rs index 85b8023e3..90e20456b 100644 --- a/programs/futarchy/src/instructions/mod.rs +++ b/programs/futarchy/src/instructions/mod.rs @@ -12,6 +12,7 @@ pub mod initialize_proposal; pub mod initiate_vault_spend_optimistic_proposal; pub mod launch_proposal; pub mod provide_liquidity; +pub mod resize_dao; pub mod sponsor_proposal; pub mod spot_swap; pub mod stake_to_proposal; @@ -31,6 +32,7 @@ pub use initialize_proposal::*; pub use initiate_vault_spend_optimistic_proposal::*; pub use launch_proposal::*; pub use provide_liquidity::*; +pub use resize_dao::*; pub use sponsor_proposal::*; pub use spot_swap::*; pub use stake_to_proposal::*; diff --git a/programs/futarchy/src/instructions/resize_dao.rs b/programs/futarchy/src/instructions/resize_dao.rs new file mode 100644 index 000000000..6352ac116 --- /dev/null +++ b/programs/futarchy/src/instructions/resize_dao.rs @@ -0,0 +1,83 @@ +use anchor_lang::{system_program, Discriminator}; + +use super::*; + +#[derive(Accounts)] +pub struct ResizeDao<'info> { + /// CHECK: we check the discriminator + #[account(mut)] + pub dao: UncheckedAccount<'info>, + #[account(mut)] + pub payer: Signer<'info>, + pub system_program: Program<'info, System>, +} + +impl ResizeDao<'_> { + pub fn handle(ctx: Context) -> Result<()> { + let dao = &ctx.accounts.dao; + + require_eq!(dao.owner, &crate::ID); + let is_discriminator_correct = dao.try_borrow_data().unwrap()[..8] == Dao::discriminator(); + require_eq!(is_discriminator_correct, true); + + const AFTER_REALLOC_SIZE: usize = Dao::INIT_SPACE + 8; + // 42 bytes: 1 (Option discriminant) + 32 (Pubkey) + 8 (i64) + 1 (bool) + const BEFORE_REALLOC_SIZE: usize = AFTER_REALLOC_SIZE - 42; + + if dao.data_len() != BEFORE_REALLOC_SIZE { + // already realloced + require_eq!(dao.data_len(), AFTER_REALLOC_SIZE); + return Ok(()); + } + + let old_dao_data = OldDao::deserialize(&mut &dao.try_borrow_data().unwrap()[8..])?; + + let new_dao_data = Dao { + amm: old_dao_data.amm, + nonce: old_dao_data.nonce, + dao_creator: old_dao_data.dao_creator, + pda_bump: old_dao_data.pda_bump, + squads_multisig: old_dao_data.squads_multisig, + squads_multisig_vault: old_dao_data.squads_multisig_vault, + base_mint: old_dao_data.base_mint, + quote_mint: old_dao_data.quote_mint, + proposal_count: old_dao_data.proposal_count, + pass_threshold_bps: old_dao_data.pass_threshold_bps, + seconds_per_proposal: old_dao_data.seconds_per_proposal, + twap_initial_observation: old_dao_data.twap_initial_observation, + twap_max_observation_change_per_update: old_dao_data + .twap_max_observation_change_per_update, + twap_start_delay_seconds: old_dao_data.twap_start_delay_seconds, + min_quote_futarchic_liquidity: old_dao_data.min_quote_futarchic_liquidity, + min_base_futarchic_liquidity: old_dao_data.min_base_futarchic_liquidity, + base_to_stake: old_dao_data.base_to_stake, + seq_num: old_dao_data.seq_num, + initial_spending_limit: old_dao_data.initial_spending_limit, + team_sponsored_pass_threshold_bps: old_dao_data.team_sponsored_pass_threshold_bps, + team_address: old_dao_data.team_address, + optimistic_proposal: None, + is_optimistic_governance_enabled: false, + }; + + dao.realloc(AFTER_REALLOC_SIZE, true)?; + + let lamports_needed = Rent::get()?.minimum_balance(AFTER_REALLOC_SIZE); + + if lamports_needed > dao.lamports() { + system_program::transfer( + CpiContext::new( + ctx.accounts.system_program.to_account_info(), + system_program::Transfer { + from: ctx.accounts.payer.to_account_info(), + to: dao.to_account_info(), + }, + ), + lamports_needed - dao.lamports(), + )?; + } + + new_dao_data.serialize(&mut &mut dao.try_borrow_mut_data().unwrap()[8..])?; + + Ok(()) + } +} diff --git a/programs/futarchy/src/lib.rs b/programs/futarchy/src/lib.rs index 1c0f4ebab..0eaaa4c7a 100644 --- a/programs/futarchy/src/lib.rs +++ b/programs/futarchy/src/lib.rs @@ -100,6 +100,10 @@ pub mod futarchy { UpdateDao::handle(ctx, dao_params) } + pub fn resize_dao(ctx: Context) -> Result<()> { + ResizeDao::handle(ctx) + } + // AMM instructions pub fn spot_swap(ctx: Context, params: SpotSwapParams) -> Result<()> { diff --git a/programs/futarchy/src/state/dao.rs b/programs/futarchy/src/state/dao.rs index dfed8ac6b..0d898f636 100644 --- a/programs/futarchy/src/state/dao.rs +++ b/programs/futarchy/src/state/dao.rs @@ -110,3 +110,59 @@ impl Dao { Ok(()) } } + +#[account] +#[derive(InitSpace)] +pub struct OldDao { + /// Embedded FutarchyAmm - 1:1 relationship + pub amm: FutarchyAmm, + /// `nonce` + `dao_creator` are PDA seeds + pub nonce: u64, + pub dao_creator: Pubkey, + pub pda_bump: u8, + pub squads_multisig: Pubkey, + pub squads_multisig_vault: Pubkey, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, + pub proposal_count: u32, + // the percentage, in basis points, the pass price needs to be above the + // fail price in order for the proposal to pass + pub pass_threshold_bps: u16, + pub seconds_per_proposal: u32, + /// For manipulation-resistance the TWAP is a time-weighted average observation, + /// where observation tries to approximate price but can only move by + /// `twap_max_observation_change_per_update` per update. Because it can only move + /// a little bit per update, you need to check that it has a good initial observation. + /// Otherwise, an attacker could create a very high initial observation in the pass + /// market and a very low one in the fail market to force the proposal to pass. + /// + /// We recommend setting an initial observation around the spot price of the token, + /// and max observation change per update around 2% the spot price of the token. + /// For example, if the spot price of META is $400, we'd recommend setting an initial + /// observation of 400 (converted into the AMM prices) and a max observation change per + /// update of 8 (also converted into the AMM prices). Observations can be updated once + /// a minute, so 2% allows the proposal market to reach double the spot price or 0 + /// in 50 minutes. + pub twap_initial_observation: u128, + pub twap_max_observation_change_per_update: u128, + /// Forces TWAP calculation to start after `twap_start_delay_seconds` seconds + pub twap_start_delay_seconds: u32, + /// As an anti-spam measure and to help liquidity, you need to lock up some liquidity + /// in both futarchic markets in order to create a proposal. + /// + /// For example, for META, we can use a `min_quote_futarchic_liquidity` of + /// 5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of + /// 10 * 1_000_000_000 (10 META). + pub min_quote_futarchic_liquidity: u64, + pub min_base_futarchic_liquidity: u64, + /// Minimum amount of base tokens that must be staked to launch a proposal + pub base_to_stake: u64, + pub seq_num: u64, + pub initial_spending_limit: Option, + /// The percentage, in basis points, the pass price needs to be above the + /// fail price in order for the proposal to pass for team-sponsored proposals. + /// + /// Can be negative to allow for team-sponsored proposals to pass by default. + pub team_sponsored_pass_threshold_bps: i16, + pub team_address: Pubkey, +} diff --git a/scripts/v0.6/dumpDaos.ts b/scripts/v0.6/dumpDaos.ts new file mode 100644 index 000000000..33bb5d55c --- /dev/null +++ b/scripts/v0.6/dumpDaos.ts @@ -0,0 +1,90 @@ +import { PublicKey } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import dotenv from "dotenv"; +import * as fs from "fs"; +import * as path from "path"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function dumpAccount( + publicKey: PublicKey, + outputDir: string, + accountType: string, +) { + const accountInfo = await provider.connection.getAccountInfo(publicKey); + + if (!accountInfo) { + console.error(`Account ${publicKey.toBase58()} not found`); + return; + } + + const accountData = { + pubkey: publicKey.toBase58(), + account: { + lamports: accountInfo.lamports, + data: [accountInfo.data.toString("base64"), "base64"], + owner: accountInfo.owner.toBase58(), + executable: accountInfo.executable, + rentEpoch: "U64_MAX_PLACEHOLDER", + }, + }; + + const filename = path.join(outputDir, `${publicKey.toBase58()}.json`); + fs.writeFileSync( + filename, + JSON.stringify(accountData, null, 2).replace( + '"U64_MAX_PLACEHOLDER"', + "18446744073709551615", + ), + ); + + console.log(`Dumped ${accountType}: ${publicKey.toBase58()}`); +} + +async function main() { + const futarchy = FutarchyClient.createClient({ provider }); + + const daosDir = "daos"; + if (!fs.existsSync(daosDir)) { + fs.mkdirSync(daosDir); + } + + const daoDiscriminator = getDiscriminator("Dao"); + console.log(`DAO discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`DAO discriminator (base58): ${bs58.encode(daoDiscriminator)}`); + console.log(`Program ID: ${futarchy.futarchy.programId.toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchy.futarchy.programId, + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (const { pubkey } of daoAccounts) { + await dumpAccount(pubkey, daosDir, "DAO"); + } +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); diff --git a/scripts/v0.6/migrateDaos.ts b/scripts/v0.6/migrateDaos.ts new file mode 100644 index 000000000..427b3f7a1 --- /dev/null +++ b/scripts/v0.6/migrateDaos.ts @@ -0,0 +1,133 @@ +import { + ComputeBudgetProgram, + Keypair, + TransactionInstruction, + VersionedTransaction, + TransactionMessage, +} from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import dotenv from "dotenv"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); +const payer = provider.wallet["payer"]; + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function sendAndConfirmTransaction( + ixs: TransactionInstruction[], + label: string, + signers: Keypair[] = [], +) { + const { blockhash } = await provider.connection.getLatestBlockhash(); + + const messageV0 = new TransactionMessage({ + instructions: ixs, + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const simulationTx = new VersionedTransaction(messageV0); + simulationTx.sign([payer, ...signers]); + + const simulationResult = + await provider.connection.simulateTransaction(simulationTx); + + const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ + units: Math.ceil(simulationResult.value.unitsConsumed! * 1.15), + }); + + const finalMessageV0 = new TransactionMessage({ + instructions: [computeBudgetIx, ...ixs], + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const tx = new VersionedTransaction(finalMessageV0); + tx.sign([payer, ...signers]); + + const txHash = await provider.connection.sendRawTransaction(tx.serialize()); + console.log(`${label} transaction sent:`, txHash); + + await provider.connection.confirmTransaction(txHash, "confirmed"); + const txStatus = await provider.connection.getTransaction(txHash, { + maxSupportedTransactionVersion: 0, + commitment: "confirmed", + }); + if (txStatus?.meta?.err) { + throw new Error( + `Transaction failed: ${txHash}\nError: ${JSON.stringify( + txStatus?.meta?.err, + )}\n\n${txStatus?.meta?.logMessages?.join("\n")}`, + ); + } + console.log(`${label} transaction confirmed`); + return txHash; +} + +async function main() { + const futarchy = FutarchyClient.createClient({ provider }); + + const daoDiscriminator = getDiscriminator("Dao"); + const daoBatchSize = 15; + + console.log(`DAO discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`DAO discriminator (base58): ${bs58.encode(daoDiscriminator)}`); + console.log(`Program ID: ${futarchy.futarchy.programId.toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchy.futarchy.programId, + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (let i = 0; i < daoAccounts.length; i += daoBatchSize) { + const batch = daoAccounts.slice( + i, + Math.min(i + daoBatchSize, daoAccounts.length), + ); + console.log( + `Processing batch ${Math.floor(i / daoBatchSize) + 1} with ${batch.length} DAOs`, + ); + + const ixs = await Promise.all( + batch.map(async ({ pubkey }) => { + return await futarchy.futarchy.methods + .resizeDao() + .accounts({ + dao: pubkey, + payer: payer.publicKey, + }) + .instruction(); + }), + ); + + await sendAndConfirmTransaction( + ixs, + `Resize DAOs batch ${Math.floor(i / daoBatchSize) + 1}`, + ); + } + + console.log("Confirming DAOs can be loaded through SDK..."); + const daos = await futarchy.futarchy.account.dao.all(); + console.log(`Confirmed ${daos.length} DAOs`); +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); diff --git a/sdk/src/v0.6/types/futarchy.ts b/sdk/src/v0.6/types/futarchy.ts index d9d95cdc1..99270d126 100644 --- a/sdk/src/v0.6/types/futarchy.ts +++ b/sdk/src/v0.6/types/futarchy.ts @@ -118,6 +118,11 @@ export type Futarchy = { isMut: false; isSigner: false; }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, { name: "dao"; isMut: true; @@ -370,6 +375,16 @@ export type Futarchy = { isMut: true; isSigner: false; }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, { name: "systemProgram"; isMut: false; @@ -562,6 +577,27 @@ export type Futarchy = { }, ]; }, + { + name: "resizeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, { name: "spotSwap"; accounts: [ @@ -1304,6 +1340,52 @@ export type Futarchy = { ]; args: []; }, + { + name: "adminApproveExecuteMultisigProposal"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1474,6 +1556,142 @@ export type Futarchy = { ]; }; }, + { + name: "oldDao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, { name: "proposal"; type: { @@ -3219,6 +3437,21 @@ export type Futarchy = { name: "NoActiveOptimisticProposal"; msg: "No active optimistic proposal"; }, + { + code: 6040; + name: "OptimisticProposalAlreadyPassed"; + msg: "Optimistic proposal has already passed"; + }, + { + code: 6041; + name: "CannotSponsorOptimisticProposalChallenge"; + msg: "Team cannot sponsor a challenge to an optimistic proposal"; + }, + { + code: 6042; + name: "InvalidSpendingLimitMint"; + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; + }, ]; }; @@ -3342,6 +3575,11 @@ export const IDL: Futarchy = { isMut: false, isSigner: false, }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, { name: "dao", isMut: true, @@ -3594,6 +3832,16 @@ export const IDL: Futarchy = { isMut: true, isSigner: false, }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, { name: "systemProgram", isMut: false, @@ -3786,6 +4034,27 @@ export const IDL: Futarchy = { }, ], }, + { + name: "resizeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, { name: "spotSwap", accounts: [ @@ -4528,6 +4797,52 @@ export const IDL: Futarchy = { ], args: [], }, + { + name: "adminApproveExecuteMultisigProposal", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { @@ -4698,6 +5013,142 @@ export const IDL: Futarchy = { ], }, }, + { + name: "oldDao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, { name: "proposal", type: { @@ -6443,5 +6894,20 @@ export const IDL: Futarchy = { name: "NoActiveOptimisticProposal", msg: "No active optimistic proposal", }, + { + code: 6040, + name: "OptimisticProposalAlreadyPassed", + msg: "Optimistic proposal has already passed", + }, + { + code: 6041, + name: "CannotSponsorOptimisticProposalChallenge", + msg: "Team cannot sponsor a challenge to an optimistic proposal", + }, + { + code: 6042, + name: "InvalidSpendingLimitMint", + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", + }, ], }; diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index b9540ec56..99270d126 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -577,6 +577,27 @@ export type Futarchy = { }, ]; }, + { + name: "resizeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, { name: "spotSwap"; accounts: [ @@ -1535,6 +1556,142 @@ export type Futarchy = { ]; }; }, + { + name: "oldDao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, { name: "proposal"; type: { @@ -3877,6 +4034,27 @@ export const IDL: Futarchy = { }, ], }, + { + name: "resizeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, { name: "spotSwap", accounts: [ @@ -4835,6 +5013,142 @@ export const IDL: Futarchy = { ], }, }, + { + name: "oldDao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, { name: "proposal", type: { From 62e4d8ac9543889105948c0703d64e669facbbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20Grani=C4=87=20Skender?= <3357638+pileks@users.noreply.github.com> Date: Fri, 16 Jan 2026 17:06:50 -0800 Subject: [PATCH 015/100] reintroduce resize_dao crankable instruction with scripts (#400) --- Anchor.toml | 2 + programs/futarchy/src/instructions/mod.rs | 2 + .../futarchy/src/instructions/resize_dao.rs | 83 ++++ programs/futarchy/src/lib.rs | 4 + programs/futarchy/src/state/dao.rs | 56 +++ scripts/v0.6/dumpDaos.ts | 90 ++++ scripts/v0.6/migrateDaos.ts | 133 +++++ sdk/src/v0.6/types/futarchy.ts | 466 ++++++++++++++++++ sdk/src/v0.7/types/futarchy.ts | 314 ++++++++++++ 9 files changed, 1150 insertions(+) create mode 100644 programs/futarchy/src/instructions/resize_dao.rs create mode 100644 scripts/v0.6/dumpDaos.ts create mode 100644 scripts/v0.6/migrateDaos.ts diff --git a/Anchor.toml b/Anchor.toml index 10a9ab039..1ade3f213 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -50,6 +50,8 @@ v06-create-dao = "yarn run tsx scripts/v0.6/createDao.ts" v06-provide-liquidity = "yarn run tsx scripts/v0.6/provideLiquidity.ts" v06-collect-meteora-damm-fees = "yarn run tsx scripts/v0.6/collectMeteoraDammFees.ts" v06-return-funds = "yarn run tsx scripts/v0.6/returnFunds.ts" +v06-dump-daos = "yarn run tsx scripts/v0.6/dumpDaos.ts" +v06-migrate-daos = "yarn run tsx scripts/v0.6/migrateDaos.ts" v07-collect-meteora-damm-fees = "yarn run tsx scripts/v0.7/collectMeteoraDammFees.ts" v07-launch-template = "yarn run tsx scripts/v0.7/launchTemplate.ts" v07-start-launch = "yarn run tsx scripts/v0.7/startLaunch.ts" diff --git a/programs/futarchy/src/instructions/mod.rs b/programs/futarchy/src/instructions/mod.rs index 85b8023e3..90e20456b 100644 --- a/programs/futarchy/src/instructions/mod.rs +++ b/programs/futarchy/src/instructions/mod.rs @@ -12,6 +12,7 @@ pub mod initialize_proposal; pub mod initiate_vault_spend_optimistic_proposal; pub mod launch_proposal; pub mod provide_liquidity; +pub mod resize_dao; pub mod sponsor_proposal; pub mod spot_swap; pub mod stake_to_proposal; @@ -31,6 +32,7 @@ pub use initialize_proposal::*; pub use initiate_vault_spend_optimistic_proposal::*; pub use launch_proposal::*; pub use provide_liquidity::*; +pub use resize_dao::*; pub use sponsor_proposal::*; pub use spot_swap::*; pub use stake_to_proposal::*; diff --git a/programs/futarchy/src/instructions/resize_dao.rs b/programs/futarchy/src/instructions/resize_dao.rs new file mode 100644 index 000000000..6352ac116 --- /dev/null +++ b/programs/futarchy/src/instructions/resize_dao.rs @@ -0,0 +1,83 @@ +use anchor_lang::{system_program, Discriminator}; + +use super::*; + +#[derive(Accounts)] +pub struct ResizeDao<'info> { + /// CHECK: we check the discriminator + #[account(mut)] + pub dao: UncheckedAccount<'info>, + #[account(mut)] + pub payer: Signer<'info>, + pub system_program: Program<'info, System>, +} + +impl ResizeDao<'_> { + pub fn handle(ctx: Context) -> Result<()> { + let dao = &ctx.accounts.dao; + + require_eq!(dao.owner, &crate::ID); + let is_discriminator_correct = dao.try_borrow_data().unwrap()[..8] == Dao::discriminator(); + require_eq!(is_discriminator_correct, true); + + const AFTER_REALLOC_SIZE: usize = Dao::INIT_SPACE + 8; + // 42 bytes: 1 (Option discriminant) + 32 (Pubkey) + 8 (i64) + 1 (bool) + const BEFORE_REALLOC_SIZE: usize = AFTER_REALLOC_SIZE - 42; + + if dao.data_len() != BEFORE_REALLOC_SIZE { + // already realloced + require_eq!(dao.data_len(), AFTER_REALLOC_SIZE); + return Ok(()); + } + + let old_dao_data = OldDao::deserialize(&mut &dao.try_borrow_data().unwrap()[8..])?; + + let new_dao_data = Dao { + amm: old_dao_data.amm, + nonce: old_dao_data.nonce, + dao_creator: old_dao_data.dao_creator, + pda_bump: old_dao_data.pda_bump, + squads_multisig: old_dao_data.squads_multisig, + squads_multisig_vault: old_dao_data.squads_multisig_vault, + base_mint: old_dao_data.base_mint, + quote_mint: old_dao_data.quote_mint, + proposal_count: old_dao_data.proposal_count, + pass_threshold_bps: old_dao_data.pass_threshold_bps, + seconds_per_proposal: old_dao_data.seconds_per_proposal, + twap_initial_observation: old_dao_data.twap_initial_observation, + twap_max_observation_change_per_update: old_dao_data + .twap_max_observation_change_per_update, + twap_start_delay_seconds: old_dao_data.twap_start_delay_seconds, + min_quote_futarchic_liquidity: old_dao_data.min_quote_futarchic_liquidity, + min_base_futarchic_liquidity: old_dao_data.min_base_futarchic_liquidity, + base_to_stake: old_dao_data.base_to_stake, + seq_num: old_dao_data.seq_num, + initial_spending_limit: old_dao_data.initial_spending_limit, + team_sponsored_pass_threshold_bps: old_dao_data.team_sponsored_pass_threshold_bps, + team_address: old_dao_data.team_address, + optimistic_proposal: None, + is_optimistic_governance_enabled: false, + }; + + dao.realloc(AFTER_REALLOC_SIZE, true)?; + + let lamports_needed = Rent::get()?.minimum_balance(AFTER_REALLOC_SIZE); + + if lamports_needed > dao.lamports() { + system_program::transfer( + CpiContext::new( + ctx.accounts.system_program.to_account_info(), + system_program::Transfer { + from: ctx.accounts.payer.to_account_info(), + to: dao.to_account_info(), + }, + ), + lamports_needed - dao.lamports(), + )?; + } + + new_dao_data.serialize(&mut &mut dao.try_borrow_mut_data().unwrap()[8..])?; + + Ok(()) + } +} diff --git a/programs/futarchy/src/lib.rs b/programs/futarchy/src/lib.rs index 1c0f4ebab..0eaaa4c7a 100644 --- a/programs/futarchy/src/lib.rs +++ b/programs/futarchy/src/lib.rs @@ -100,6 +100,10 @@ pub mod futarchy { UpdateDao::handle(ctx, dao_params) } + pub fn resize_dao(ctx: Context) -> Result<()> { + ResizeDao::handle(ctx) + } + // AMM instructions pub fn spot_swap(ctx: Context, params: SpotSwapParams) -> Result<()> { diff --git a/programs/futarchy/src/state/dao.rs b/programs/futarchy/src/state/dao.rs index dfed8ac6b..0d898f636 100644 --- a/programs/futarchy/src/state/dao.rs +++ b/programs/futarchy/src/state/dao.rs @@ -110,3 +110,59 @@ impl Dao { Ok(()) } } + +#[account] +#[derive(InitSpace)] +pub struct OldDao { + /// Embedded FutarchyAmm - 1:1 relationship + pub amm: FutarchyAmm, + /// `nonce` + `dao_creator` are PDA seeds + pub nonce: u64, + pub dao_creator: Pubkey, + pub pda_bump: u8, + pub squads_multisig: Pubkey, + pub squads_multisig_vault: Pubkey, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, + pub proposal_count: u32, + // the percentage, in basis points, the pass price needs to be above the + // fail price in order for the proposal to pass + pub pass_threshold_bps: u16, + pub seconds_per_proposal: u32, + /// For manipulation-resistance the TWAP is a time-weighted average observation, + /// where observation tries to approximate price but can only move by + /// `twap_max_observation_change_per_update` per update. Because it can only move + /// a little bit per update, you need to check that it has a good initial observation. + /// Otherwise, an attacker could create a very high initial observation in the pass + /// market and a very low one in the fail market to force the proposal to pass. + /// + /// We recommend setting an initial observation around the spot price of the token, + /// and max observation change per update around 2% the spot price of the token. + /// For example, if the spot price of META is $400, we'd recommend setting an initial + /// observation of 400 (converted into the AMM prices) and a max observation change per + /// update of 8 (also converted into the AMM prices). Observations can be updated once + /// a minute, so 2% allows the proposal market to reach double the spot price or 0 + /// in 50 minutes. + pub twap_initial_observation: u128, + pub twap_max_observation_change_per_update: u128, + /// Forces TWAP calculation to start after `twap_start_delay_seconds` seconds + pub twap_start_delay_seconds: u32, + /// As an anti-spam measure and to help liquidity, you need to lock up some liquidity + /// in both futarchic markets in order to create a proposal. + /// + /// For example, for META, we can use a `min_quote_futarchic_liquidity` of + /// 5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of + /// 10 * 1_000_000_000 (10 META). + pub min_quote_futarchic_liquidity: u64, + pub min_base_futarchic_liquidity: u64, + /// Minimum amount of base tokens that must be staked to launch a proposal + pub base_to_stake: u64, + pub seq_num: u64, + pub initial_spending_limit: Option, + /// The percentage, in basis points, the pass price needs to be above the + /// fail price in order for the proposal to pass for team-sponsored proposals. + /// + /// Can be negative to allow for team-sponsored proposals to pass by default. + pub team_sponsored_pass_threshold_bps: i16, + pub team_address: Pubkey, +} diff --git a/scripts/v0.6/dumpDaos.ts b/scripts/v0.6/dumpDaos.ts new file mode 100644 index 000000000..33bb5d55c --- /dev/null +++ b/scripts/v0.6/dumpDaos.ts @@ -0,0 +1,90 @@ +import { PublicKey } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import dotenv from "dotenv"; +import * as fs from "fs"; +import * as path from "path"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function dumpAccount( + publicKey: PublicKey, + outputDir: string, + accountType: string, +) { + const accountInfo = await provider.connection.getAccountInfo(publicKey); + + if (!accountInfo) { + console.error(`Account ${publicKey.toBase58()} not found`); + return; + } + + const accountData = { + pubkey: publicKey.toBase58(), + account: { + lamports: accountInfo.lamports, + data: [accountInfo.data.toString("base64"), "base64"], + owner: accountInfo.owner.toBase58(), + executable: accountInfo.executable, + rentEpoch: "U64_MAX_PLACEHOLDER", + }, + }; + + const filename = path.join(outputDir, `${publicKey.toBase58()}.json`); + fs.writeFileSync( + filename, + JSON.stringify(accountData, null, 2).replace( + '"U64_MAX_PLACEHOLDER"', + "18446744073709551615", + ), + ); + + console.log(`Dumped ${accountType}: ${publicKey.toBase58()}`); +} + +async function main() { + const futarchy = FutarchyClient.createClient({ provider }); + + const daosDir = "daos"; + if (!fs.existsSync(daosDir)) { + fs.mkdirSync(daosDir); + } + + const daoDiscriminator = getDiscriminator("Dao"); + console.log(`DAO discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`DAO discriminator (base58): ${bs58.encode(daoDiscriminator)}`); + console.log(`Program ID: ${futarchy.futarchy.programId.toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchy.futarchy.programId, + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (const { pubkey } of daoAccounts) { + await dumpAccount(pubkey, daosDir, "DAO"); + } +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); diff --git a/scripts/v0.6/migrateDaos.ts b/scripts/v0.6/migrateDaos.ts new file mode 100644 index 000000000..427b3f7a1 --- /dev/null +++ b/scripts/v0.6/migrateDaos.ts @@ -0,0 +1,133 @@ +import { + ComputeBudgetProgram, + Keypair, + TransactionInstruction, + VersionedTransaction, + TransactionMessage, +} from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import dotenv from "dotenv"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); +const payer = provider.wallet["payer"]; + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function sendAndConfirmTransaction( + ixs: TransactionInstruction[], + label: string, + signers: Keypair[] = [], +) { + const { blockhash } = await provider.connection.getLatestBlockhash(); + + const messageV0 = new TransactionMessage({ + instructions: ixs, + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const simulationTx = new VersionedTransaction(messageV0); + simulationTx.sign([payer, ...signers]); + + const simulationResult = + await provider.connection.simulateTransaction(simulationTx); + + const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ + units: Math.ceil(simulationResult.value.unitsConsumed! * 1.15), + }); + + const finalMessageV0 = new TransactionMessage({ + instructions: [computeBudgetIx, ...ixs], + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const tx = new VersionedTransaction(finalMessageV0); + tx.sign([payer, ...signers]); + + const txHash = await provider.connection.sendRawTransaction(tx.serialize()); + console.log(`${label} transaction sent:`, txHash); + + await provider.connection.confirmTransaction(txHash, "confirmed"); + const txStatus = await provider.connection.getTransaction(txHash, { + maxSupportedTransactionVersion: 0, + commitment: "confirmed", + }); + if (txStatus?.meta?.err) { + throw new Error( + `Transaction failed: ${txHash}\nError: ${JSON.stringify( + txStatus?.meta?.err, + )}\n\n${txStatus?.meta?.logMessages?.join("\n")}`, + ); + } + console.log(`${label} transaction confirmed`); + return txHash; +} + +async function main() { + const futarchy = FutarchyClient.createClient({ provider }); + + const daoDiscriminator = getDiscriminator("Dao"); + const daoBatchSize = 15; + + console.log(`DAO discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`DAO discriminator (base58): ${bs58.encode(daoDiscriminator)}`); + console.log(`Program ID: ${futarchy.futarchy.programId.toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchy.futarchy.programId, + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (let i = 0; i < daoAccounts.length; i += daoBatchSize) { + const batch = daoAccounts.slice( + i, + Math.min(i + daoBatchSize, daoAccounts.length), + ); + console.log( + `Processing batch ${Math.floor(i / daoBatchSize) + 1} with ${batch.length} DAOs`, + ); + + const ixs = await Promise.all( + batch.map(async ({ pubkey }) => { + return await futarchy.futarchy.methods + .resizeDao() + .accounts({ + dao: pubkey, + payer: payer.publicKey, + }) + .instruction(); + }), + ); + + await sendAndConfirmTransaction( + ixs, + `Resize DAOs batch ${Math.floor(i / daoBatchSize) + 1}`, + ); + } + + console.log("Confirming DAOs can be loaded through SDK..."); + const daos = await futarchy.futarchy.account.dao.all(); + console.log(`Confirmed ${daos.length} DAOs`); +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); diff --git a/sdk/src/v0.6/types/futarchy.ts b/sdk/src/v0.6/types/futarchy.ts index d9d95cdc1..99270d126 100644 --- a/sdk/src/v0.6/types/futarchy.ts +++ b/sdk/src/v0.6/types/futarchy.ts @@ -118,6 +118,11 @@ export type Futarchy = { isMut: false; isSigner: false; }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, { name: "dao"; isMut: true; @@ -370,6 +375,16 @@ export type Futarchy = { isMut: true; isSigner: false; }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, { name: "systemProgram"; isMut: false; @@ -562,6 +577,27 @@ export type Futarchy = { }, ]; }, + { + name: "resizeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, { name: "spotSwap"; accounts: [ @@ -1304,6 +1340,52 @@ export type Futarchy = { ]; args: []; }, + { + name: "adminApproveExecuteMultisigProposal"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1474,6 +1556,142 @@ export type Futarchy = { ]; }; }, + { + name: "oldDao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, { name: "proposal"; type: { @@ -3219,6 +3437,21 @@ export type Futarchy = { name: "NoActiveOptimisticProposal"; msg: "No active optimistic proposal"; }, + { + code: 6040; + name: "OptimisticProposalAlreadyPassed"; + msg: "Optimistic proposal has already passed"; + }, + { + code: 6041; + name: "CannotSponsorOptimisticProposalChallenge"; + msg: "Team cannot sponsor a challenge to an optimistic proposal"; + }, + { + code: 6042; + name: "InvalidSpendingLimitMint"; + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; + }, ]; }; @@ -3342,6 +3575,11 @@ export const IDL: Futarchy = { isMut: false, isSigner: false, }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, { name: "dao", isMut: true, @@ -3594,6 +3832,16 @@ export const IDL: Futarchy = { isMut: true, isSigner: false, }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, { name: "systemProgram", isMut: false, @@ -3786,6 +4034,27 @@ export const IDL: Futarchy = { }, ], }, + { + name: "resizeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, { name: "spotSwap", accounts: [ @@ -4528,6 +4797,52 @@ export const IDL: Futarchy = { ], args: [], }, + { + name: "adminApproveExecuteMultisigProposal", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { @@ -4698,6 +5013,142 @@ export const IDL: Futarchy = { ], }, }, + { + name: "oldDao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, { name: "proposal", type: { @@ -6443,5 +6894,20 @@ export const IDL: Futarchy = { name: "NoActiveOptimisticProposal", msg: "No active optimistic proposal", }, + { + code: 6040, + name: "OptimisticProposalAlreadyPassed", + msg: "Optimistic proposal has already passed", + }, + { + code: 6041, + name: "CannotSponsorOptimisticProposalChallenge", + msg: "Team cannot sponsor a challenge to an optimistic proposal", + }, + { + code: 6042, + name: "InvalidSpendingLimitMint", + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", + }, ], }; diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index b9540ec56..99270d126 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -577,6 +577,27 @@ export type Futarchy = { }, ]; }, + { + name: "resizeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, { name: "spotSwap"; accounts: [ @@ -1535,6 +1556,142 @@ export type Futarchy = { ]; }; }, + { + name: "oldDao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, { name: "proposal"; type: { @@ -3877,6 +4034,27 @@ export const IDL: Futarchy = { }, ], }, + { + name: "resizeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, { name: "spotSwap", accounts: [ @@ -4835,6 +5013,142 @@ export const IDL: Futarchy = { ], }, }, + { + name: "oldDao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, { name: "proposal", type: { From 98dfe15ae1d0c89ac494659f2029f18072f0f373 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 23 Jan 2026 15:49:11 -0800 Subject: [PATCH 016/100] remove duplicate optimistic proposal check --- .../initiate_vault_spend_optimistic_proposal.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 28b6e074f..94dd55e38 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -65,16 +65,10 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::PoolNotInSpotState ); - // There should be no active optimistic proposal - require!( - self.dao.optimistic_proposal.is_none(), - FutarchyError::ActiveOptimisticProposalAlreadyEnqueued - ); - // No existing optimistic proposal can be present. If one has passed, it can be finalized (finalize_optimistic_proposal) require!( self.dao.optimistic_proposal.is_none(), - FutarchyError::ProposalDurationTooShort + FutarchyError::ActiveOptimisticProposalAlreadyEnqueued ); // Spending limit mint must be the same as the DAO's quote mint From d31f514dc07176eb202f9059d376a6f628d23775 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 10 Feb 2026 12:01:30 -0800 Subject: [PATCH 017/100] initiate vault spend optimistic proposal won't fail due to reentrancy from squads --- CLAUDE.md | 26 +- ...nitiate_vault_spend_optimistic_proposal.rs | 190 ++++----- sdk/src/v0.7/FutarchyClient.ts | 62 ++- sdk/src/v0.7/types/futarchy.ts | 50 +-- ...itiateVaultSpendOptimisticProposal.test.ts | 366 +++++++++++++++++- 5 files changed, 538 insertions(+), 156 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b0b3d1732..4787724a0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -196,13 +196,7 @@ await client Do NOT use `advanceBySlots()` for this purpose - it changes the clock which may affect time-dependent tests. -**Token amounts in tests:** Use easy-to-read round numbers like hundreds or thousands of tokens. Our standard mint decimals is 6, so: -- 100 tokens = `100_000_000` (100 * 10^6) -- 1,000 tokens = `1_000_000_000` (1000 * 10^6) - -This makes test assertions and calculations much easier to verify at a glance. - -**Isolating tests during development:** When developing or debugging tests, use `.only` to run only the tests you're working on: +**Isolating tests during development:** When writing or editing tests, ALWAYS add `.only` to the `describe`/`it` block you're working on before running. This keeps feedback fast and output clean. Once your changes pass, remove `.only` and run the full suite (`anchor test --skip-build`) to confirm nothing else broke. ```typescript // Run only this specific test @@ -216,8 +210,6 @@ describe.only("#split_tokens", function () { }); ``` -This significantly speeds up iteration and makes test output easier to read. Remember to remove `.only` before finishing development. - **Assertion messages:** Do not include assertion messages for better readability. The assertion itself should be clear enough: ```typescript @@ -231,6 +223,22 @@ assert.equal(recipientBalance.toString(), "500000000", "Recipient should have 50 Exceptions: Keep messages in `expectError()` calls and `assert.fail()` within try-catch blocks, since those are part of error handling patterns and help identify which check failed. + +**Token amounts in tests:** Use easy-to-read round numbers like hundreds or thousands of tokens. Our standard mint decimals is 6, so: +- 100 tokens = `100_000_000` (100 * 10^6) +- 1,000 tokens = `1_000_000_000` (1000 * 10^6) + +This makes test assertions and calculations much easier to verify at a glance. + +### Solana Reentrancy Guard +The Solana runtime prevents a program from appearing more than once in the same CPI stack. This affects two patterns in our codebase: + +1. **futarchy → squads → futarchy** (e.g., admin-executing a DAO config change): Futarchy cannot CPI into Squads to execute a vault transaction whose inner instructions CPI back into futarchy. Workaround: futarchy only approves/validates the Squads transaction, then the client executes it as a separate top-level transaction. + +2. **squads → futarchy → squads** (e.g., a team multisig that is itself a Squads wallet): If a Squads-initiated transaction calls a futarchy instruction that needs to CPI into Squads, the runtime will reject it. Workaround: have futarchy validate pre-created Squads accounts on-chain instead of creating them via CPI. + +When designing instructions that involve Squads CPIs, check whether either pattern applies and flag it early. The general solution is: split the operation across multiple transactions — validate/approve in one, execute in another. + ## SDK Usage ```typescript diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 94dd55e38..087a1cfea 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -8,7 +8,7 @@ pub struct InitiateVaultSpendOptimisticProposalParams { #[derive(Accounts)] #[event_cpi] pub struct InitiateVaultSpendOptimisticProposal<'info> { - #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, /// CHECK: The squads multisig vault that executes the transaction @@ -18,35 +18,26 @@ pub struct InitiateVaultSpendOptimisticProposal<'info> { #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_spending_limit: Account<'info, squads_multisig_program::SpendingLimit>, - /// CHECK: Squads multisig proposal, initialized by squads multisig program, checked by squads multisig program - #[account(mut)] - pub squads_proposal: UncheckedAccount<'info>, + #[account(constraint = squads_proposal.multisig == squads_multisig.key() @ FutarchyError::InvalidTransaction)] + pub squads_proposal: Account<'info, squads_multisig_program::Proposal>, - /// CHECK: Squads multisig vault transaction, initialized by squads multisig program, checked by squads multisig program - #[account(mut)] - pub squads_vault_transaction: UncheckedAccount<'info>, - - #[account(address = permissionless_account::id())] - pub squads_multisig_permissionless_account: Signer<'info>, + #[account(constraint = squads_vault_transaction.multisig == squads_multisig.key() @ FutarchyError::InvalidTransaction)] + pub squads_vault_transaction: Account<'info, squads_multisig_program::VaultTransaction>, #[account(mut, has_one = squads_multisig, has_one = squads_multisig_vault)] pub dao: Box>, - #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = dao.squads_multisig_vault)] + #[account(associated_token::mint = dao.quote_mint, associated_token::authority = dao.squads_multisig_vault)] pub dao_quote_vault_account: Account<'info, TokenAccount>, // Only the team can initiate an optimistic proposal - #[account(mut, address = dao.team_address)] + #[account(address = dao.team_address)] pub proposer: Signer<'info>, /// CHECK: Used for constraints pub recipient: UncheckedAccount<'info>, - #[account(mut, associated_token::mint = dao.quote_mint, associated_token::authority = recipient)] + #[account(associated_token::mint = dao.quote_mint, associated_token::authority = recipient)] pub recipient_quote_account: Account<'info, TokenAccount>, - #[account(mut)] - pub payer: Signer<'info>, - - pub system_program: Program<'info, System>, pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, pub token_program: Program<'info, Token>, } @@ -85,6 +76,97 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::InvalidAmount ); + // Validate the squads proposal is Active + require!( + matches!( + self.squads_proposal.status, + squads_multisig_program::ProposalStatus::Active { .. } + ), + FutarchyError::InvalidSquadsProposalStatus + ); + + // Validate the proposal references the vault transaction + require_eq!( + self.squads_proposal.transaction_index, + self.squads_vault_transaction.index, + FutarchyError::InvalidTransaction + ); + + // Validate the vault transaction message contains exactly the expected SPL transfer + let message = &self.squads_vault_transaction.message; + + // Must have exactly 1 instruction + require!( + message.instructions.len() == 1, + FutarchyError::InvalidTransaction + ); + + let instruction = &message.instructions[0]; + + // Program ID must be SPL Token + let program_id = message + .account_keys + .get(instruction.program_id_index as usize) + .ok_or(error!(FutarchyError::InvalidTransaction))?; + require_keys_eq!( + *program_id, + self.token_program.key(), + FutarchyError::InvalidTransaction + ); + + // Instruction data must be a Transfer: discriminator [3] + amount as u64 LE (9 bytes total) + require!( + instruction.data.len() == 9, + FutarchyError::InvalidTransaction + ); + require!(instruction.data[0] == 3, FutarchyError::InvalidTransaction); + let encoded_amount = u64::from_le_bytes( + instruction.data[1..9] + .try_into() + .map_err(|_| error!(FutarchyError::InvalidTransaction))?, + ); + require_eq!( + encoded_amount, + params.amount, + FutarchyError::InvalidTransaction + ); + + // Validate the transfer accounts: source, destination, authority + require!( + instruction.account_indexes.len() >= 3, + FutarchyError::InvalidTransaction + ); + + let source = message + .account_keys + .get(instruction.account_indexes[0] as usize) + .ok_or(error!(FutarchyError::InvalidTransaction))?; + require_keys_eq!( + *source, + self.dao_quote_vault_account.key(), + FutarchyError::InvalidTransaction + ); + + let destination = message + .account_keys + .get(instruction.account_indexes[1] as usize) + .ok_or(error!(FutarchyError::InvalidTransaction))?; + require_keys_eq!( + *destination, + self.recipient_quote_account.key(), + FutarchyError::InvalidTransaction + ); + + let authority = message + .account_keys + .get(instruction.account_indexes[2] as usize) + .ok_or(error!(FutarchyError::InvalidTransaction))?; + require_keys_eq!( + *authority, + self.squads_multisig_vault.key(), + FutarchyError::InvalidTransaction + ); + Ok(()) } @@ -97,86 +179,18 @@ impl InitiateVaultSpendOptimisticProposal<'_> { squads_multisig_vault, squads_spending_limit: _, squads_proposal, - squads_vault_transaction, + squads_vault_transaction: _, dao, - payer: _, - system_program, event_authority: _, program: _, - squads_program, + squads_program: _, proposer, recipient: _, recipient_quote_account, - squads_multisig_permissionless_account, - token_program, + token_program: _, dao_quote_vault_account, } = ctx.accounts; - // Prepare the transfer instruction - let transfer_ix = anchor_spl::token::spl_token::instruction::transfer( - &token_program.key(), - &dao_quote_vault_account.key(), - &recipient_quote_account.key(), - &squads_multisig_vault.key(), - &[&squads_multisig_vault.key()], - params.amount, - )?; - - // Compile the transaction message in Squads' format - let transaction_message = - compile_squads_transaction_message(&squads_multisig_vault.key(), &[transfer_ix])?; - - let transaction_message_bytes = transaction_message.try_to_vec()?; - - let dao_nonce = &dao.nonce.to_le_bytes(); - let dao_creator_key = dao.dao_creator.as_ref(); - let dao_seeds = &[b"dao".as_ref(), dao_creator_key, dao_nonce, &[dao.pda_bump]]; - - let dao_signer = &[&dao_seeds[..]]; - - // Create the squads transaction - squads_multisig_program::cpi::vault_transaction_create( - CpiContext::new( - squads_program.to_account_info(), - squads_multisig_program::cpi::accounts::VaultTransactionCreate { - creator: squads_multisig_permissionless_account.to_account_info(), - multisig: squads_multisig.to_account_info(), - rent_payer: proposer.to_account_info(), - system_program: system_program.to_account_info(), - transaction: squads_vault_transaction.to_account_info(), - }, - ), - squads_multisig_program::VaultTransactionCreateArgs { - ephemeral_signers: 0, - vault_index: 0, - transaction_message: transaction_message_bytes, - memo: None, - }, - )?; - - // Reload the squads multisig account to get the latest transaction index - squads_multisig.reload()?; - let transaction_index = squads_multisig.transaction_index; - - // Create the squads proposal - squads_multisig_program::cpi::proposal_create( - CpiContext::new_with_signer( - squads_program.to_account_info(), - squads_multisig_program::cpi::accounts::ProposalCreate { - creator: squads_multisig_permissionless_account.to_account_info(), - multisig: squads_multisig.to_account_info(), - rent_payer: proposer.to_account_info(), - system_program: system_program.to_account_info(), - proposal: squads_proposal.to_account_info(), - }, - dao_signer, - ), - squads_multisig_program::ProposalCreateArgs { - transaction_index, - draft: false, - }, - )?; - // Update the DAO state let clock = Clock::get()?; diff --git a/sdk/src/v0.7/FutarchyClient.ts b/sdk/src/v0.7/FutarchyClient.ts index 3a79387b2..9b14ec22a 100644 --- a/sdk/src/v0.7/FutarchyClient.ts +++ b/sdk/src/v0.7/FutarchyClient.ts @@ -53,6 +53,7 @@ import { import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; import { createAssociatedTokenAccountIdempotentInstruction, + createTransferInstruction, getAssociatedTokenAddressSync, unpackMint, TOKEN_PROGRAM_ID, @@ -1160,6 +1161,48 @@ export class FutarchyClient { index: transactionIndex, })[0]; + const daoQuoteVaultAccount = getAssociatedTokenAddressSync( + quoteMint, + squadsMultisigVault, + true, + ); + const recipientQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + recipient, + true, + ); + + // Build the SPL token transfer instruction for the vault transaction + const transferIx = createTransferInstruction( + daoQuoteVaultAccount, + recipientQuoteAccount, + squadsMultisigVault, + BigInt(amount.toString()), + ); + + const transactionMessage = new TransactionMessage({ + payerKey: payer, + recentBlockhash: "", + instructions: [transferIx], + }); + + const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage, + }); + + const proposalCreate = multisig.instructions.proposalCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + }); + return this.autocrat.methods .initiateVaultSpendOptimisticProposal({ amount }) .accounts({ @@ -1168,32 +1211,23 @@ export class FutarchyClient { squadsSpendingLimit, squadsProposal, squadsVaultTransaction, - squadsMultisigPermissionlessAccount: PERMISSIONLESS_ACCOUNT.publicKey, dao, - daoQuoteVaultAccount: getAssociatedTokenAddressSync( - quoteMint, - squadsMultisigVault, - true, - ), + daoQuoteVaultAccount, proposer, recipient, - recipientQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - recipient, - true, - ), - payer, - systemProgram: SystemProgram.programId, + recipientQuoteAccount, squadsProgram: SQUADS_PROGRAM_ID, tokenProgram: TOKEN_PROGRAM_ID, }) .preInstructions([ createAssociatedTokenAccountIdempotentInstruction( payer, - getAssociatedTokenAddressSync(quoteMint, recipient, true), + recipientQuoteAccount, recipient, quoteMint, ), + vaultTxCreate, + proposalCreate, ]); } diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 889e8038a..eeefb88f9 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -1211,7 +1211,7 @@ export type Futarchy = { accounts: [ { name: "squadsMultisig"; - isMut: true; + isMut: false; isSigner: false; }, { @@ -1226,18 +1226,13 @@ export type Futarchy = { }, { name: "squadsProposal"; - isMut: true; + isMut: false; isSigner: false; }, { name: "squadsVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigPermissionlessAccount"; isMut: false; - isSigner: true; + isSigner: false; }, { name: "dao"; @@ -1246,12 +1241,12 @@ export type Futarchy = { }, { name: "daoQuoteVaultAccount"; - isMut: true; + isMut: false; isSigner: false; }, { name: "proposer"; - isMut: true; + isMut: false; isSigner: true; }, { @@ -1261,16 +1256,6 @@ export type Futarchy = { }, { name: "recipientQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; isMut: false; isSigner: false; }, @@ -4899,7 +4884,7 @@ export const IDL: Futarchy = { accounts: [ { name: "squadsMultisig", - isMut: true, + isMut: false, isSigner: false, }, { @@ -4914,18 +4899,13 @@ export const IDL: Futarchy = { }, { name: "squadsProposal", - isMut: true, + isMut: false, isSigner: false, }, { name: "squadsVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigPermissionlessAccount", isMut: false, - isSigner: true, + isSigner: false, }, { name: "dao", @@ -4934,12 +4914,12 @@ export const IDL: Futarchy = { }, { name: "daoQuoteVaultAccount", - isMut: true, + isMut: false, isSigner: false, }, { name: "proposer", - isMut: true, + isMut: false, isSigner: true, }, { @@ -4949,16 +4929,6 @@ export const IDL: Futarchy = { }, { name: "recipientQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", isMut: false, isSigner: false, }, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 5d9333b2e..16b1010bf 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -1,11 +1,26 @@ import { PERMISSIONLESS_ACCOUNT, PriceMath, + SQUADS_PROGRAM_ID, } from "@metadaoproject/futarchy/v0.7"; -import { ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; +import { + ComputeBudgetProgram, + Keypair, + PublicKey, + SystemProgram, + Transaction, + TransactionInstruction, + TransactionMessage, +} from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { + createAssociatedTokenAccountIdempotentInstruction, + createTransferInstruction, + getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; import { assert } from "chai"; import * as squads from "@sqds/multisig"; @@ -315,7 +330,7 @@ export default function suite() { dao, amount: new BN(1000), recipient: this.payer.publicKey, - transactionIndex: 0n, + transactionIndex: 1n, }) .signers([this.payer, PERMISSIONLESS_ACCOUNT]) .rpc() @@ -396,9 +411,9 @@ export default function suite() { dao, amount: new BN(1000), recipient: this.payer.publicKey, - transactionIndex: 1n, + transactionIndex: 2n, }) - .preInstructions([ + .postInstructions([ // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ]) @@ -432,7 +447,7 @@ export default function suite() { recipient: this.payer.publicKey, transactionIndex: 1n, }) - .preInstructions([ + .postInstructions([ // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ]) @@ -440,4 +455,345 @@ export default function suite() { .rpc() .then(callbacks[0], callbacks[1]); }); + + describe("vault transaction validation", function () { + async function createSquadsVtAndProposal( + ctx: any, + multisigPda: PublicKey, + instructions: TransactionInstruction[], + transactionIndex: bigint, + isDraft: boolean = false, + ) { + const transactionMessage = new TransactionMessage({ + payerKey: ctx.payer.publicKey, + recentBlockhash: (await ctx.banksClient.getLatestBlockhash())[0], + instructions, + }); + + const tx = new Transaction().add( + squads.instructions.vaultTransactionCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: ctx.payer.publicKey, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage, + }), + squads.instructions.proposalCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: ctx.payer.publicKey, + isDraft, + }), + ); + + tx.recentBlockhash = (await ctx.banksClient.getLatestBlockhash())[0]; + tx.feePayer = ctx.payer.publicKey; + tx.sign(ctx.payer, PERMISSIONLESS_ACCOUNT); + + await ctx.banksClient.processTransaction(tx); + + const [squadsProposal] = squads.getProposalPda({ + multisigPda, + transactionIndex, + }); + const [squadsVaultTransaction] = squads.getTransactionPda({ + multisigPda, + index: transactionIndex, + }); + + return { squadsProposal, squadsVaultTransaction }; + } + + async function callInitiateRaw( + ctx: any, + dao: PublicKey, + amount: BN, + recipient: PublicKey, + squadsProposal: PublicKey, + squadsVaultTransaction: PublicKey, + ) { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = squads.getVaultPda({ + multisigPda, + index: 0, + })[0]; + const squadsSpendingLimit = squads.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + const daoAccount = await ctx.futarchy.getDao(dao); + const daoQuoteVaultAccount = getAssociatedTokenAddressSync( + daoAccount.quoteMint, + squadsMultisigVault, + true, + ); + const recipientQuoteAccount = getAssociatedTokenAddressSync( + daoAccount.quoteMint, + recipient, + true, + ); + + return ctx.futarchy.autocrat.methods + .initiateVaultSpendOptimisticProposal({ amount }) + .accounts({ + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsSpendingLimit, + squadsProposal, + squadsVaultTransaction, + dao, + daoQuoteVaultAccount, + proposer: ctx.payer.publicKey, + recipient, + recipientQuoteAccount, + squadsProgram: SQUADS_PROGRAM_ID, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + ctx.payer.publicKey, + recipientQuoteAccount, + recipient, + daoAccount.quoteMint, + ), + ]); + } + + it("fails when vault transaction has wrong transfer amount", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const wrongAmountIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 500n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [wrongAmountIx], 1n); + + const callbacks = expectError( + "InvalidTransaction", + "VT amount doesn't match instruction amount", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when vault transaction has wrong recipient", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + const wrongRecipient = Keypair.generate().publicKey; + + // Create the wrong-recipient's ATA so the instruction references it + const wrongRecipientAta = getAssociatedTokenAddressSync( + MAINNET_USDC, + wrongRecipient, + ); + + const wrongDestIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + wrongRecipientAta, + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [wrongDestIx], 1n); + + const callbacks = expectError( + "InvalidTransaction", + "VT destination doesn't match recipient", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when vault transaction has wrong source", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + const wrongSource = Keypair.generate().publicKey; + const wrongSourceAta = getAssociatedTokenAddressSync( + MAINNET_USDC, + wrongSource, + ); + + const wrongSrcIx = createTransferInstruction( + wrongSourceAta, + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [wrongSrcIx], 1n); + + const callbacks = expectError( + "InvalidTransaction", + "VT source doesn't match dao vault account", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when vault transaction uses wrong program", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + // Build a raw instruction targeting SystemProgram with SPL Transfer-like data + const data = Buffer.alloc(9); + data[0] = 3; // SPL Transfer discriminator + data.writeBigUInt64LE(1000n, 1); + + const wrongProgramIx = new TransactionInstruction({ + programId: SystemProgram.programId, + keys: [ + { + pubkey: getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + isSigner: false, + isWritable: true, + }, + { + pubkey: getAssociatedTokenAddressSync( + MAINNET_USDC, + this.payer.publicKey, + ), + isSigner: false, + isWritable: true, + }, + { pubkey: vault, isSigner: true, isWritable: false }, + ], + data, + }); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal( + this, + multisigPda, + [wrongProgramIx], + 1n, + ); + + const callbacks = expectError( + "InvalidTransaction", + "VT instruction targets wrong program", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when vault transaction has multiple instructions", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + // Two identical transfer instructions + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal( + this, + multisigPda, + [transferIx, transferIx], + 1n, + ); + + const callbacks = expectError( + "InvalidTransaction", + "VT has multiple instructions", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when squads proposal is in Draft status", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal( + this, + multisigPda, + [transferIx], + 1n, + true, // isDraft = true + ); + + const callbacks = expectError( + "InvalidSquadsProposalStatus", + "Squads proposal is in Draft status", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + }); } From 56cf9eb402a48539ae38a500aea3323ef7be2274 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 10 Feb 2026 12:35:40 -0800 Subject: [PATCH 018/100] increase payer usdc balance to prevent tests from depleting entire balance --- tests/main.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main.test.ts b/tests/main.test.ts index 35875f199..be12a118e 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -731,7 +731,7 @@ before(async function () { await mintToOverride( this.context, token.getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), - 10_000_000n * 10n ** 6n, + 100_000_000n * 10n ** 6n, ); }); From 92875b1114309f65cefcec59e258c046e0a9e911 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 12 Feb 2026 15:21:15 -0800 Subject: [PATCH 019/100] prevent udapte_dao during active optimistic proposal --- .../futarchy/src/instructions/update_dao.rs | 6 + tests/futarchy/unit/updateDao.test.ts | 300 +++++++++++++++++- 2 files changed, 291 insertions(+), 15 deletions(-) diff --git a/programs/futarchy/src/instructions/update_dao.rs b/programs/futarchy/src/instructions/update_dao.rs index 9df7dd756..5ce63c4f6 100644 --- a/programs/futarchy/src/instructions/update_dao.rs +++ b/programs/futarchy/src/instructions/update_dao.rs @@ -29,6 +29,12 @@ impl UpdateDao<'_> { if !matches!(self.dao.amm.state, PoolState::Spot { .. }) { return Err(FutarchyError::PoolNotInSpotState.into()); } + + // Prevent updates to DAO parameters if an optimistic proposal is enqueued + if matches!(self.dao.optimistic_proposal, Some(_)) { + return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); + } + Ok(()) } diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 45657aa2b..34ad34907 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -11,34 +11,100 @@ import { PERMISSIONLESS_ACCOUNT, getProposalAddrV2, InstructionUtils, + getDaoAddr, + PriceMath, + MAINNET_USDC, } from "@metadaoproject/futarchy/v0.7"; import { sha256 } from "@metadaoproject/futarchy"; import BN from "bn.js"; +const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); + export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; + let setOptimisticGovernanceEnabled: ( + dao: PublicKey, + enabled: boolean, + ) => Promise; beforeEach(async function () { - META = await this.createMint(this.payer.publicKey, 6); - USDC = await this.createMint(this.payer.publicKey, 6); + setOptimisticGovernanceEnabled = async ( + dao: PublicKey, + enabled: boolean, + ) => { + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + }; + + META = await this.createMint(this.payer.publicKey, 9); + USDC = MAINNET_USDC; + + await this.createTokenAccount(META, this.payer.publicKey); + await this.mintTo(META, this.payer.publicKey, this.payer, 10_000 * 10 ** 9); - await this.mintTo( + const nonce = new BN(Math.floor(Math.random() * 1000000)); + + await this.futarchy + .initializeDaoIx({ + baseMint: META, + quoteMint: USDC, + params: { + secondsPerProposal: 60 * 60 * 24 * 3, + twapStartDelaySeconds: 60 * 60 * 24, + twapInitialObservation: THOUSAND_BUCK_PRICE, + twapMaxObservationChangePerUpdate: THOUSAND_BUCK_PRICE.divn(100), + minQuoteFutarchicLiquidity: new BN(1), + minBaseFutarchicLiquidity: new BN(1), + passThresholdBps: 300, + nonce, + initialSpendingLimit: { + amountPerMonth: new BN(10_000_000_000), + members: [this.payer.publicKey], + }, + baseToStake: new BN(0), + teamSponsoredPassThresholdBps: 0, + teamAddress: this.payer.publicKey, + }, + provideLiquidity: true, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + [dao] = getDaoAddr({ + nonce, + daoCreator: this.payer.publicKey, + }); + + const daoAccount = await this.futarchy.getDao(dao); + + await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); + await this.transfer( USDC, - this.payer.publicKey, this.payer, - 10_000_000_000_000, - ); - await this.mintTo( - META, - this.payer.publicKey, - this.payer, - 10_000_000_000_000, + daoAccount.squadsMultisigVault, + 100_000 * 1_000_000, ); - dao = await this.setupBasicDaoWithLiquidity({ - baseMint: META, - quoteMint: USDC, - }); + await this.futarchy + .provideLiquidityIx({ + dao, + baseMint: META, + quoteMint: USDC, + maxBaseAmount: new BN(100_000 * 10 ** 6), + quoteAmount: new BN(100_000 * 10 ** 6), + }) + .rpc(); }); it("should fail updateDao execution when DAO is in Futarchy state", async function () { @@ -341,4 +407,208 @@ export default function suite() { ); } }); + + it("should fail updateDao execution when DAO has an active optimistic proposal", async function () { + const daoAccount = await this.futarchy.getDao(dao); + + // Step 1: Create updateDao squads vault transaction (index 1) + const updateDaoIx = await this.futarchy + .updateDaoIx({ + dao, + params: { + passThresholdBps: 500, + secondsPerProposal: null, + twapInitialObservation: null, + twapMaxObservationChangePerUpdate: null, + minQuoteFutarchicLiquidity: null, + minBaseFutarchicLiquidity: null, + baseToStake: null, + teamSponsoredPassThresholdBps: null, + teamAddress: null, + twapStartDelaySeconds: null, + isOptimisticGovernanceEnabled: null, + }, + }) + .instruction(); + + const updateDaoMessage = new TransactionMessage({ + payerKey: daoAccount.squadsMultisigVault, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: [updateDaoIx], + }); + + const vaultTxCreateIx = multisig.instructions.vaultTransactionCreate({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage: updateDaoMessage, + }); + + const squadsProposalCreateIx = multisig.instructions.proposalCreate({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + }); + + const [squadsProposalPda] = multisig.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + }); + + const createSquadsTx = new Transaction().add( + vaultTxCreateIx, + squadsProposalCreateIx, + ); + createSquadsTx.recentBlockhash = ( + await this.banksClient.getLatestBlockhash() + )[0]; + createSquadsTx.feePayer = this.payer.publicKey; + createSquadsTx.sign(this.payer, PERMISSIONLESS_ACCOUNT); + + await this.banksClient.processTransaction(createSquadsTx); + + // Step 2: Create futarchy proposal A linked to updateDao squads proposal + let [proposalA] = getProposalAddrV2({ squadsProposal: squadsProposalPda }); + + await this.conditionalVault.initializeQuestion( + sha256(`Will ${proposalA} pass?/FAIL/PASS`), + proposalA, + 2, + ); + + const { question, baseVault, quoteVault } = this.futarchy.getProposalPdas( + proposalA, + META, + USDC, + dao, + ); + + await this.conditionalVault + .initializeVaultIx(question, META, 2) + .postInstructions( + await InstructionUtils.getInstructions( + this.conditionalVault.initializeVaultIx(question, USDC, 2), + ), + ) + .rpc(); + + await this.futarchy + .initializeProposalIx(squadsProposalPda, dao, META, USDC, question) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + // Split tokens before launching proposal + await this.conditionalVault + .splitTokensIx(question, baseVault, META, new BN(1000_000_000), 2) + .rpc(); + await this.conditionalVault + .splitTokensIx(question, quoteVault, USDC, new BN(1000_000_000), 2) + .rpc(); + + // Launch proposal A to put DAO in Futarchy state + await this.futarchy + .launchProposalIx({ + proposal: proposalA, + dao, + baseMint: META, + quoteMint: USDC, + squadsProposal: squadsProposalPda, + }) + .rpc(); + + // Step 3: Trade on pass market to make proposal A pass + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: USDC, + proposal: proposalA, + market: "pass", + swapType: "buy", + inputAmount: new BN(900_000_000), + minOutputAmount: new BN(0), + }) + .rpc(); + + // Crank TWAP over time by doing small swaps + for (let i = 0; i < 100; i++) { + await this.advanceBySeconds(20_000); + + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: USDC, + proposal: proposalA, + market: "pass", + swapType: "buy", + inputAmount: new BN(10), + minOutputAmount: new BN(0), + payer: this.payer.publicKey, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitPrice({ microLamports: i }), + ]) + .rpc(); + } + + // Step 4: Finalize proposal A - DAO returns to Spot state + await this.futarchy.finalizeProposal(proposalA); + + // Verify DAO is in Spot state + let daoState = await this.futarchy.getDao(dao); + assert.isDefined(daoState.amm.state.spot); + + // Step 5: Enable optimistic governance and enqueue a real optimistic proposal + await setOptimisticGovernanceEnabled(dao, true); + + await this.futarchy + .initiateVaultSpendOptimisticProposalIx({ + dao, + quoteMint: USDC, + amount: new BN(1000), + recipient: this.payer.publicKey, + transactionIndex: 2n, + }) + .signers([this.payer, PERMISSIONLESS_ACCOUNT]) + .rpc(); + + // Verify optimistic proposal is set + const updatedDao = await this.futarchy.getDao(dao); + assert.exists(updatedDao.optimisticProposal); + + // Step 6: Try to execute updateDao - should fail with ActiveOptimisticProposalAlreadyEnqueued + const txExecuteIx = await multisig.instructions.vaultTransactionExecute({ + connection: this.squadsConnection, + multisigPda: daoAccount.squadsMultisig, + transactionIndex: 1n, + member: PERMISSIONLESS_ACCOUNT.publicKey, + }); + + const txExecute = new Transaction().add(txExecuteIx.instruction); + txExecute.recentBlockhash = ( + await this.banksClient.getLatestBlockhash() + )[0]; + txExecute.feePayer = this.payer.publicKey; + txExecute.sign(this.payer, PERMISSIONLESS_ACCOUNT); + + try { + await this.banksClient.processTransaction(txExecute); + assert.fail( + "Should have failed with ActiveOptimisticProposalAlreadyEnqueued", + ); + } catch (e) { + assert( + e.toString().includes("ActiveOptimisticProposalAlreadyEnqueued") || + e.toString().includes("0x1796"), + `Expected ActiveOptimisticProposalAlreadyEnqueued error, got: ${e}`, + ); + } + }); } From cf0faccc32cb552cd06ba96b44d35f05beb66f41 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 17 Feb 2026 22:31:42 +0100 Subject: [PATCH 020/100] prevent admin execution of multisig proposals when there is an active optimistic governance proposal --- ...admin_approve_execute_multisig_proposal.rs | 4 + ...dminApproveExecuteMultisigProposal.test.ts | 105 ++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/programs/futarchy/src/instructions/admin_approve_execute_multisig_proposal.rs b/programs/futarchy/src/instructions/admin_approve_execute_multisig_proposal.rs index 924dad343..0a00d93de 100644 --- a/programs/futarchy/src/instructions/admin_approve_execute_multisig_proposal.rs +++ b/programs/futarchy/src/instructions/admin_approve_execute_multisig_proposal.rs @@ -60,6 +60,10 @@ impl<'info, 'c: 'info> AdminApproveExecuteMultisigProposal<'info> { return Err(FutarchyError::PoolNotInSpotState.into()); } + if matches!(self.dao.optimistic_proposal, Some(_)) { + return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); + } + Ok(()) } diff --git a/tests/futarchy/unit/adminApproveExecuteMultisigProposal.test.ts b/tests/futarchy/unit/adminApproveExecuteMultisigProposal.test.ts index a619add4e..12e060429 100644 --- a/tests/futarchy/unit/adminApproveExecuteMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminApproveExecuteMultisigProposal.test.ts @@ -1,6 +1,7 @@ import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; import { ComputeBudgetProgram, + Keypair, PublicKey, Transaction, TransactionMessage, @@ -9,6 +10,7 @@ import { expectError, setupBasicDao } from "../../utils.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; import { createMemoInstruction } from "@solana/spl-memo"; +import BN from "bn.js"; export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; @@ -248,4 +250,107 @@ export default function suite() { .rpc() .then(callbacks[0], callbacks[1]); }); + + it("should fail when DAO has an active optimistic proposal", async function () { + const daoAccount = await this.futarchy.getDao(dao); + + // Create a simple vault transaction + proposal for the admin to approve + const transactionIndex = 1n; + + const memoMessage = new TransactionMessage({ + payerKey: this.payer.publicKey, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: [createMemoInstruction("test memo")], + }); + + const createVtAndProposalTx = new Transaction().add( + multisig.instructions.vaultTransactionCreate({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage: memoMessage, + }), + multisig.instructions.proposalCreate({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: this.payer.publicKey, + }), + ); + createVtAndProposalTx.recentBlockhash = ( + await this.banksClient.getLatestBlockhash() + )[0]; + createVtAndProposalTx.feePayer = this.payer.publicKey; + createVtAndProposalTx.sign(this.payer, PERMISSIONLESS_ACCOUNT); + + await this.banksClient.processTransaction(createVtAndProposalTx); + + const [vaultTransactionPda] = multisig.getTransactionPda({ + multisigPda: daoAccount.squadsMultisig, + index: transactionIndex, + }); + + const [squadsProposalPda] = multisig.getProposalPda({ + multisigPda: daoAccount.squadsMultisig, + transactionIndex, + }); + + const transactionAccount = + await multisig.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + vaultTransactionPda, + ); + + const { accountMetas } = await multisig.utils.accountsForTransactionExecute( + { + connection: this.squadsConnection, + message: transactionAccount.message, + ephemeralSignerBumps: [...transactionAccount.ephemeralSignerBumps], + vaultPda: daoAccount.squadsMultisigVault, + transactionPda: vaultTransactionPda, + programId: multisig.PROGRAM_ID, + }, + ); + + // Set optimisticProposal on the DAO via direct state manipulation + daoAccount.optimisticProposal = { + squadsProposal: Keypair.generate().publicKey, + enqueuedTimestamp: new BN(1000), + }; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + + const callbacks = expectError( + "ActiveOptimisticProposalAlreadyEnqueued", + "Should fail because DAO has an active optimistic proposal", + ); + + await this.futarchy.autocrat.methods + .adminApproveExecuteMultisigProposal() + .accounts({ + dao: dao, + squadsMultisig: daoAccount.squadsMultisig, + squadsMultisigProposal: squadsProposalPda, + squadsMultisigVaultTransaction: vaultTransactionPda, + admin: this.payer.publicKey, + squadsMultisigProgram: multisig.PROGRAM_ID, + }) + .remainingAccounts( + accountMetas.map((meta) => + meta.pubkey.equals(dao) ? { ...meta, isSigner: false } : meta, + ), + ) + .signers([this.payer]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); } From 3c85ce4fa9954aaac680b95aa97226f246cb68d9 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 18 Feb 2026 18:33:23 +0100 Subject: [PATCH 021/100] prevent deadlock from optimistic proposal staleness --- .../execute_spending_limit_change.rs | 4 + ...nitiate_vault_spend_optimistic_proposal.rs | 6 + .../unit/executeSpendingLimitChange.test.ts | 148 ++++++++++++++++++ ...itiateVaultSpendOptimisticProposal.test.ts | 49 ++++++ 4 files changed, 207 insertions(+) diff --git a/programs/futarchy/src/instructions/execute_spending_limit_change.rs b/programs/futarchy/src/instructions/execute_spending_limit_change.rs index 5f46afdb6..6967df41d 100644 --- a/programs/futarchy/src/instructions/execute_spending_limit_change.rs +++ b/programs/futarchy/src/instructions/execute_spending_limit_change.rs @@ -29,6 +29,10 @@ impl<'info, 'c: 'info> ExecuteSpendingLimitChange<'info> { return Err(FutarchyError::PoolNotInSpotState.into()); } + if matches!(self.dao.optimistic_proposal, Some(_)) { + return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); + } + Ok(()) } diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 087a1cfea..d06529391 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -85,6 +85,12 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::InvalidSquadsProposalStatus ); + // Ensure the squads proposal is not invalidated by a previous config transaction + require_gt!( + self.squads_proposal.transaction_index, + self.squads_multisig.stale_transaction_index + ); + // Validate the proposal references the vault transaction require_eq!( self.squads_proposal.transaction_index, diff --git a/tests/futarchy/unit/executeSpendingLimitChange.test.ts b/tests/futarchy/unit/executeSpendingLimitChange.test.ts index 18566129b..4e7d4e2b1 100644 --- a/tests/futarchy/unit/executeSpendingLimitChange.test.ts +++ b/tests/futarchy/unit/executeSpendingLimitChange.test.ts @@ -175,6 +175,154 @@ export default function suite() { .rpc(); }); + it("throws if the DAO has an active optimistic proposal", async function () { + const newSpendingLimitPda = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + + const addSpendingLimitIx = multisig.instructions.multisigAddSpendingLimit({ + multisigPda, + spendingLimit: newSpendingLimitPda, + configAuthority: dao, + rentPayer: this.payer.publicKey, + createKey: dao, + vaultIndex: 0, + mint: USDC, + amount: BigInt(50_000 * 10 ** 6), + period: multisig.types.Period.Month, + members: [this.payer.publicKey], + destinations: [], + memo: "", + }); + + const proposalResult = await this.initializeAndLaunchProposal({ + dao, + instructions: [addSpendingLimitIx], + }); + + proposal = proposalResult.proposal; + squadsProposal = proposalResult.squadsProposal; + + const { question, quoteVault } = this.futarchy.getProposalPdas( + proposal, + META, + USDC, + dao, + ); + + await this.conditionalVault + .splitTokensIx(question, quoteVault, USDC, new BN(11_000 * 1_000_000), 2) + .rpc(); + + // Trade heavily on pass market to make it pass + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: USDC, + proposal, + market: "pass", + swapType: "buy", + inputAmount: new BN(10_000 * 1_000_000), + minOutputAmount: new BN(0), + }) + .rpc(); + + // Crank TWAP to build up price history + for (let i = 0; i < 100; i++) { + this.advanceBySeconds(10_000); + + await this.futarchy + .conditionalSwapIx({ + dao, + baseMint: META, + quoteMint: USDC, + proposal, + market: "pass", + swapType: "buy", + inputAmount: new BN(10), + minOutputAmount: new BN(0), + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitPrice({ microLamports: i }), + ]) + .rpc(); + } + + // Finalize the proposal + await this.futarchy.finalizeProposal(proposal); + + const storedProposal = await this.futarchy.getProposal(proposal); + assert.exists(storedProposal.state.passed); + + // Set an active optimistic proposal on the DAO + const daoAccount = await this.futarchy.getDao(dao); + daoAccount.optimisticProposal = { + squadsProposal: PublicKey.default, + enqueuedTimestamp: new BN(0), + }; + const daoAccountBuffer = + await this.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + const daoBanksAccount = await this.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + this.context.setAccount(dao, daoBanksAccount); + + const [vaultTransactionPda] = multisig.getTransactionPda({ + multisigPda: multisigPda, + index: 1n, + }); + + const transactionAccount = + await multisig.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + vaultTransactionPda, + ); + + const [vaultPda] = multisig.getVaultPda({ + multisigPda, + index: transactionAccount.vaultIndex, + programId: multisig.PROGRAM_ID, + }); + + const { accountMetas } = await multisig.utils.accountsForTransactionExecute( + { + connection: this.squadsConnection, + message: transactionAccount.message, + ephemeralSignerBumps: [...transactionAccount.ephemeralSignerBumps], + vaultPda, + transactionPda: vaultTransactionPda, + programId: multisig.PROGRAM_ID, + }, + ); + + const callbacks = expectError( + "ActiveOptimisticProposalAlreadyEnqueued", + "Should fail because there is an active optimistic proposal", + ); + + await this.futarchy.autocrat.methods + .executeSpendingLimitChange() + .accounts({ + squadsMultisig: multisigPda, + proposal, + dao, + squadsProposal, + squadsMultisigProgram: multisig.PROGRAM_ID, + vaultTransaction: vaultTransactionPda, + }) + .remainingAccounts( + accountMetas.map((meta) => + meta.pubkey.equals(dao) ? { ...meta, isSigner: false } : meta, + ), + ) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + it("throws if the transaction is to remove the DAO as a member", async function () { const removeMemberIx = multisig.instructions.multisigRemoveMember({ multisigPda, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 16b1010bf..522ab1395 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -795,5 +795,54 @@ export default function suite() { .then((b: any) => b.signers([this.payer]).rpc()) .then(callbacks[0], callbacks[1]); }); + + it("fails when squads proposal is stale", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + // Create the squads proposal while stale_transaction_index is 0 + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + // Now mutate the multisig to set staleTransactionIndex = 1 + const multisigAccount = await squads.accounts.Multisig.fromAccountAddress( + this.squadsConnection, + multisigPda, + ); + + const modifiedMultisig = squads.accounts.Multisig.fromArgs({ + ...multisigAccount, + staleTransactionIndex: new BN(1), + }); + const [serialized] = modifiedMultisig.serialize(); + + const multisigBanksAccount = + await this.banksClient.getAccount(multisigPda); + multisigBanksAccount.data.set(serialized, 0); + this.context.setAccount(multisigPda, multisigBanksAccount); + + const callbacks = expectError( + "RequireGtViolated", + "Squads proposal is stale", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); }); } From 8717302614121f4777654c38feba1335e2a7ae32 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 11 Mar 2026 22:51:24 +0100 Subject: [PATCH 022/100] ensure squads vault transaction is created by permissionless account --- .../initiate_vault_spend_optimistic_proposal.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index d06529391..cc6296483 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -91,6 +91,13 @@ impl InitiateVaultSpendOptimisticProposal<'_> { self.squads_multisig.stale_transaction_index ); + // Ensure the vault transaction was created by the permissionless account + require_keys_eq!( + self.squads_vault_transaction.creator, + permissionless_account::id(), + FutarchyError::InvalidTransaction + ); + // Validate the proposal references the vault transaction require_eq!( self.squads_proposal.transaction_index, From 4337ae82ba558c2e1e7183e7f4ca6919c86fbcaa Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 14 Mar 2026 01:28:35 +0100 Subject: [PATCH 023/100] additional checks for proper transaction in vault spend optimistic proposals --- ...nitiate_vault_spend_optimistic_proposal.rs | 63 +++ sdk/src/v0.7/FutarchyClient.ts | 4 +- ...itiateVaultSpendOptimisticProposal.test.ts | 464 +++++++++++++++++- 3 files changed, 529 insertions(+), 2 deletions(-) diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index cc6296483..29af31b07 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -85,6 +85,20 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::InvalidSquadsProposalStatus ); + // Proposal must be fresh: no votes recorded yet + require!( + self.squads_proposal.approved.is_empty(), + FutarchyError::InvalidTransaction + ); + require!( + self.squads_proposal.rejected.is_empty(), + FutarchyError::InvalidTransaction + ); + require!( + self.squads_proposal.cancelled.is_empty(), + FutarchyError::InvalidTransaction + ); + // Ensure the squads proposal is not invalidated by a previous config transaction require_gt!( self.squads_proposal.transaction_index, @@ -105,9 +119,58 @@ impl InitiateVaultSpendOptimisticProposal<'_> { FutarchyError::InvalidTransaction ); + // Must target vault index 0 + require_eq!( + self.squads_vault_transaction.vault_index, + 0, + FutarchyError::InvalidTransaction + ); + + // No ephemeral signers for SPL transfer + require!( + self.squads_vault_transaction + .ephemeral_signer_bumps + .is_empty(), + FutarchyError::InvalidTransaction + ); + // Validate the vault transaction message contains exactly the expected SPL transfer let message = &self.squads_vault_transaction.message; + // Exactly 1 signer (the vault, which is both the payer and the SPL Transfer authority) + require_eq!(message.num_signers, 1_u8, FutarchyError::InvalidTransaction); + + // First account key (sole signer) must be the vault + let first_signer = message + .account_keys + .first() + .ok_or(error!(FutarchyError::InvalidTransaction))?; + require_keys_eq!( + *first_signer, + self.squads_multisig_vault.key(), + FutarchyError::InvalidTransaction + ); + + // Vault is a writable signer (TransactionMessage always marks the payerKey as writable) + require_eq!( + message.num_writable_signers, + 1_u8, + FutarchyError::InvalidTransaction + ); + + // Source + destination are writable non-signers + require_eq!( + message.num_writable_non_signers, + 2_u8, + FutarchyError::InvalidTransaction + ); + + // No address table lookups + require!( + message.address_table_lookups.is_empty(), + FutarchyError::InvalidTransaction + ); + // Must have exactly 1 instruction require!( message.instructions.len() == 1, diff --git a/sdk/src/v0.7/FutarchyClient.ts b/sdk/src/v0.7/FutarchyClient.ts index 9b14ec22a..d4587cd63 100644 --- a/sdk/src/v0.7/FutarchyClient.ts +++ b/sdk/src/v0.7/FutarchyClient.ts @@ -1180,8 +1180,10 @@ export class FutarchyClient { BigInt(amount.toString()), ); + // Use the vault as the payerKey so it deduplicates with the transfer authority, + // producing a clean message with exactly 1 signer (the vault). const transactionMessage = new TransactionMessage({ - payerKey: payer, + payerKey: squadsMultisigVault, recentBlockhash: "", instructions: [transferIx], }); diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 522ab1395..af1fc3eee 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -464,8 +464,9 @@ export default function suite() { transactionIndex: bigint, isDraft: boolean = false, ) { + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; const transactionMessage = new TransactionMessage({ - payerKey: ctx.payer.publicKey, + payerKey: vault, recentBlockhash: (await ctx.banksClient.getLatestBlockhash())[0], instructions, }); @@ -796,6 +797,467 @@ export default function suite() { .then(callbacks[0], callbacks[1]); }); + it("fails when vault transaction has wrong vault_index", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + vaultIndex: 1, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "VT has wrong vault_index", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when vault transaction has ephemeral signers", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + ephemeralSignerBumps: Uint8Array.from([255]), + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "VT has ephemeral signers", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when message has wrong num_signers", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + message: { + ...vtAccount.message, + numSigners: 2, + }, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Message has wrong num_signers", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when first signer is not the vault", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const tamperedKeys = [...vtAccount.message.accountKeys]; + tamperedKeys[0] = Keypair.generate().publicKey; + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + message: { + ...vtAccount.message, + accountKeys: tamperedKeys, + }, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "First signer is not the vault", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when message has wrong num_writable_signers", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + message: { + ...vtAccount.message, + numWritableSigners: 2, + }, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Message has too many writable signers", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when message has wrong num_writable_non_signers", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + message: { + ...vtAccount.message, + numWritableNonSigners: 1, + }, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Message has wrong numWritableNonSigners", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when message has address table lookups", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const vtAccount = + await squads.accounts.VaultTransaction.fromAccountAddress( + this.squadsConnection, + squadsVaultTransaction, + ); + + const modifiedVt = squads.accounts.VaultTransaction.fromArgs({ + ...vtAccount, + message: { + ...vtAccount.message, + addressTableLookups: [ + { + accountKey: Keypair.generate().publicKey, + writableIndexes: Uint8Array.from([0]), + readonlyIndexes: Uint8Array.from([1]), + }, + ], + }, + }); + const [serialized] = modifiedVt.serialize(); + + const vtBanksAccount = await this.banksClient.getAccount( + squadsVaultTransaction, + ); + vtBanksAccount.data = serialized; + this.context.setAccount(squadsVaultTransaction, vtBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Message has address table lookups", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when squads proposal has approvals", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const proposalAccount = await squads.accounts.Proposal.fromAccountAddress( + this.squadsConnection, + squadsProposal, + ); + + const modifiedProposal = squads.accounts.Proposal.fromArgs({ + ...proposalAccount, + approved: [Keypair.generate().publicKey], + }); + const [serialized] = modifiedProposal.serialize(); + + const proposalBanksAccount = + await this.banksClient.getAccount(squadsProposal); + proposalBanksAccount.data = serialized; + this.context.setAccount(squadsProposal, proposalBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Proposal has approvals", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + + it("fails when squads proposal has rejections", async function () { + const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; + const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; + + const transferIx = createTransferInstruction( + getAssociatedTokenAddressSync(MAINNET_USDC, vault, true), + getAssociatedTokenAddressSync(MAINNET_USDC, this.payer.publicKey), + vault, + 1000n, + ); + + const { squadsProposal, squadsVaultTransaction } = + await createSquadsVtAndProposal(this, multisigPda, [transferIx], 1n); + + const proposalAccount = await squads.accounts.Proposal.fromAccountAddress( + this.squadsConnection, + squadsProposal, + ); + + const modifiedProposal = squads.accounts.Proposal.fromArgs({ + ...proposalAccount, + rejected: [Keypair.generate().publicKey], + }); + const [serialized] = modifiedProposal.serialize(); + + const proposalBanksAccount = + await this.banksClient.getAccount(squadsProposal); + proposalBanksAccount.data = serialized; + this.context.setAccount(squadsProposal, proposalBanksAccount); + + const callbacks = expectError( + "InvalidTransaction", + "Proposal has rejections", + ); + + await callInitiateRaw( + this, + dao, + new BN(1000), + this.payer.publicKey, + squadsProposal, + squadsVaultTransaction, + ) + .then((b: any) => b.signers([this.payer]).rpc()) + .then(callbacks[0], callbacks[1]); + }); + it("fails when squads proposal is stale", async function () { const multisigPda = squads.getMultisigPda({ createKey: dao })[0]; const vault = squads.getVaultPda({ multisigPda, index: 0 })[0]; From e05d565adede36a8b1a95f4f4b536242a808ee59 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 20 Mar 2026 19:46:46 +0100 Subject: [PATCH 024/100] finalize resize dao logic, add scripts for dumping and resizing daos --- Anchor.toml | 2 + .../futarchy/src/instructions/resize_dao.rs | 3 +- scripts/v0.7/dumpDaos.ts | 90 +++++++++++ scripts/v0.7/resizeDaos.ts | 145 ++++++++++++++++++ 4 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 scripts/v0.7/dumpDaos.ts create mode 100644 scripts/v0.7/resizeDaos.ts diff --git a/Anchor.toml b/Anchor.toml index 3e732aca6..bc9fe904f 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -71,6 +71,8 @@ v07-dump-launches-funding-records = "yarn run tsx scripts/v0.7/dumpLaunchesAndFu v07-resize-launches-funding-records = "yarn run tsx scripts/v0.7/resizeLaunchesAndFundingRecords.ts" v07-dump-launches = "yarn run tsx scripts/v0.7/dumpLaunches.ts" v07-resize-launches = "yarn run tsx scripts/v0.7/resizeLaunches.ts" +v07-dump-daos = "yarn run tsx scripts/v0.7/dumpDaos.ts" +v07-resize-daos = "yarn run tsx scripts/v0.7/resizeDaos.ts" [test] startup_wait = 5000 diff --git a/programs/futarchy/src/instructions/resize_dao.rs b/programs/futarchy/src/instructions/resize_dao.rs index 6352ac116..fbed86068 100644 --- a/programs/futarchy/src/instructions/resize_dao.rs +++ b/programs/futarchy/src/instructions/resize_dao.rs @@ -56,7 +56,8 @@ impl ResizeDao<'_> { team_sponsored_pass_threshold_bps: old_dao_data.team_sponsored_pass_threshold_bps, team_address: old_dao_data.team_address, optimistic_proposal: None, - is_optimistic_governance_enabled: false, + // if the team address is not the default address, then optimistic governance should be enabled + is_optimistic_governance_enabled: !old_dao_data.team_address.eq(&Pubkey::default()), }; dao.realloc(AFTER_REALLOC_SIZE, true)?; diff --git a/scripts/v0.7/dumpDaos.ts b/scripts/v0.7/dumpDaos.ts new file mode 100644 index 000000000..64bebc6a3 --- /dev/null +++ b/scripts/v0.7/dumpDaos.ts @@ -0,0 +1,90 @@ +import { PublicKey } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.7"; +import dotenv from "dotenv"; +import * as fs from "fs"; +import * as path from "path"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function dumpAccount( + publicKey: PublicKey, + outputDir: string, + accountType: string, +) { + const accountInfo = await provider.connection.getAccountInfo(publicKey); + + if (!accountInfo) { + console.error(`Account ${publicKey.toBase58()} not found`); + return; + } + + const accountData = { + pubkey: publicKey.toBase58(), + account: { + lamports: accountInfo.lamports, + data: [accountInfo.data.toString("base64"), "base64"], + owner: accountInfo.owner.toBase58(), + executable: accountInfo.executable, + rentEpoch: "U64_MAX_PLACEHOLDER", + }, + }; + + const filename = path.join(outputDir, `${publicKey.toBase58()}.json`); + fs.writeFileSync( + filename, + JSON.stringify(accountData, null, 2).replace( + '"U64_MAX_PLACEHOLDER"', + "18446744073709551615", + ), + ); + + console.log(`Dumped ${accountType}: ${publicKey.toBase58()}`); +} + +async function main() { + const futarchyClient = FutarchyClient.createClient({ provider }); + + const daosDir = "test-ledger-accounts"; + if (!fs.existsSync(daosDir)) { + fs.mkdirSync(daosDir); + } + + const daoDiscriminator = getDiscriminator("Dao"); + console.log(`Dao discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`Dao discriminator (base58): ${bs58.encode(daoDiscriminator)}`); + console.log(`Program ID: ${futarchyClient.getProgramId().toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchyClient.getProgramId(), + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (const { pubkey } of daoAccounts) { + await dumpAccount(pubkey, daosDir, "Dao"); + } +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); diff --git a/scripts/v0.7/resizeDaos.ts b/scripts/v0.7/resizeDaos.ts new file mode 100644 index 000000000..73f829f5a --- /dev/null +++ b/scripts/v0.7/resizeDaos.ts @@ -0,0 +1,145 @@ +import { + ComputeBudgetProgram, + Keypair, + TransactionInstruction, + VersionedTransaction, + TransactionMessage, +} from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/v0.7"; +import dotenv from "dotenv"; +import bs58 from "bs58"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); +const payer = provider.wallet["payer"]; + +function getDiscriminator(accountName: string): Buffer { + return Buffer.from( + anchor.BorshAccountsCoder.accountDiscriminator(accountName), + ); +} + +async function main() { + const futarchyClient = FutarchyClient.createClient({ provider }); + const autocrat = futarchyClient["autocrat"]; + + const daoDiscriminator = getDiscriminator("Dao"); + + const batchSize = 20; + + console.log(`Dao discriminator (hex): ${daoDiscriminator.toString("hex")}`); + console.log(`Program ID: ${futarchyClient.getProgramId().toBase58()}\n`); + + const daoAccounts = await provider.connection.getProgramAccounts( + futarchyClient.getProgramId(), + { + filters: [ + { + memcmp: { + offset: 0, + bytes: bs58.encode(daoDiscriminator), + }, + }, + ], + }, + ); + + console.log(`Found ${daoAccounts.length} DAOs`); + for (let i = 0; i < daoAccounts.length; i += batchSize) { + const batch = daoAccounts.slice( + i, + Math.min(i + batchSize, daoAccounts.length), + ); + console.log( + `Processing batch ${i / batchSize + 1} with ${batch.length} DAOs`, + ); + + const ixs = await Promise.all( + batch.map(async ({ pubkey }) => { + return await autocrat.methods + .resizeDao() + .accounts({ + dao: pubkey, + payer: payer.publicKey, + }) + .instruction(); + }), + ); + + await sendAndConfirmTransaction( + ixs, + `Resize DAOs batch ${i / batchSize + 1}`, + ); + } + + // Verify all accounts load through SDK and report optimistic governance status + console.log("\nConfirming DAOs can be loaded through SDK..."); + const daos = await autocrat.account.dao.all(); + console.log(`Confirmed ${daos.length} DAOs\n`); + + for (const { publicKey, account: dao } of daos) { + console.log(`DAO: ${publicKey.toBase58()}`); + console.log(` Team address: ${dao.teamAddress.toBase58()}`); + console.log( + ` Optimistic governance enabled: ${dao.isOptimisticGovernanceEnabled}`, + ); + } +} + +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); + +async function sendAndConfirmTransaction( + ixs: TransactionInstruction[], + label: string, + signers: Keypair[] = [], +) { + const { blockhash } = await provider.connection.getLatestBlockhash(); + + // Simulate without compute budget to get units consumed + const messageV0 = new TransactionMessage({ + instructions: ixs, + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const simulationTx = new VersionedTransaction(messageV0); + simulationTx.sign([payer, ...signers]); + + const simulationResult = + await provider.connection.simulateTransaction(simulationTx); + + const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({ + units: Math.ceil(simulationResult.value.unitsConsumed! * 1.15), + }); + + // Rebuild transaction with compute budget instruction prepended + const finalMessageV0 = new TransactionMessage({ + instructions: [computeBudgetIx, ...ixs], + payerKey: payer.publicKey, + recentBlockhash: blockhash, + }).compileToV0Message(); + const tx = new VersionedTransaction(finalMessageV0); + tx.sign([payer, ...signers]); + + const txHash = await provider.connection.sendRawTransaction(tx.serialize()); + console.log(`${label} transaction sent:`, txHash); + + await provider.connection.confirmTransaction(txHash, "confirmed"); + const txStatus = await provider.connection.getTransaction(txHash, { + maxSupportedTransactionVersion: 0, + commitment: "confirmed", + }); + if (txStatus?.meta?.err) { + throw new Error( + `Transaction failed: ${txHash}\nError: ${JSON.stringify( + txStatus?.meta?.err, + )}\n\n${txStatus?.meta?.logMessages?.join("\n")}`, + ); + } + console.log(`${label} transaction confirmed`); + return txHash; +} From 9bb28ac8f2f716a8cc3fbbeaea866e334ea83f9f Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 24 Mar 2026 01:20:25 +0100 Subject: [PATCH 025/100] initial layout for v2 SDK --- sdk2/.gitignore | 2 + sdk2/package.json | 73 + sdk2/permissionless-account.json | 1 + sdk2/src/conditional_vault/index.ts | 1 + .../v0.4/ConditionalVaultClient.ts | 468 ++ sdk2/src/conditional_vault/v0.4/index.ts | 3 + sdk2/src/conditional_vault/v0.4/pda.ts | 74 + .../v0.4/types/conditional_vault.ts | 1849 ++++ .../src/conditional_vault/v0.4/types/index.ts | 34 + sdk2/src/constants.ts | 135 + sdk2/src/futarchy/index.ts | 1 + sdk2/src/futarchy/v0.6/FutarchyClient.ts | 1250 +++ sdk2/src/futarchy/v0.6/index.ts | 3 + sdk2/src/futarchy/v0.6/pda.ts | 54 + sdk2/src/futarchy/v0.6/types/futarchy.ts | 7471 +++++++++++++++++ sdk2/src/futarchy/v0.6/types/index.ts | 51 + sdk2/src/index.ts | 8 + sdk2/src/pda.ts | 22 + sdk2/src/utils.ts | 19 + sdk2/tsconfig.json | 18 + sdk2/yarn.lock | 3331 ++++++++ 21 files changed, 14868 insertions(+) create mode 100644 sdk2/.gitignore create mode 100644 sdk2/package.json create mode 100644 sdk2/permissionless-account.json create mode 100644 sdk2/src/conditional_vault/index.ts create mode 100644 sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts create mode 100644 sdk2/src/conditional_vault/v0.4/index.ts create mode 100644 sdk2/src/conditional_vault/v0.4/pda.ts create mode 100644 sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts create mode 100644 sdk2/src/conditional_vault/v0.4/types/index.ts create mode 100644 sdk2/src/constants.ts create mode 100644 sdk2/src/futarchy/index.ts create mode 100644 sdk2/src/futarchy/v0.6/FutarchyClient.ts create mode 100644 sdk2/src/futarchy/v0.6/index.ts create mode 100644 sdk2/src/futarchy/v0.6/pda.ts create mode 100644 sdk2/src/futarchy/v0.6/types/futarchy.ts create mode 100644 sdk2/src/futarchy/v0.6/types/index.ts create mode 100644 sdk2/src/index.ts create mode 100644 sdk2/src/pda.ts create mode 100644 sdk2/src/utils.ts create mode 100644 sdk2/tsconfig.json create mode 100644 sdk2/yarn.lock diff --git a/sdk2/.gitignore b/sdk2/.gitignore new file mode 100644 index 000000000..7bd11f8a3 --- /dev/null +++ b/sdk2/.gitignore @@ -0,0 +1,2 @@ +dist +tsconfig.tsbuildinfo diff --git a/sdk2/package.json b/sdk2/package.json new file mode 100644 index 000000000..102b9072f --- /dev/null +++ b/sdk2/package.json @@ -0,0 +1,73 @@ +{ + "name": "@metadaoproject/futarchy-v2", + "version": "0.7.3-alpha.1", + "type": "module", + "main": "dist/index.js", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "license": "BSL-1.0", + "files": [ + "/dist" + ], + "exports": { + ".": "./dist/index.js", + "./v0.3": "./dist/v0.3/index.js", + "./v0.4": "./dist/v0.4/index.js", + "./v0.5": "./dist/v0.5/index.js", + "./v0.6": "./dist/v0.6/index.js", + "./v0.7": "./dist/v0.7/index.js" + }, + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", + "build": "tsc", + "build-local": "rm -rf ./dist && cp ../target/types/* ./src/v0.7/types && yarn tsc", + "prepublishOnly": "yarn lint:fix && yarn build" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.29.0", + "@metaplex-foundation/umi": "^0.9.2", + "@metaplex-foundation/umi-bundle-defaults": "^0.9.2", + "@metaplex-foundation/umi-uploader-bundlr": "^0.9.2", + "@noble/hashes": "^1.4.0", + "@solana/spl-token": "^0.3.7", + "@solana/web3.js": "^1.76.0", + "@sqds/multisig": "^2.1.4", + "bn.js": "^5.2.1", + "decimal.js": "^10.4.3", + "esbuild": "^0.17.15" + }, + "devDependencies": { + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "3.6.2", + "solana-bankrun": "^0.2.0", + "spl-token-bankrun": "0.2.3", + "ts-mocha": "^10.0.0", + "typescript": "^5.5.5" + }, + "resolutions": { + "error-ex": "=1.3.2", + "strip-ansi": "=6.0.1", + "wrap-ansi": "=7.0.0", + "ansi-styles": "=4.3.0", + "color-string": "=2.1.0", + "is-arrayish": "=0.3.2", + "chalk": "=4.1.2", + "supports-color": "=7.2.0", + "slice-ansi": "=5.0.0", + "ansi-regex": "=5.0.1", + "color-name": "=2.0.0", + "chalk-template": "=0.4.0", + "supports-hyperlinks": "=2.3.0", + "has-ansi": "=4.0.1", + "color-convert": "=2.0.1", + "backslash": "=0.2.0", + "simple-swizzle": "=0.2.2", + "debug": "=4.4.1", + "color": "=4.2.3" + } +} diff --git a/sdk2/permissionless-account.json b/sdk2/permissionless-account.json new file mode 100644 index 000000000..81b00d37f --- /dev/null +++ b/sdk2/permissionless-account.json @@ -0,0 +1 @@ +[249,158,188,171,243,143,1,48,87,243,209,153,144,106,23,88,161,209,65,217,199,121,0,250,3,203,133,138,141,112,243,38,198,205,120,222,160,224,151,190,84,254,127,178,224,195,130,243,145,73,20,91,9,69,222,184,23,1,2,196,202,206,153,192] \ No newline at end of file diff --git a/sdk2/src/conditional_vault/index.ts b/sdk2/src/conditional_vault/index.ts new file mode 100644 index 000000000..e5bb29172 --- /dev/null +++ b/sdk2/src/conditional_vault/index.ts @@ -0,0 +1 @@ +export * from "./v0.4/index.js"; diff --git a/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts b/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts new file mode 100644 index 000000000..4aa216fe7 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts @@ -0,0 +1,468 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { AccountInfo, Keypair, PublicKey } from "@solana/web3.js"; + +import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; + +import BN from "bn.js"; +import { + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, +} from "../../constants.js"; +import { getMetadataAddr } from "../../pda.js"; +import { + getQuestionAddr, + getVaultAddr, + getConditionalTokenMintAddr, +} from "./pda.js"; + +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import { ConditionalVault, Question } from "./types/index.js"; + +export type CreateVaultClientParams = { + provider: AnchorProvider; + conditionalVaultProgramId?: PublicKey; +}; + +export class ConditionalVaultClient { + public readonly provider: AnchorProvider; + public readonly vaultProgram: Program; + + constructor(provider: AnchorProvider, conditionalVaultProgramId: PublicKey) { + this.provider = provider; + this.vaultProgram = new Program( + ConditionalVaultIDL, + conditionalVaultProgramId, + provider, + ); + } + + public static createClient( + createVaultClientParams: CreateVaultClientParams, + ): ConditionalVaultClient { + let { provider, conditionalVaultProgramId } = createVaultClientParams; + + return new ConditionalVaultClient( + provider, + conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + ); + } + + async fetchQuestion(question: PublicKey): Promise { + return this.vaultProgram.account.question.fetchNullable(question); + } + + async fetchVault(vault: PublicKey): Promise { + return this.vaultProgram.account.conditionalVault.fetchNullable(vault); + } + + async deserializeQuestion( + accountInfo: AccountInfo, + ): Promise { + return this.vaultProgram.coder.accounts.decode( + "question", + accountInfo.data, + ); + } + + async deserializeVault( + accountInfo: AccountInfo, + ): Promise { + return this.vaultProgram.coder.accounts.decode( + "conditionalVault", + accountInfo.data, + ); + } + + initializeQuestionIx( + questionId: Uint8Array, + oracle: PublicKey, + numOutcomes: number, + ) { + const [question] = getQuestionAddr( + this.vaultProgram.programId, + questionId, + oracle, + numOutcomes, + ); + + return this.vaultProgram.methods + .initializeQuestion({ + questionId: Array.from(questionId), + oracle, + numOutcomes, + }) + .accounts({ + question, + }); + } + + async initializeQuestion( + questionId: Uint8Array, + oracle: PublicKey, + numOutcomes: number, + ): Promise { + const [question] = getQuestionAddr( + this.vaultProgram.programId, + questionId, + oracle, + numOutcomes, + ); + + await this.initializeQuestionIx(questionId, oracle, numOutcomes).rpc(); + + return question; + } + + initializeVaultIx( + question: PublicKey, + underlyingTokenMint: PublicKey, + numOutcomes: number, + payer: PublicKey = this.provider.publicKey, + ) { + const [vault] = getVaultAddr( + this.vaultProgram.programId, + question, + underlyingTokenMint, + ); + + let conditionalTokenMintAddrs = []; + for (let i = 0; i < numOutcomes; i++) { + const [conditionalTokenMint] = getConditionalTokenMintAddr( + this.vaultProgram.programId, + vault, + i, + ); + conditionalTokenMintAddrs.push(conditionalTokenMint); + } + + const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ); + + return this.vaultProgram.methods + .initializeConditionalVault() + .accounts({ + vault, + question, + underlyingTokenMint, + vaultUnderlyingTokenAccount, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + vaultUnderlyingTokenAccount, + vault, + underlyingTokenMint, + ), + ]) + .remainingAccounts( + conditionalTokenMintAddrs.map((conditionalTokenMint) => { + return { + pubkey: conditionalTokenMint, + isWritable: true, + isSigner: false, + }; + }), + ); + } + + // TODO remove `numOucomes` + + async initializeVault( + question: PublicKey, + underlyingTokenMint: PublicKey, + numOutcomes: number, + ): Promise { + const [vault] = getVaultAddr( + this.vaultProgram.programId, + question, + underlyingTokenMint, + ); + + await this.initializeVaultIx( + question, + underlyingTokenMint, + numOutcomes, + ).rpc(); + + return vault; + } + + resolveQuestionIx( + question: PublicKey, + oracle: Keypair, + payoutNumerators: number[], + ) { + return this.vaultProgram.methods + .resolveQuestion({ + payoutNumerators, + }) + .accounts({ + question, + oracle: oracle.publicKey, + }) + .signers([oracle]); + } + + getConditionalTokenMints(vault: PublicKey, numOutcomes: number): PublicKey[] { + let conditionalTokenMintAddrs = []; + for (let i = 0; i < numOutcomes; i++) { + const [conditionalTokenMint] = getConditionalTokenMintAddr( + this.vaultProgram.programId, + vault, + i, + ); + conditionalTokenMintAddrs.push(conditionalTokenMint); + } + return conditionalTokenMintAddrs; + } + + getRemainingAccounts( + conditionalTokenMints: PublicKey[], + userConditionalAccounts: PublicKey[], + ) { + return conditionalTokenMints + .concat(userConditionalAccounts) + .map((account) => ({ + pubkey: account, + isWritable: true, + isSigner: false, + })); + } + + // Helper method to get conditional token accounts and instructions + getConditionalTokenAccountsAndInstructions( + vault: PublicKey, + numOutcomes: number, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const conditionalTokenMintAddrs = this.getConditionalTokenMints( + vault, + numOutcomes, + ); + const userConditionalAccounts = conditionalTokenMintAddrs.map((mint) => + getAssociatedTokenAddressSync(mint, user, true), + ); + + const preInstructions = conditionalTokenMintAddrs.map((mint) => + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(mint, user, true), + user, + mint, + ), + ); + + const remainingAccounts = this.getRemainingAccounts( + conditionalTokenMintAddrs, + userConditionalAccounts, + ); + + return { userConditionalAccounts, preInstructions, remainingAccounts }; + } + + splitTokensIx( + question: PublicKey, + vault: PublicKey, + underlyingTokenMint: PublicKey, + amount: BN, + numOutcomes: number, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const { preInstructions, remainingAccounts } = + this.getConditionalTokenAccountsAndInstructions( + vault, + numOutcomes, + user, + payer, + ); + + return this.vaultProgram.methods + .splitTokens(amount) + .accounts({ + question, + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + }) + .preInstructions(preInstructions) + .remainingAccounts(remainingAccounts); + } + + mergeTokensIx( + question: PublicKey, + vault: PublicKey, + underlyingTokenMint: PublicKey, + amount: BN, + numOutcomes: number, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + let conditionalTokenMintAddrs = this.getConditionalTokenMints( + vault, + numOutcomes, + ); + + let userConditionalAccounts = []; + for (let conditionalTokenMint of conditionalTokenMintAddrs) { + userConditionalAccounts.push( + getAssociatedTokenAddressSync(conditionalTokenMint, user, true), + ); + } + + let ix = this.vaultProgram.methods + .mergeTokens(amount) + .accounts({ + question, + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + }) + .preInstructions( + conditionalTokenMintAddrs.map((conditionalTokenMint) => { + return createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(conditionalTokenMint, user, true), + user, + conditionalTokenMint, + ); + }), + ) + .remainingAccounts( + conditionalTokenMintAddrs + .concat(userConditionalAccounts) + .map((conditionalTokenMint) => { + return { + pubkey: conditionalTokenMint, + isWritable: true, + isSigner: false, + }; + }), + ); + + return ix; + } + + redeemTokensIx( + question: PublicKey, + vault: PublicKey, + underlyingTokenMint: PublicKey, + numOutcomes: number, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + let conditionalTokenMintAddrs = []; + for (let i = 0; i < numOutcomes; i++) { + const [conditionalTokenMint] = getConditionalTokenMintAddr( + this.vaultProgram.programId, + vault, + i, + ); + conditionalTokenMintAddrs.push(conditionalTokenMint); + } + + let userConditionalAccounts = []; + for (let conditionalTokenMint of conditionalTokenMintAddrs) { + userConditionalAccounts.push( + getAssociatedTokenAddressSync(conditionalTokenMint, user, true), + ); + } + + let ix = this.vaultProgram.methods + .redeemTokens() + .accounts({ + question, + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + }) + .preInstructions( + conditionalTokenMintAddrs.map((conditionalTokenMint) => { + return createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(conditionalTokenMint, user, true), + user, + conditionalTokenMint, + ); + }), + ) + .remainingAccounts( + conditionalTokenMintAddrs + .concat(userConditionalAccounts) + .map((conditionalTokenMint) => { + return { + pubkey: conditionalTokenMint, + isWritable: true, + isSigner: false, + }; + }), + ); + + return ix; + } + + addMetadataToConditionalTokensIx( + vault: PublicKey, + index: number, + name: string, + symbol: string, + uri: string, + payer: PublicKey = this.provider.publicKey, + ) { + const [conditionalTokenMint] = getConditionalTokenMintAddr( + this.vaultProgram.programId, + vault, + index, + ); + + const [conditionalTokenMetadata] = getMetadataAddr(conditionalTokenMint); + + return this.vaultProgram.methods + .addMetadataToConditionalTokens({ + name, + symbol, + uri, + }) + .accounts({ + payer, + vault, + conditionalTokenMint, + conditionalTokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + }); + } +} diff --git a/sdk2/src/conditional_vault/v0.4/index.ts b/sdk2/src/conditional_vault/v0.4/index.ts new file mode 100644 index 000000000..1918f77d1 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.4/index.ts @@ -0,0 +1,3 @@ +export * from "./ConditionalVaultClient.js"; +export * from "./types/index.js"; +export * from "./pda.js"; diff --git a/sdk2/src/conditional_vault/v0.4/pda.ts b/sdk2/src/conditional_vault/v0.4/pda.ts new file mode 100644 index 000000000..2e52277b2 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.4/pda.ts @@ -0,0 +1,74 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import BN from "bn.js"; + +export const getQuestionAddr = ( + programId: PublicKey, + questionId: Uint8Array, + oracle: PublicKey, + numOutcomes: number, +) => { + if (questionId.length != 32) { + throw new Error("questionId must be 32 bytes"); + } + + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("question"), + Buffer.from(questionId), + oracle.toBuffer(), + new BN(numOutcomes).toArrayLike(Buffer, "le", 1), + ], + programId, + ); +}; + +export const getVaultAddr = ( + programId: PublicKey, + question: PublicKey, + underlyingTokenMint: PublicKey, +) => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("conditional_vault"), + question.toBuffer(), + underlyingTokenMint.toBuffer(), + ], + programId, + ); +}; + +export const getConditionalTokenMintAddr = ( + programId: PublicKey, + vault: PublicKey, + index: number, +) => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("conditional_token"), + vault.toBuffer(), + new BN(index).toArrayLike(Buffer, "le", 1), + ], + programId, + ); +}; + +export const getDownAndUpMintAddrs = ( + programId: PublicKey, + vault: PublicKey, +): { down: PublicKey; up: PublicKey } => { + return { + down: getConditionalTokenMintAddr(programId, vault, 0)[0], + up: getConditionalTokenMintAddr(programId, vault, 1)[0], + }; +}; + +export const getFailAndPassMintAddrs = ( + programId: PublicKey, + vault: PublicKey, +): { fail: PublicKey; pass: PublicKey } => { + return { + fail: getConditionalTokenMintAddr(programId, vault, 0)[0], + pass: getConditionalTokenMintAddr(programId, vault, 1)[0], + }; +}; diff --git a/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts b/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts new file mode 100644 index 000000000..27c245b79 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts @@ -0,0 +1,1849 @@ +export type ConditionalVault = { + version: "0.4.0"; + name: "conditional_vault"; + instructions: [ + { + name: "initializeQuestion"; + accounts: [ + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeQuestionArgs"; + }; + }, + ]; + }, + { + name: "resolveQuestion"; + accounts: [ + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "oracle"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ResolveQuestionArgs"; + }; + }, + ]; + }, + { + name: "initializeConditionalVault"; + accounts: [ + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "underlyingTokenMint"; + isMut: false; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "splitTokens"; + accounts: [ + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "mergeTokens"; + accounts: [ + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "redeemTokens"; + accounts: [ + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "addMetadataToConditionalTokens"; + accounts: [ + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalTokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddMetadataToConditionalTokensArgs"; + }; + }, + ]; + }, + ]; + accounts: [ + { + name: "conditionalVault"; + type: { + kind: "struct"; + fields: [ + { + name: "question"; + type: "publicKey"; + }, + { + name: "underlyingTokenMint"; + type: "publicKey"; + }, + { + name: "underlyingTokenAccount"; + type: "publicKey"; + }, + { + name: "conditionalTokenMints"; + type: { + vec: "publicKey"; + }; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "decimals"; + type: "u8"; + }, + { + name: "seqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "question"; + docs: [ + "Questions represent statements about future events.", + "", + "These statements include:", + '- "Will this proposal pass?"', + '- "Who, if anyone, will be hired?"', + '- "How effective will the grant committee deem this grant?"', + "", + 'Questions have 2 or more possible outcomes. For a question like "will this', + 'proposal pass," the outcomes are "yes" and "no." For a question like "who', + 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', + "", + 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', + 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', + 'also have questions with scalar outcomes. For example, the question "how', + 'effective will the grant committee deem this grant" could have two outcomes:', + '"ineffective" and "effective." If the grant committee deems the grant 70%', + 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', + "outcome would resolve to 0.3.", + "", + "Once resolved, the sum of all outcome resolutions is exactly 1.", + ]; + type: { + kind: "struct"; + fields: [ + { + name: "questionId"; + type: { + array: ["u8", 32]; + }; + }, + { + name: "oracle"; + type: "publicKey"; + }, + { + name: "payoutNumerators"; + type: { + vec: "u32"; + }; + }, + { + name: "payoutDenominator"; + type: "u32"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + ]; + }; + }, + { + name: "AddMetadataToConditionalTokensArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "name"; + type: "string"; + }, + { + name: "symbol"; + type: "string"; + }, + { + name: "uri"; + type: "string"; + }, + ]; + }; + }, + { + name: "InitializeQuestionArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "questionId"; + type: { + array: ["u8", 32]; + }; + }, + { + name: "oracle"; + type: "publicKey"; + }, + { + name: "numOutcomes"; + type: "u8"; + }, + ]; + }; + }, + { + name: "ResolveQuestionArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "payoutNumerators"; + type: { + vec: "u32"; + }; + }, + ]; + }; + }, + { + name: "VaultStatus"; + type: { + kind: "enum"; + variants: [ + { + name: "Active"; + }, + { + name: "Finalized"; + }, + { + name: "Reverted"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "AddMetadataToConditionalTokensEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "vault"; + type: "publicKey"; + index: false; + }, + { + name: "conditionalTokenMint"; + type: "publicKey"; + index: false; + }, + { + name: "conditionalTokenMetadata"; + type: "publicKey"; + index: false; + }, + { + name: "name"; + type: "string"; + index: false; + }, + { + name: "symbol"; + type: "string"; + index: false; + }, + { + name: "uri"; + type: "string"; + index: false; + }, + { + name: "seqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "InitializeConditionalVaultEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "vault"; + type: "publicKey"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "underlyingTokenMint"; + type: "publicKey"; + index: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "conditionalTokenMints"; + type: { + vec: "publicKey"; + }; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "seqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "InitializeQuestionEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "questionId"; + type: { + array: ["u8", 32]; + }; + index: false; + }, + { + name: "oracle"; + type: "publicKey"; + index: false; + }, + { + name: "numOutcomes"; + type: "u8"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "MergeTokensEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + { + name: "vault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "postUserUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postVaultUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postUserConditionalTokenBalances"; + type: { + vec: "u64"; + }; + index: false; + }, + { + name: "postConditionalTokenSupplies"; + type: { + vec: "u64"; + }; + index: false; + }, + { + name: "seqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "RedeemTokensEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + { + name: "vault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "postUserUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postVaultUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postConditionalTokenSupplies"; + type: { + vec: "u64"; + }; + index: false; + }, + { + name: "seqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "ResolveQuestionEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "payoutNumerators"; + type: { + vec: "u32"; + }; + index: false; + }, + ]; + }, + { + name: "SplitTokensEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + { + name: "vault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "postUserUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postVaultUnderlyingBalance"; + type: "u64"; + index: false; + }, + { + name: "postUserConditionalTokenBalances"; + type: { + vec: "u64"; + }; + index: false; + }, + { + name: "postConditionalTokenSupplies"; + type: { + vec: "u64"; + }; + index: false; + }, + { + name: "seqNum"; + type: "u64"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AssertFailed"; + msg: "An assertion failed"; + }, + { + code: 6001; + name: "InsufficientUnderlyingTokens"; + msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; + }, + { + code: 6002; + name: "InsufficientConditionalTokens"; + msg: "Insufficient conditional token balance to merge this `amount`"; + }, + { + code: 6003; + name: "InvalidVaultUnderlyingTokenAccount"; + msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; + }, + { + code: 6004; + name: "InvalidConditionalTokenMint"; + msg: "This conditional token mint is not this vault's conditional token mint"; + }, + { + code: 6005; + name: "CantRedeemConditionalTokens"; + msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens"; + }, + { + code: 6006; + name: "InsufficientNumConditions"; + msg: "Questions need 2 or more conditions"; + }, + { + code: 6007; + name: "InvalidNumPayoutNumerators"; + msg: "Invalid number of payout numerators"; + }, + { + code: 6008; + name: "InvalidConditionals"; + msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens"; + }, + { + code: 6009; + name: "ConditionalMintMismatch"; + msg: "Conditional mint not in vault"; + }, + { + code: 6010; + name: "BadConditionalMint"; + msg: "Unable to deserialize a conditional token mint"; + }, + { + code: 6011; + name: "BadConditionalTokenAccount"; + msg: "Unable to deserialize a conditional token account"; + }, + { + code: 6012; + name: "ConditionalTokenMintMismatch"; + msg: "User conditional token account mint does not match conditional mint"; + }, + { + code: 6013; + name: "PayoutZero"; + msg: "Payouts must sum to 1 or more"; + }, + { + code: 6014; + name: "QuestionAlreadyResolved"; + msg: "Question already resolved"; + }, + { + code: 6015; + name: "ConditionalTokenMetadataAlreadySet"; + msg: "Conditional token metadata already set"; + }, + { + code: 6016; + name: "UnauthorizedConditionalTokenAccount"; + msg: "Conditional token account is not owned by the authority"; + }, + ]; +}; + +export const IDL: ConditionalVault = { + version: "0.4.0", + name: "conditional_vault", + instructions: [ + { + name: "initializeQuestion", + accounts: [ + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeQuestionArgs", + }, + }, + ], + }, + { + name: "resolveQuestion", + accounts: [ + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "oracle", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ResolveQuestionArgs", + }, + }, + ], + }, + { + name: "initializeConditionalVault", + accounts: [ + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "underlyingTokenMint", + isMut: false, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "splitTokens", + accounts: [ + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "mergeTokens", + accounts: [ + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "redeemTokens", + accounts: [ + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "addMetadataToConditionalTokens", + accounts: [ + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "conditionalTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalTokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddMetadataToConditionalTokensArgs", + }, + }, + ], + }, + ], + accounts: [ + { + name: "conditionalVault", + type: { + kind: "struct", + fields: [ + { + name: "question", + type: "publicKey", + }, + { + name: "underlyingTokenMint", + type: "publicKey", + }, + { + name: "underlyingTokenAccount", + type: "publicKey", + }, + { + name: "conditionalTokenMints", + type: { + vec: "publicKey", + }, + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "decimals", + type: "u8", + }, + { + name: "seqNum", + type: "u64", + }, + ], + }, + }, + { + name: "question", + docs: [ + "Questions represent statements about future events.", + "", + "These statements include:", + '- "Will this proposal pass?"', + '- "Who, if anyone, will be hired?"', + '- "How effective will the grant committee deem this grant?"', + "", + 'Questions have 2 or more possible outcomes. For a question like "will this', + 'proposal pass," the outcomes are "yes" and "no." For a question like "who', + 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', + "", + 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', + 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', + 'also have questions with scalar outcomes. For example, the question "how', + 'effective will the grant committee deem this grant" could have two outcomes:', + '"ineffective" and "effective." If the grant committee deems the grant 70%', + 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', + "outcome would resolve to 0.3.", + "", + "Once resolved, the sum of all outcome resolutions is exactly 1.", + ], + type: { + kind: "struct", + fields: [ + { + name: "questionId", + type: { + array: ["u8", 32], + }, + }, + { + name: "oracle", + type: "publicKey", + }, + { + name: "payoutNumerators", + type: { + vec: "u32", + }, + }, + { + name: "payoutDenominator", + type: "u32", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + ], + }, + }, + { + name: "AddMetadataToConditionalTokensArgs", + type: { + kind: "struct", + fields: [ + { + name: "name", + type: "string", + }, + { + name: "symbol", + type: "string", + }, + { + name: "uri", + type: "string", + }, + ], + }, + }, + { + name: "InitializeQuestionArgs", + type: { + kind: "struct", + fields: [ + { + name: "questionId", + type: { + array: ["u8", 32], + }, + }, + { + name: "oracle", + type: "publicKey", + }, + { + name: "numOutcomes", + type: "u8", + }, + ], + }, + }, + { + name: "ResolveQuestionArgs", + type: { + kind: "struct", + fields: [ + { + name: "payoutNumerators", + type: { + vec: "u32", + }, + }, + ], + }, + }, + { + name: "VaultStatus", + type: { + kind: "enum", + variants: [ + { + name: "Active", + }, + { + name: "Finalized", + }, + { + name: "Reverted", + }, + ], + }, + }, + ], + events: [ + { + name: "AddMetadataToConditionalTokensEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "vault", + type: "publicKey", + index: false, + }, + { + name: "conditionalTokenMint", + type: "publicKey", + index: false, + }, + { + name: "conditionalTokenMetadata", + type: "publicKey", + index: false, + }, + { + name: "name", + type: "string", + index: false, + }, + { + name: "symbol", + type: "string", + index: false, + }, + { + name: "uri", + type: "string", + index: false, + }, + { + name: "seqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "InitializeConditionalVaultEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "vault", + type: "publicKey", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "underlyingTokenMint", + type: "publicKey", + index: false, + }, + { + name: "vaultUnderlyingTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "conditionalTokenMints", + type: { + vec: "publicKey", + }, + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "seqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "InitializeQuestionEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "questionId", + type: { + array: ["u8", 32], + }, + index: false, + }, + { + name: "oracle", + type: "publicKey", + index: false, + }, + { + name: "numOutcomes", + type: "u8", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "MergeTokensEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + { + name: "vault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "postUserUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postVaultUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postUserConditionalTokenBalances", + type: { + vec: "u64", + }, + index: false, + }, + { + name: "postConditionalTokenSupplies", + type: { + vec: "u64", + }, + index: false, + }, + { + name: "seqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "RedeemTokensEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + { + name: "vault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "postUserUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postVaultUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postConditionalTokenSupplies", + type: { + vec: "u64", + }, + index: false, + }, + { + name: "seqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "ResolveQuestionEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "payoutNumerators", + type: { + vec: "u32", + }, + index: false, + }, + ], + }, + { + name: "SplitTokensEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + { + name: "vault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "postUserUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postVaultUnderlyingBalance", + type: "u64", + index: false, + }, + { + name: "postUserConditionalTokenBalances", + type: { + vec: "u64", + }, + index: false, + }, + { + name: "postConditionalTokenSupplies", + type: { + vec: "u64", + }, + index: false, + }, + { + name: "seqNum", + type: "u64", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AssertFailed", + msg: "An assertion failed", + }, + { + code: 6001, + name: "InsufficientUnderlyingTokens", + msg: "Insufficient underlying token balance to mint this amount of conditional tokens", + }, + { + code: 6002, + name: "InsufficientConditionalTokens", + msg: "Insufficient conditional token balance to merge this `amount`", + }, + { + code: 6003, + name: "InvalidVaultUnderlyingTokenAccount", + msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", + }, + { + code: 6004, + name: "InvalidConditionalTokenMint", + msg: "This conditional token mint is not this vault's conditional token mint", + }, + { + code: 6005, + name: "CantRedeemConditionalTokens", + msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens", + }, + { + code: 6006, + name: "InsufficientNumConditions", + msg: "Questions need 2 or more conditions", + }, + { + code: 6007, + name: "InvalidNumPayoutNumerators", + msg: "Invalid number of payout numerators", + }, + { + code: 6008, + name: "InvalidConditionals", + msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens", + }, + { + code: 6009, + name: "ConditionalMintMismatch", + msg: "Conditional mint not in vault", + }, + { + code: 6010, + name: "BadConditionalMint", + msg: "Unable to deserialize a conditional token mint", + }, + { + code: 6011, + name: "BadConditionalTokenAccount", + msg: "Unable to deserialize a conditional token account", + }, + { + code: 6012, + name: "ConditionalTokenMintMismatch", + msg: "User conditional token account mint does not match conditional mint", + }, + { + code: 6013, + name: "PayoutZero", + msg: "Payouts must sum to 1 or more", + }, + { + code: 6014, + name: "QuestionAlreadyResolved", + msg: "Question already resolved", + }, + { + code: 6015, + name: "ConditionalTokenMetadataAlreadySet", + msg: "Conditional token metadata already set", + }, + { + code: 6016, + name: "UnauthorizedConditionalTokenAccount", + msg: "Conditional token account is not owned by the authority", + }, + ], +}; diff --git a/sdk2/src/conditional_vault/v0.4/types/index.ts b/sdk2/src/conditional_vault/v0.4/types/index.ts new file mode 100644 index 000000000..b308696ed --- /dev/null +++ b/sdk2/src/conditional_vault/v0.4/types/index.ts @@ -0,0 +1,34 @@ +import { + ConditionalVault as ConditionalVaultProgram, + IDL as ConditionalVaultIDL, +} from "./conditional_vault.js"; +export { ConditionalVaultProgram, ConditionalVaultIDL }; + +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +export type Question = IdlAccounts["question"]; +export type ConditionalVault = + IdlAccounts["conditionalVault"]; + +export type AddMetadataToConditionalTokensEvent = + IdlEvents["AddMetadataToConditionalTokensEvent"]; +export type InitializeConditionalVaultEvent = + IdlEvents["InitializeConditionalVaultEvent"]; +export type InitializeQuestionEvent = + IdlEvents["InitializeQuestionEvent"]; +export type MergeTokensEvent = + IdlEvents["MergeTokensEvent"]; +export type RedeemTokensEvent = + IdlEvents["RedeemTokensEvent"]; +export type ResolveQuestionEvent = + IdlEvents["ResolveQuestionEvent"]; +export type SplitTokensEvent = + IdlEvents["SplitTokensEvent"]; +export type ConditionalVaultEvent = + | AddMetadataToConditionalTokensEvent + | InitializeConditionalVaultEvent + | InitializeQuestionEvent + | MergeTokensEvent + | RedeemTokensEvent + | ResolveQuestionEvent + | SplitTokensEvent; diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts new file mode 100644 index 000000000..780cfe31e --- /dev/null +++ b/sdk2/src/constants.ts @@ -0,0 +1,135 @@ +import { Keypair, PublicKey } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { BN } from "bn.js"; + +export const FUTARCHY_V0_6_PROGRAM_ID = new PublicKey( + "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq", +); +export const AMM_PROGRAM_ID = new PublicKey( + "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", +); +export const CONDITIONAL_VAULT_v0_4_PROGRAM_ID = new PublicKey( + "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", +); +export const LAUNCHPAD_V0_7_PROGRAM_ID = new PublicKey( + "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM", +); +export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( + "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", +); +export const PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID = new PublicKey( + "pbPPQH7jyKoSLu8QYs3rSY3YkDRXEBojKbTgnUg7NDS", +); +export const BID_WALL_V0_1_PROGRAM_ID = new PublicKey( + "WALL8ucBuUyL46QYxwYJjidaFYhdvxUFrgvBxPshERx", +); +export const MINT_GOVERNOR_V0_1_PROGRAM_ID = new PublicKey( + "gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH", +); +export const PERFORMANCE_PACKAGE_V2_PROGRAM_ID = new PublicKey( + "pPV2pfrxnmstSb9j7kEeCLny5BGj6SNwCWGd6xbGGzz", +); +export const LIQUIDATION_V0_1_PROGRAM_ID = new PublicKey( + "LiQnowFbFQdYyZhF4pUbpsrZCjxRTQ1upKJxZ2VXjde", +); + +export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( + "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", +); + +export const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( + "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", +); + +export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( + "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", +); + +export const META_MINT = new PublicKey( + "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", +); +export const MAINNET_USDC = new PublicKey( + "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", +); + +export const DEVNET_USDC = new PublicKey( + "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", +); +export const DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( + "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", +); + +export const USDC_DECIMALS = 6; + +export const AUTOCRAT_LUTS: PublicKey[] = []; + +export const RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( + [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], + RAYDIUM_CP_SWAP_PROGRAM_ID, +)[0]; + +export const DEVNET_RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( + [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +)[0]; + +export const DAMM_V2_PROGRAM_ID = new PublicKey( + "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", +); + +export const DAMM_V2_POOL_AUTHORITY = new PublicKey( + "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC", +); + +export const LOW_FEE_RAYDIUM_CONFIG = new PublicKey( + "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2", +); + +export const DEVNET_LOW_FEE_RAYDIUM_CONFIG = PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("amm_config"), + new BN(0).toArrayLike(Buffer, "be", 2), + ], + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +)[0]; + +export const RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( + "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8", +); + +export const DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( + "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2", +); + +export const SQUADS_PROGRAM_CONFIG = new PublicKey( + "BSTq9w3kZwNwpBXJEvTZz2G9ZTNyKBvoSeXMvwb4cNZr", +); + +export const SQUADS_PROGRAM_ID = new PublicKey( + "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", +); + +export const SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( + "5DH2e3cJmFpyi6mk65EGFediunm4ui6BiKNUNrhWtD1b", +); + +export const SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET = new PublicKey( + "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", +); + +export const LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG = new PublicKey( + "FaA6RM9enPh1tU9Y8LiGCq715JubLc49WGcYTdNvDfsc", +); + +export const METADAO_MULTISIG_VAULT = new PublicKey( + "6awyHMshBGVjJ3ozdSJdyyDE1CTAXUwrpNMaRGMsb4sf", +); + +export const PERMISSIONLESS_ACCOUNT = Keypair.fromSecretKey( + Uint8Array.from([ + 249, 158, 188, 171, 243, 143, 1, 48, 87, 243, 209, 153, 144, 106, 23, 88, + 161, 209, 65, 217, 199, 121, 0, 250, 3, 203, 133, 138, 141, 112, 243, 38, + 198, 205, 120, 222, 160, 224, 151, 190, 84, 254, 127, 178, 224, 195, 130, + 243, 145, 73, 20, 91, 9, 69, 222, 184, 23, 1, 2, 196, 202, 206, 153, 192, + ]), +); diff --git a/sdk2/src/futarchy/index.ts b/sdk2/src/futarchy/index.ts new file mode 100644 index 000000000..f77abe821 --- /dev/null +++ b/sdk2/src/futarchy/index.ts @@ -0,0 +1 @@ +export * from "./v0.6/index.js"; diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk2/src/futarchy/v0.6/FutarchyClient.ts new file mode 100644 index 000000000..a800cc05d --- /dev/null +++ b/sdk2/src/futarchy/v0.6/FutarchyClient.ts @@ -0,0 +1,1250 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AddressLookupTableAccount, + ComputeBudgetProgram, + PublicKey, + SystemProgram, + Transaction, + TransactionInstruction, + TransactionMessage, +} from "@solana/web3.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + createTransferInstruction, + getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { sha256 } from "@noble/hashes/sha256"; +import BN from "bn.js"; +import * as multisig from "@sqds/multisig"; + +import { + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + MAINNET_USDC, + PERMISSIONLESS_ACCOUNT, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + SQUADS_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + METADAO_MULTISIG_VAULT, + DAMM_V2_PROGRAM_ID, + LAUNCHPAD_V0_7_PROGRAM_ID, + DAMM_V2_POOL_AUTHORITY, +} from "../../constants.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { InstructionUtils } from "../../utils.js"; + +import { + Dao, + Proposal, + InitializeDaoParams, + UpdateDaoParams, +} from "./types/index.js"; +import { Futarchy, IDL as FutarchyIDL } from "./types/futarchy.js"; +import { + getDaoAddr, + getProposalAddr, + getProposalAddrV2, + getStakeAddr, +} from "./pda.js"; + +import { + getQuestionAddr, + getVaultAddr, + getConditionalTokenMintAddr, +} from "../../conditional_vault/v0.4/index.js"; +import { ConditionalVaultClient } from "../../conditional_vault/v0.4/index.js"; + +export type CreateClientParams = { + provider: AnchorProvider; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; +}; + +export type ProposalVaults = { + baseVault: PublicKey; + quoteVault: PublicKey; +}; + +export class FutarchyClient { + public readonly provider: AnchorProvider; + public readonly autocrat: Program; + public readonly vaultClient: ConditionalVaultClient; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + autocratProgramId: PublicKey, + conditionalVaultProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.autocrat = new Program( + FutarchyIDL, + autocratProgramId, + provider, + ); + this.vaultClient = ConditionalVaultClient.createClient({ + provider, + conditionalVaultProgramId, + }); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateClientParams, + ): FutarchyClient { + let { provider, autocratProgramId, conditionalVaultProgramId } = + createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new FutarchyClient( + provider, + autocratProgramId || FUTARCHY_V0_6_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + luts, + ); + } + + getProgramId(): PublicKey { + return this.autocrat.programId; + } + + async getProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetch(proposal); + } + + async getDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetch(dao); + } + + async fetchProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetchNullable(proposal); + } + + async fetchDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetchNullable(dao); + } + + async deserializeProposal( + accountInfo: AccountInfo, + ): Promise { + return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); + } + + async deserializeDao(accountInfo: AccountInfo): Promise { + return this.autocrat.coder.accounts.decode("dao", accountInfo.data); + } + + getProposalPdas( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + dao: PublicKey, + ): { + question: PublicKey; + baseVault: PublicKey; + quoteVault: PublicKey; + passBaseMint: PublicKey; + passQuoteMint: PublicKey; + failBaseMint: PublicKey; + failQuoteMint: PublicKey; + } { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const [question] = getQuestionAddr( + vaultProgramId, + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + const [baseVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + baseMint, + ); + const [quoteVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + quoteMint, + ); + + const [failBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 0, + ); + const [failQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 0, + ); + + const [passBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 1, + ); + const [passQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 1, + ); + + return { + question, + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + }; + } + + initializeDaoIx({ + baseMint, + params, + provideLiquidity = false, + quoteMint = MAINNET_USDC, + squadsProgramConfigTreasury = SQUADS_PROGRAM_CONFIG_TREASURY, + }: { + baseMint: PublicKey; + params: InitializeDaoParams; + provideLiquidity?: boolean; + quoteMint?: PublicKey; + squadsProgramConfigTreasury?: PublicKey; + }) { + const [dao] = getDaoAddr({ + nonce: params.nonce, + daoCreator: this.provider.publicKey, + }); + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + + let daoCreatorBaseAccount = null; + let daoCreatorQuoteAccount = null; + if (provideLiquidity) { + daoCreatorBaseAccount = getAssociatedTokenAddressSync( + baseMint, + this.provider.publicKey, + true, + ); + daoCreatorQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + this.provider.publicKey, + true, + ); + } + + const spendingLimit = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + + return this.autocrat.methods.initializeDao(params).accounts({ + dao, + baseMint, + quoteMint, + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury, + squadsProgram: SQUADS_PROGRAM_ID, + spendingLimit, + futarchyAmmBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + futarchyAmmQuoteVault: getAssociatedTokenAddressSync( + quoteMint, + dao, + true, + ), + }); + } + + launchProposalIx({ + proposal, + dao, + baseMint, + quoteMint, + squadsProposal, + }: { + proposal: PublicKey; + dao: PublicKey; + baseMint: PublicKey; + quoteMint: PublicKey; + squadsProposal: PublicKey; + }) { + const { + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); + + const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; + + return this.autocrat.methods + .launchProposal() + .accounts({ + proposal, + dao, + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + ammPassBaseVault: getAssociatedTokenAddressSync( + passBaseMint, + dao, + true, + ), + ammPassQuoteVault: getAssociatedTokenAddressSync( + passQuoteMint, + dao, + true, + ), + ammFailBaseVault: getAssociatedTokenAddressSync( + failBaseMint, + dao, + true, + ), + ammFailQuoteVault: getAssociatedTokenAddressSync( + failQuoteMint, + dao, + true, + ), + squadsMultisig, + squadsProposal, + payer: this.provider.publicKey, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]); + } + + spotSwapIx({ + dao, + baseMint, + quoteMint = MAINNET_USDC, + swapType, + inputAmount, + minOutputAmount = new BN(0), + trader = this.provider.publicKey, + }: { + dao: PublicKey; + baseMint: PublicKey; + quoteMint?: PublicKey; + swapType: "buy" | "sell"; + inputAmount: BN; + minOutputAmount?: BN; + trader?: PublicKey; + }) { + return this.autocrat.methods + .spotSwap({ + swapType: swapType === "buy" ? { buy: {} } : { sell: {} }, + inputAmount, + minOutputAmount, + }) + .accounts({ + dao, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, trader, true), + userQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + trader, + true, + ), + ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), + user: trader, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, trader, true), + trader, + baseMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(quoteMint, trader, true), + trader, + quoteMint, + ), + ]); + } + + provideLiquidityIx({ + dao, + baseMint, + quoteMint, + quoteAmount, + maxBaseAmount, + minLiquidity = new BN(0), + positionAuthority = this.provider.publicKey, + liquidityProvider = this.provider.publicKey, + }: { + dao: PublicKey; + baseMint: PublicKey; + quoteMint: PublicKey; + quoteAmount: BN; + maxBaseAmount: BN; + minLiquidity?: BN; + positionAuthority?: PublicKey; + liquidityProvider?: PublicKey; + }) { + const ammPosition = PublicKey.findProgramAddressSync( + [ + Buffer.from("amm_position"), + dao.toBuffer(), + positionAuthority.toBuffer(), + ], + this.getProgramId(), + )[0]; + + return this.autocrat.methods + .provideLiquidity({ + quoteAmount, + maxBaseAmount, + minLiquidity, + positionAuthority, + }) + .accounts({ + dao, + liquidityProvider, + liquidityProviderBaseAccount: getAssociatedTokenAddressSync( + baseMint, + liquidityProvider, + true, + ), + liquidityProviderQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + liquidityProvider, + true, + ), + payer: this.provider.publicKey, + systemProgram: SystemProgram.programId, + ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), + ammPosition, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, liquidityProvider, true), + liquidityProvider, + baseMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(quoteMint, liquidityProvider, true), + liquidityProvider, + quoteMint, + ), + ]); + } + + conditionalSwapIx({ + dao, + trader = this.provider.publicKey, + payer = this.provider.publicKey, + baseMint, + quoteMint = MAINNET_USDC, + proposal, + market, + swapType, + inputAmount, + minOutputAmount, + }: { + dao: PublicKey; + trader?: PublicKey; + payer?: PublicKey; + baseMint: PublicKey; + quoteMint?: PublicKey; + proposal: PublicKey; + market: "pass" | "fail"; + swapType: "buy" | "sell"; + inputAmount: BN; + minOutputAmount: BN; + }) { + const { + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + baseVault, + quoteVault, + question, + } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); + + let inputMint: PublicKey, outputMint: PublicKey; + + if (market == "pass" && swapType == "buy") { + inputMint = passQuoteMint; + outputMint = passBaseMint; + } else if (market == "pass" && swapType == "sell") { + inputMint = passBaseMint; + outputMint = passQuoteMint; + } else if (market == "fail" && swapType == "buy") { + inputMint = failQuoteMint; + outputMint = failBaseMint; + } else if (market == "fail" && swapType == "sell") { + inputMint = failBaseMint; + outputMint = failQuoteMint; + } else { + throw new Error( + "Either `market` or `swapType` is incorrectly configured", + ); + } + + return this.autocrat.methods + .conditionalSwap({ + market: market == "pass" ? { pass: {} } : { fail: {} }, + swapType: swapType == "buy" ? { buy: {} } : { sell: {} }, + inputAmount, + minOutputAmount, + }) + .accounts({ + dao, + proposal, + ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), + ammPassBaseVault: getAssociatedTokenAddressSync( + passBaseMint, + dao, + true, + ), + ammPassQuoteVault: getAssociatedTokenAddressSync( + passQuoteMint, + dao, + true, + ), + ammFailBaseVault: getAssociatedTokenAddressSync( + failBaseMint, + dao, + true, + ), + ammFailQuoteVault: getAssociatedTokenAddressSync( + failQuoteMint, + dao, + true, + ), + baseVault, + quoteVault, + userInputAccount: getAssociatedTokenAddressSync( + inputMint, + trader, + true, + ), + userOutputAccount: getAssociatedTokenAddressSync( + outputMint, + trader, + true, + ), + baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + baseMint, + baseVault, + true, + ), + quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + quoteMint, + quoteVault, + true, + ), + passBaseMint, + failBaseMint, + passQuoteMint, + failQuoteMint, + conditionalVaultProgram: this.vaultClient.vaultProgram.programId, + vaultEventAuthority: getEventAuthorityAddr( + this.vaultClient.vaultProgram.programId, + )[0], + question, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(outputMint, trader, true), + trader, + outputMint, + ), + ]); + } + + squadsProposalCreateTx({ + dao, + instructions, + transactionIndex, + payer = this.provider.publicKey, + }: { + dao: PublicKey; + instructions: TransactionInstruction[]; + transactionIndex: bigint; + payer?: PublicKey; + }): { tx: Transaction; squadsProposal: PublicKey } { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + + const transactionMessage = new TransactionMessage({ + payerKey: payer, + recentBlockhash: "", // this doesn't get used + instructions, + }); + + const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage, + }); + + const proposalCreate = multisig.instructions.proposalCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + }); + + const [squadsProposal] = multisig.getProposalPda({ + multisigPda, + transactionIndex: transactionIndex, + }); + + const tx = new Transaction().add(vaultTxCreate, proposalCreate); + + return { tx, squadsProposal }; + } + + async initializeProposal( + dao: PublicKey, + squadsProposal: PublicKey, + ): Promise { + const storedDao = await this.getDao(dao); + + let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + + await this.vaultClient.initializeQuestion( + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + + const { question } = this.getProposalPdas( + proposal, + storedDao.baseMint, + storedDao.quoteMint, + dao, + ); + + // it's important that these happen in a single atomic transaction + await this.vaultClient + .initializeVaultIx(question, storedDao.baseMint, 2) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.initializeVaultIx(question, storedDao.quoteMint, 2), + ), + ) + .rpc(); + + await this.initializeProposalIx( + squadsProposal, + dao, + storedDao.baseMint, + storedDao.quoteMint, + question, + ) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc(); + + return proposal; + } + + initializeProposalIx( + squadsProposal: PublicKey, + dao: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + question: PublicKey, + proposer: PublicKey = this.provider.publicKey, + ) { + let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + const { + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); + + let [futarchyAmm] = PublicKey.findProgramAddressSync( + [Buffer.from("futarchy_amm")], + this.getProgramId(), + ); + + const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; + + return this.autocrat.methods + .initializeProposal() + .accounts({ + question, + proposal, + squadsProposal, + dao, + baseVault, + quoteVault, + proposer, + squadsMultisig, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(passBaseMint, futarchyAmm, true), + futarchyAmm, + passBaseMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(passQuoteMint, futarchyAmm, true), + futarchyAmm, + passQuoteMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(failBaseMint, futarchyAmm, true), + futarchyAmm, + failBaseMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(failQuoteMint, futarchyAmm, true), + futarchyAmm, + failQuoteMint, + ), + ]); + } + + async finalizeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + let storedDao = await this.getDao(storedProposal.dao); + + return this.finalizeProposalIx( + proposal, + storedProposal.squadsProposal, + storedProposal.dao, + storedDao.baseMint, + storedDao.quoteMint, + ).rpc(); + } + + finalizeProposalIxV2({ + squadsProposal, + dao, + baseMint, + quoteMint = MAINNET_USDC, + }: { + squadsProposal: PublicKey; + dao: PublicKey; + baseMint: PublicKey; + quoteMint?: PublicKey; + }) { + const [proposal] = getProposalAddrV2({ squadsProposal }); + + return this.finalizeProposalIx( + proposal, + squadsProposal, + dao, + baseMint, + quoteMint, + ); + } + + /** + * @deprecated use `finalizeProposalIxV2` instead + */ + finalizeProposalIx( + proposal: PublicKey, + squadsProposal: PublicKey, + dao: PublicKey, + daoToken: PublicKey, + usdc: PublicKey, + ) { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + + const { + question, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + baseVault, + } = this.getProposalPdas(proposal, daoToken, usdc, dao); + + const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); + + return this.autocrat.methods + .finalizeProposal() + .accounts({ + proposal, + dao, + squadsProposal, + squadsMultisig: multisigPda, + squadsMultisigProgram: SQUADS_PROGRAM_ID, + quoteVault, + question, + quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + usdc, + quoteVault, + true, + ), + passQuoteMint, + failQuoteMint, + passBaseMint, + failBaseMint, + ammPassQuoteVault: getAssociatedTokenAddressSync( + passQuoteMint, + dao, + true, + ), + ammFailQuoteVault: getAssociatedTokenAddressSync( + failQuoteMint, + dao, + true, + ), + ammQuoteVault: getAssociatedTokenAddressSync(usdc, dao, true), + ammPassBaseVault: getAssociatedTokenAddressSync( + passBaseMint, + dao, + true, + ), + ammFailBaseVault: getAssociatedTokenAddressSync( + failBaseMint, + dao, + true, + ), + ammBaseVault: getAssociatedTokenAddressSync(daoToken, dao, true), + baseVault, + baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + daoToken, + baseVault, + true, + ), + vaultProgram: this.vaultClient.vaultProgram.programId, + vaultEventAuthority, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]); + } + + updateDaoIx({ dao, params }: { dao: PublicKey; params: UpdateDaoParams }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + + return this.autocrat.methods.updateDao(params).accounts({ + dao, + squadsMultisigVault, + }); + } + + stakeToProposalIx({ + proposal, + dao, + baseMint, + amount, + staker = this.provider.publicKey, + payer = this.provider.publicKey, + }: { + proposal: PublicKey; + dao: PublicKey; + baseMint: PublicKey; + amount: BN; + staker?: PublicKey; + payer?: PublicKey; + }) { + const stakeAccount = getStakeAddr( + FUTARCHY_V0_6_PROGRAM_ID, + proposal, + staker, + )[0]; + + return this.autocrat.methods + .stakeToProposal({ amount }) + .accounts({ + proposal, + dao, + stakerBaseAccount: getAssociatedTokenAddressSync( + baseMint, + staker, + true, + ), + proposalBaseAccount: getAssociatedTokenAddressSync( + baseMint, + proposal, + true, + ), + stakeAccount, + staker, + payer, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(baseMint, staker, true), + staker, + baseMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(baseMint, proposal, true), + proposal, + baseMint, + ), + ]); + } + + unstakeFromProposalIx({ + proposal, + dao, + baseMint, + amount, + staker = this.provider.publicKey, + }: { + proposal: PublicKey; + dao: PublicKey; + baseMint: PublicKey; + amount: BN; + staker?: PublicKey; + }) { + const stakeAccount = getStakeAddr( + FUTARCHY_V0_6_PROGRAM_ID, + proposal, + staker, + )[0]; + + return this.autocrat.methods.unstakeFromProposal({ amount }).accounts({ + proposal, + dao, + stakerBaseAccount: getAssociatedTokenAddressSync(baseMint, staker, true), + proposalBaseAccount: getAssociatedTokenAddressSync( + baseMint, + proposal, + true, + ), + stakeAccount, + staker, + baseMint, + tokenProgram: TOKEN_PROGRAM_ID, + }); + } + + collectFeesIx({ + dao, + baseMint, + quoteMint, + }: { + dao: PublicKey; + baseMint: PublicKey; + quoteMint: PublicKey; + }) { + // Hardcode destination to MetaDAO multisig vault + const baseTokenAccount = getAssociatedTokenAddressSync( + baseMint, + METADAO_MULTISIG_VAULT, + true, + ); + const quoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + METADAO_MULTISIG_VAULT, + true, + ); + + return this.autocrat.methods.collectFees().accounts({ + dao, + admin: this.provider.publicKey, + ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), + baseTokenAccount, + quoteTokenAccount, + }); + } + + sponsorProposalIx({ + proposal, + dao, + teamAddress = this.provider.publicKey, + }: { + proposal: PublicKey; + dao: PublicKey; + teamAddress?: PublicKey; + }) { + return this.autocrat.methods.sponsorProposal().accounts({ + proposal, + dao, + teamAddress, + }); + } + + collectMeteoraDammFeesIx({ + dao, + baseMint, + quoteMint = MAINNET_USDC, + transactionIndex, + meteoraConfig = LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + admin = this.provider.publicKey, + }: { + dao: PublicKey; + baseMint: PublicKey; + quoteMint?: PublicKey; + transactionIndex: bigint; + meteoraConfig?: PublicKey; + admin?: PublicKey; + }) { + // Squads accounts + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + const squadsMultisigVaultTransaction = multisig.getTransactionPda({ + multisigPda, + index: transactionIndex, + })[0]; + const squadsMultisigProposal = multisig.getProposalPda({ + multisigPda, + transactionIndex, + })[0]; + + // Token accounts for receiving fees + const baseTokenAccount = getAssociatedTokenAddressSync( + baseMint, + METADAO_MULTISIG_VAULT, + true, + ); + const quoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + METADAO_MULTISIG_VAULT, + true, + ); + + // Helper function to sort mints for Meteora pool PDA + const sortMints = ( + mint1: PublicKey, + mint2: PublicKey, + ): [Buffer, Buffer] => { + const buf1 = mint1.toBuffer(); + const buf2 = mint2.toBuffer(); + if (Buffer.compare(buf1, buf2) > 0) { + return [buf1, buf2]; + } + return [buf2, buf1]; + }; + + const [sortedMint1, sortedMint2] = sortMints(baseMint, quoteMint); + + // Meteora DAMM accounts + const [pool] = PublicKey.findProgramAddressSync( + [Buffer.from("pool"), meteoraConfig.toBuffer(), sortedMint1, sortedMint2], + DAMM_V2_PROGRAM_ID, + ); + + const [positionNftMint] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_mint"), baseMint.toBuffer()], + LAUNCHPAD_V0_7_PROGRAM_ID, + ); + + const [positionNftAccount] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [position] = PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenAVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenBVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); + + return this.autocrat.methods.collectMeteoraDammFees().accounts({ + dao, + admin, + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsMultisigVaultTransaction, + squadsMultisigProposal, + squadsMultisigPermissionlessAccount: PERMISSIONLESS_ACCOUNT.publicKey, + meteoraClaimPositionFeesAccounts: { + dammV2Program: DAMM_V2_PROGRAM_ID, + dammV2EventAuthority, + poolAuthority: DAMM_V2_POOL_AUTHORITY, + pool, + position, + tokenAAccount: baseTokenAccount, + tokenBAccount: quoteTokenAccount, + tokenAVault, + tokenBVault, + tokenAMint: baseMint, + tokenBMint: quoteMint, + positionNftAccount, + owner: squadsMultisigVault, + tokenAProgram: TOKEN_PROGRAM_ID, + tokenBProgram: TOKEN_PROGRAM_ID, + }, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + squadsProgram: SQUADS_PROGRAM_ID, + }); + } + + initiateVaultSpendOptimisticProposalIx({ + dao, + quoteMint = MAINNET_USDC, + amount, + recipient, + transactionIndex, + proposer = this.provider.publicKey, + payer = this.provider.publicKey, + }: { + dao: PublicKey; + quoteMint?: PublicKey; + amount: BN; + recipient: PublicKey; + transactionIndex: bigint; + proposer?: PublicKey; + payer?: PublicKey; + }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + const squadsSpendingLimit = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + const squadsProposal = multisig.getProposalPda({ + multisigPda, + transactionIndex, + })[0]; + const squadsVaultTransaction = multisig.getTransactionPda({ + multisigPda, + index: transactionIndex, + })[0]; + + const daoQuoteVaultAccount = getAssociatedTokenAddressSync( + quoteMint, + squadsMultisigVault, + true, + ); + const recipientQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + recipient, + true, + ); + + // Build the SPL token transfer instruction for the vault transaction + const transferIx = createTransferInstruction( + daoQuoteVaultAccount, + recipientQuoteAccount, + squadsMultisigVault, + BigInt(amount.toString()), + ); + + // Use the vault as the payerKey so it deduplicates with the transfer authority, + // producing a clean message with exactly 1 signer (the vault). + const transactionMessage = new TransactionMessage({ + payerKey: squadsMultisigVault, + recentBlockhash: "", + instructions: [transferIx], + }); + + const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + vaultIndex: 0, + ephemeralSigners: 0, + transactionMessage, + }); + + const proposalCreate = multisig.instructions.proposalCreate({ + multisigPda, + transactionIndex, + creator: PERMISSIONLESS_ACCOUNT.publicKey, + rentPayer: payer, + }); + + return this.autocrat.methods + .initiateVaultSpendOptimisticProposal({ amount }) + .accounts({ + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsSpendingLimit, + squadsProposal, + squadsVaultTransaction, + dao, + daoQuoteVaultAccount, + proposer, + recipient, + recipientQuoteAccount, + squadsProgram: SQUADS_PROGRAM_ID, + tokenProgram: TOKEN_PROGRAM_ID, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + recipientQuoteAccount, + recipient, + quoteMint, + ), + vaultTxCreate, + proposalCreate, + ]); + } + + finalizeOptimisticProposalIx({ + dao, + squadsProposal, + }: { + dao: PublicKey; + squadsProposal: PublicKey; + }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + + return this.autocrat.methods.finalizeOptimisticProposal().accounts({ + squadsMultisig: multisigPda, + squadsProposal, + dao, + squadsProgram: SQUADS_PROGRAM_ID, + }); + } +} diff --git a/sdk2/src/futarchy/v0.6/index.ts b/sdk2/src/futarchy/v0.6/index.ts new file mode 100644 index 000000000..433ec210e --- /dev/null +++ b/sdk2/src/futarchy/v0.6/index.ts @@ -0,0 +1,3 @@ +export * from "./FutarchyClient.js"; +export * from "./types/index.js"; +export * from "./pda.js"; diff --git a/sdk2/src/futarchy/v0.6/pda.ts b/sdk2/src/futarchy/v0.6/pda.ts new file mode 100644 index 000000000..000e43861 --- /dev/null +++ b/sdk2/src/futarchy/v0.6/pda.ts @@ -0,0 +1,54 @@ +import { BN, utils } from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; + +import { FUTARCHY_V0_6_PROGRAM_ID } from "../../constants.js"; + +export const getDaoAddr = ({ + nonce, + daoCreator, + programId = FUTARCHY_V0_6_PROGRAM_ID, +}: { + nonce: BN; + daoCreator: PublicKey; + programId?: PublicKey; +}): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("dao"), + daoCreator.toBuffer(), + nonce.toArrayLike(Buffer, "le", 8), + ], + programId, + ); +}; + +export const getProposalAddr = ( + programId: PublicKey = FUTARCHY_V0_6_PROGRAM_ID, + squadsProposal: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("proposal"), squadsProposal.toBuffer()], + programId, + ); +}; + +export const getProposalAddrV2 = ({ + programId = FUTARCHY_V0_6_PROGRAM_ID, + squadsProposal, +}: { + programId?: PublicKey; + squadsProposal: PublicKey; +}): [PublicKey, number] => { + return getProposalAddr(programId, squadsProposal); +}; + +export const getStakeAddr = ( + programId: PublicKey = FUTARCHY_V0_6_PROGRAM_ID, + draftProposal: PublicKey, + staker: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("stake"), draftProposal.toBuffer(), staker.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/futarchy/v0.6/types/futarchy.ts b/sdk2/src/futarchy/v0.6/types/futarchy.ts new file mode 100644 index 000000000..491a7d42d --- /dev/null +++ b/sdk2/src/futarchy/v0.6/types/futarchy.ts @@ -0,0 +1,7471 @@ +export type Futarchy = { + version: "0.6.1"; + name: "futarchy"; + instructions: [ + { + name: "initializeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoCreator"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeDaoParams"; + }; + }, + ]; + }, + { + name: "initializeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "stakeToProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "stakerBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposalBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "stakeAccount"; + isMut: true; + isSigner: false; + }, + { + name: "staker"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "StakeToProposalParams"; + }; + }, + ]; + }, + { + name: "unstakeFromProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "stakerBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposalBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "stakeAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "staker"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "UnstakeFromProposalParams"; + }; + }, + ]; + }, + { + name: "launchProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: false; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: false; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "finalizeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "daoParams"; + type: { + defined: "UpdateDaoParams"; + }; + }, + ]; + }, + { + name: "resizeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "spotSwap"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "user"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "SpotSwapParams"; + }; + }, + ]; + }, + { + name: "conditionalSwap"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "proposal"; + isMut: false; + isSigner: false; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "trader"; + isMut: false; + isSigner: true; + }, + { + name: "userInputAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userOutputAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalVaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ConditionalSwapParams"; + }; + }, + ]; + }, + { + name: "provideLiquidity"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProvider"; + isMut: false; + isSigner: true; + }, + { + name: "liquidityProviderBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProviderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPosition"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ProvideLiquidityParams"; + }; + }, + ]; + }, + { + name: "withdrawLiquidity"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "positionAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "liquidityProviderBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProviderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPosition"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "WithdrawLiquidityParams"; + }; + }, + ]; + }, + { + name: "collectFees"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "baseTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "executeSpendingLimitChange"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultTransaction"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "sponsorProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "teamAddress"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "collectMeteoraDammFees"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigPermissionlessAccount"; + isMut: false; + isSigner: true; + }, + { + name: "meteoraClaimPositionFeesAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "pool"; + isMut: false; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "tokenAAccount"; + isMut: true; + isSigner: false; + docs: ["Token account of base tokens recipient"]; + }, + { + name: "tokenBAccount"; + isMut: true; + isSigner: false; + docs: ["Token account of quote tokens recipient"]; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenAMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenBMint"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: false; + isSigner: false; + }, + { + name: "owner"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenBProgram"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "initiateVaultSpendOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsSpendingLimit"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, + { + name: "squadsVaultTransaction"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoQuoteVaultAccount"; + isMut: false; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "recipientQuoteAccount"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitiateVaultSpendOptimisticProposalParams"; + }; + }, + ]; + }, + { + name: "finalizeOptimisticProposal"; + accounts: [ + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "adminApproveMultisigProposal"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVaultTransaction"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "adminExecuteMultisigProposal"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVaultTransaction"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "adminCancelProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "adminRemoveProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "ammPosition"; + type: { + kind: "struct"; + fields: [ + { + name: "dao"; + type: "publicKey"; + }, + { + name: "positionAuthority"; + type: "publicKey"; + }, + { + name: "liquidity"; + type: "u128"; + }, + ]; + }; + }, + { + name: "dao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + { + name: "optimisticProposal"; + type: { + option: { + defined: "OptimisticProposal"; + }; + }; + }, + { + name: "isOptimisticGovernanceEnabled"; + type: "bool"; + }, + ]; + }; + }, + { + name: "oldDao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ]; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "proposal"; + type: { + kind: "struct"; + fields: [ + { + name: "number"; + type: "u32"; + }, + { + name: "proposer"; + type: "publicKey"; + }, + { + name: "timestampEnqueued"; + type: "i64"; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + }, + { + name: "baseVault"; + type: "publicKey"; + }, + { + name: "quoteVault"; + type: "publicKey"; + }, + { + name: "dao"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "question"; + type: "publicKey"; + }, + { + name: "durationInSeconds"; + type: "u32"; + }, + { + name: "squadsProposal"; + type: "publicKey"; + }, + { + name: "passBaseMint"; + type: "publicKey"; + }, + { + name: "passQuoteMint"; + type: "publicKey"; + }, + { + name: "failBaseMint"; + type: "publicKey"; + }, + { + name: "failQuoteMint"; + type: "publicKey"; + }, + { + name: "isTeamSponsored"; + type: "bool"; + }, + ]; + }; + }, + { + name: "stakeAccount"; + type: { + kind: "struct"; + fields: [ + { + name: "proposal"; + type: "publicKey"; + }, + { + name: "staker"; + type: "publicKey"; + }, + { + name: "amount"; + type: "u64"; + }, + { + name: "bump"; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "daoSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "ConditionalSwapParams"; + type: { + kind: "struct"; + fields: [ + { + name: "market"; + type: { + defined: "Market"; + }; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "minOutputAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + type: "u64"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "nonce"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + type: "i16"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "InitiateVaultSpendOptimisticProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "ProvideLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "quoteAmount"; + docs: ["How much quote token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "maxBaseAmount"; + docs: ["The maximum base token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "minLiquidity"; + docs: ["The minimum liquidity you will be assigned"]; + type: "u128"; + }, + { + name: "positionAuthority"; + docs: [ + "The account that will own the LP position, usually the same as the", + "liquidity provider", + ]; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "SpotSwapParams"; + type: { + kind: "struct"; + fields: [ + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "minOutputAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "StakeToProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UnstakeFromProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "secondsPerProposal"; + type: { + option: "u32"; + }; + }, + { + name: "twapInitialObservation"; + type: { + option: "u128"; + }; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: { + option: "u128"; + }; + }, + { + name: "twapStartDelaySeconds"; + type: { + option: "u32"; + }; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "minBaseFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "baseToStake"; + type: { + option: "u64"; + }; + }, + { + name: "teamSponsoredPassThresholdBps"; + type: { + option: "i16"; + }; + }, + { + name: "teamAddress"; + type: { + option: "publicKey"; + }; + }, + { + name: "isOptimisticGovernanceEnabled"; + type: { + option: "bool"; + }; + }, + ]; + }; + }, + { + name: "WithdrawLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidityToWithdraw"; + docs: ["How much liquidity to withdraw"]; + type: "u128"; + }, + { + name: "minBaseAmount"; + docs: ["Minimum base tokens to receive"]; + type: "u64"; + }, + { + name: "minQuoteAmount"; + docs: ["Minimum quote tokens to receive"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "OptimisticProposal"; + type: { + kind: "struct"; + fields: [ + { + name: "squadsProposal"; + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ]; + type: "publicKey"; + }, + { + name: "enqueuedTimestamp"; + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ]; + type: "i64"; + }, + ]; + }; + }, + { + name: "InitialSpendingLimit"; + type: { + kind: "struct"; + fields: [ + { + name: "amountPerMonth"; + type: "u64"; + }, + { + name: "members"; + type: { + vec: "publicKey"; + }; + }, + ]; + }; + }, + { + name: "FutarchyAmm"; + type: { + kind: "struct"; + fields: [ + { + name: "state"; + type: { + defined: "PoolState"; + }; + }, + { + name: "totalLiquidity"; + type: "u128"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "ammBaseVault"; + type: "publicKey"; + }, + { + name: "ammQuoteVault"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "TwapOracle"; + type: { + kind: "struct"; + fields: [ + { + name: "aggregator"; + docs: [ + "Running sum of seconds_since_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million seconds worth of observations, which turns out to", + "be ~213 days.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store ~57 years worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ]; + type: "u128"; + }, + { + name: "lastUpdatedTimestamp"; + type: "i64"; + }, + { + name: "createdAtTimestamp"; + type: "i64"; + }, + { + name: "lastPrice"; + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ]; + type: "u128"; + }, + { + name: "lastObservation"; + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ]; + type: "u128"; + }, + { + name: "maxObservationChangePerUpdate"; + docs: ["The most that an observation can change per update."]; + type: "u128"; + }, + { + name: "initialObservation"; + docs: ["What the initial `latest_observation` is set to."]; + type: "u128"; + }, + { + name: "startDelaySeconds"; + docs: [ + "Number of seconds after amm.created_at_slot to start recording TWAP", + ]; + type: "u32"; + }, + ]; + }; + }, + { + name: "Pool"; + type: { + kind: "struct"; + fields: [ + { + name: "oracle"; + type: { + defined: "TwapOracle"; + }; + }, + { + name: "quoteReserves"; + type: "u64"; + }, + { + name: "baseReserves"; + type: "u64"; + }, + { + name: "quoteProtocolFeeBalance"; + type: "u64"; + }, + { + name: "baseProtocolFeeBalance"; + type: "u64"; + }, + ]; + }; + }, + { + name: "PoolState"; + type: { + kind: "enum"; + variants: [ + { + name: "Spot"; + fields: [ + { + name: "spot"; + type: { + defined: "Pool"; + }; + }, + ]; + }, + { + name: "Futarchy"; + fields: [ + { + name: "spot"; + type: { + defined: "Pool"; + }; + }, + { + name: "pass"; + type: { + defined: "Pool"; + }; + }, + { + name: "fail"; + type: { + defined: "Pool"; + }; + }, + ]; + }, + ]; + }; + }, + { + name: "Market"; + type: { + kind: "enum"; + variants: [ + { + name: "Spot"; + }, + { + name: "Pass"; + }, + { + name: "Fail"; + }, + ]; + }; + }, + { + name: "SwapType"; + type: { + kind: "enum"; + variants: [ + { + name: "Buy"; + }, + { + name: "Sell"; + }, + ]; + }; + }, + { + name: "Token"; + type: { + kind: "enum"; + variants: [ + { + name: "Base"; + }, + { + name: "Quote"; + }, + ]; + }; + }, + { + name: "ProposalState"; + type: { + kind: "enum"; + variants: [ + { + name: "Draft"; + fields: [ + { + name: "amountStaked"; + type: "u64"; + }, + ]; + }, + { + name: "Pending"; + }, + { + name: "Passed"; + }, + { + name: "Failed"; + }, + { + name: "Removed"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "CollectFeesEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "baseTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "quoteTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "ammBaseVault"; + type: "publicKey"; + index: false; + }, + { + name: "ammQuoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteFeesCollected"; + type: "u64"; + index: false; + }, + { + name: "baseFeesCollected"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "InitializeDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "secondsPerProposal"; + type: "u32"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "twapStartDelaySeconds"; + type: "u32"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "baseToStake"; + type: "u64"; + index: false; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + { + name: "teamSponsoredPassThresholdBps"; + type: "i16"; + index: false; + }, + { + name: "teamAddress"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "UpdateDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "secondsPerProposal"; + type: "u32"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "twapStartDelaySeconds"; + type: "u32"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "baseToStake"; + type: "u64"; + index: false; + }, + { + name: "teamSponsoredPassThresholdBps"; + type: "i16"; + index: false; + }, + { + name: "teamAddress"; + type: "publicKey"; + index: false; + }, + { + name: "isOptimisticGovernanceEnabled"; + type: "bool"; + index: false; + }, + ]; + }, + { + name: "InitializeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "quoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseVault"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "number"; + type: "u32"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "durationInSeconds"; + type: "u32"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "StakeToProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "staker"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "UnstakeFromProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "staker"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "timestampEnqueued"; + type: "i64"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "FinalizeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "failMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "threshold"; + type: "u128"; + index: false; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + { + name: "isTeamSponsored"; + type: "bool"; + index: false; + }, + ]; + }, + { + name: "SpotSwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "minOutputAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "ConditionalSwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "trader"; + type: "publicKey"; + index: false; + }, + { + name: "market"; + type: { + defined: "Market"; + }; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "minOutputAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "ProvideLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityProvider"; + type: "publicKey"; + index: false; + }, + { + name: "positionAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "liquidityMinted"; + type: "u128"; + index: false; + }, + { + name: "minLiquidity"; + type: "u128"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "WithdrawLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityProvider"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityWithdrawn"; + type: "u128"; + index: false; + }, + { + name: "minBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "minQuoteAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "SponsorProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "teamAddress"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "RemoveProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "admin"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "AdminCancelProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "admin"; + type: "publicKey"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "CollectMeteoraDammFeesEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "pool"; + type: "publicKey"; + index: false; + }, + { + name: "baseTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "quoteTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteFeesCollected"; + type: "u64"; + index: false; + }, + { + name: "baseFeesCollected"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "AdminFixPositionAuthorityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "admin"; + type: "publicKey"; + index: false; + }, + { + name: "ammPosition"; + type: "publicKey"; + index: false; + }, + { + name: "oldAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "newAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "InitiateVaultSpendOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "daoQuoteVaultAccount"; + type: "publicKey"; + index: false; + }, + { + name: "recipientQuoteAccount"; + type: "publicKey"; + index: false; + }, + { + name: "enqueuedTimestamp"; + type: "i64"; + index: false; + }, + ]; + }, + { + name: "FinalizeOptimisticProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AmmTooOld"; + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; + }, + { + code: 6001; + name: "InvalidInitialObservation"; + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; + }, + { + code: 6002; + name: "InvalidMaxObservationChange"; + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; + }, + { + code: 6003; + name: "InvalidStartDelaySlots"; + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; + }, + { + code: 6004; + name: "InvalidSettlementAuthority"; + msg: "One of the vaults has an invalid `settlement_authority`"; + }, + { + code: 6005; + name: "ProposalTooYoung"; + msg: "Proposal is too young to be executed or rejected"; + }, + { + code: 6006; + name: "MarketsTooYoung"; + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; + }, + { + code: 6007; + name: "ProposalAlreadyFinalized"; + msg: "This proposal has already been finalized"; + }, + { + code: 6008; + name: "InvalidVaultNonce"; + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; + }, + { + code: 6009; + name: "ProposalNotPassed"; + msg: "This proposal can't be executed because it isn't in the passed state"; + }, + { + code: 6010; + name: "InsufficientLiquidity"; + msg: "More liquidity needs to be in the AMM to launch this proposal"; + }, + { + code: 6011; + name: "ProposalDurationTooShort"; + msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay"; + }, + { + code: 6012; + name: "PassThresholdTooHigh"; + msg: "Pass threshold must be less than 10%"; + }, + { + code: 6013; + name: "QuestionMustBeBinary"; + msg: "Question must have exactly 2 outcomes for binary futarchy"; + }, + { + code: 6014; + name: "InvalidSquadsProposalStatus"; + msg: "Squads proposal must be in Active status"; + }, + { + code: 6015; + name: "CastingOverflow"; + msg: "Casting overflow. If you're seeing this, please report this"; + }, + { + code: 6016; + name: "InsufficientBalance"; + msg: "Insufficient balance"; + }, + { + code: 6017; + name: "ZeroLiquidityRemove"; + msg: "Cannot remove zero liquidity"; + }, + { + code: 6018; + name: "SwapSlippageExceeded"; + msg: "Swap slippage exceeded"; + }, + { + code: 6019; + name: "AssertFailed"; + msg: "Assert failed"; + }, + { + code: 6020; + name: "InvalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6021; + name: "ProposalNotInDraftState"; + msg: "Proposal is not in draft state"; + }, + { + code: 6022; + name: "InsufficientTokenBalance"; + msg: "Insufficient token balance"; + }, + { + code: 6023; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6024; + name: "InsufficientStakeToLaunch"; + msg: "Insufficient stake to launch proposal"; + }, + { + code: 6025; + name: "StakerNotFound"; + msg: "Staker not found in proposal"; + }, + { + code: 6026; + name: "PoolNotInSpotState"; + msg: "Pool must be in spot state"; + }, + { + code: 6027; + name: "InvalidDaoCreateLiquidity"; + msg: "If you're providing liquidity, you must provide both base and quote token accounts"; + }, + { + code: 6028; + name: "InvalidStakeAccount"; + msg: "Invalid stake account"; + }, + { + code: 6029; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6030; + name: "ProposalNotActive"; + msg: "Proposal needs to be active to perform a conditional swap"; + }, + { + code: 6031; + name: "InvalidTransaction"; + msg: "This Squads transaction should only contain calls to update spending limits"; + }, + { + code: 6032; + name: "ProposalAlreadySponsored"; + msg: "Proposal has already been sponsored"; + }, + { + code: 6033; + name: "InvalidTeamSponsoredPassThreshold"; + msg: "Team sponsored pass threshold must be between -10% and 10%"; + }, + { + code: 6034; + name: "InvalidTargetK"; + msg: "Target K must be greater than the current K"; + }, + { + code: 6035; + name: "InvalidTransactionMessage"; + msg: "Failed to compile transaction message for Squads vault transaction"; + }, + { + code: 6036; + name: "InvalidMint"; + msg: "Base mint and quote mint must be different"; + }, + { + code: 6037; + name: "InvalidRecipient"; + msg: "Invalid recipient"; + }, + { + code: 6038; + name: "OptimisticGovernanceDisabled"; + msg: "Optimistic governance is disabled"; + }, + { + code: 6039; + name: "ActiveOptimisticProposalAlreadyEnqueued"; + msg: "An active optimistic proposal is already enqueued"; + }, + { + code: 6040; + name: "NoActiveOptimisticProposal"; + msg: "No active optimistic proposal"; + }, + { + code: 6041; + name: "OptimisticProposalAlreadyPassed"; + msg: "Optimistic proposal has already passed"; + }, + { + code: 6042; + name: "CannotSponsorOptimisticProposalChallenge"; + msg: "Team cannot sponsor a challenge to an optimistic proposal"; + }, + { + code: 6043; + name: "InvalidSpendingLimitMint"; + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; + }, + ]; +}; + +export const IDL: Futarchy = { + version: "0.6.1", + name: "futarchy", + instructions: [ + { + name: "initializeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoCreator", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeDaoParams", + }, + }, + ], + }, + { + name: "initializeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "stakeToProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "stakerBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposalBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "stakeAccount", + isMut: true, + isSigner: false, + }, + { + name: "staker", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "StakeToProposalParams", + }, + }, + ], + }, + { + name: "unstakeFromProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "stakerBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposalBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "stakeAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "staker", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "UnstakeFromProposalParams", + }, + }, + ], + }, + { + name: "launchProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: false, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: false, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: false, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "finalizeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "daoParams", + type: { + defined: "UpdateDaoParams", + }, + }, + ], + }, + { + name: "resizeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "spotSwap", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "user", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "SpotSwapParams", + }, + }, + ], + }, + { + name: "conditionalSwap", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "proposal", + isMut: false, + isSigner: false, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "trader", + isMut: false, + isSigner: true, + }, + { + name: "userInputAccount", + isMut: true, + isSigner: false, + }, + { + name: "userOutputAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalVaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ConditionalSwapParams", + }, + }, + ], + }, + { + name: "provideLiquidity", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProvider", + isMut: false, + isSigner: true, + }, + { + name: "liquidityProviderBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProviderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPosition", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ProvideLiquidityParams", + }, + }, + ], + }, + { + name: "withdrawLiquidity", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "positionAuthority", + isMut: false, + isSigner: true, + }, + { + name: "liquidityProviderBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProviderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPosition", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "WithdrawLiquidityParams", + }, + }, + ], + }, + { + name: "collectFees", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "baseTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "executeSpendingLimitChange", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultTransaction", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "sponsorProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "teamAddress", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "collectMeteoraDammFees", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigPermissionlessAccount", + isMut: false, + isSigner: true, + }, + { + name: "meteoraClaimPositionFeesAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "pool", + isMut: false, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "tokenAAccount", + isMut: true, + isSigner: false, + docs: ["Token account of base tokens recipient"], + }, + { + name: "tokenBAccount", + isMut: true, + isSigner: false, + docs: ["Token account of quote tokens recipient"], + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenAMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenBMint", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: false, + isSigner: false, + }, + { + name: "owner", + isMut: false, + isSigner: false, + }, + { + name: "tokenAProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenBProgram", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "initiateVaultSpendOptimisticProposal", + accounts: [ + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsSpendingLimit", + isMut: false, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, + { + name: "squadsVaultTransaction", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoQuoteVaultAccount", + isMut: false, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "recipientQuoteAccount", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitiateVaultSpendOptimisticProposalParams", + }, + }, + ], + }, + { + name: "finalizeOptimisticProposal", + accounts: [ + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "adminApproveMultisigProposal", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "adminExecuteMultisigProposal", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVaultTransaction", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "adminCancelProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "adminRemoveProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "ammPosition", + type: { + kind: "struct", + fields: [ + { + name: "dao", + type: "publicKey", + }, + { + name: "positionAuthority", + type: "publicKey", + }, + { + name: "liquidity", + type: "u128", + }, + ], + }, + }, + { + name: "dao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + { + name: "optimisticProposal", + type: { + option: { + defined: "OptimisticProposal", + }, + }, + }, + { + name: "isOptimisticGovernanceEnabled", + type: "bool", + }, + ], + }, + }, + { + name: "oldDao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + docs: [ + "The percentage, in basis points, the pass price needs to be above the", + "fail price in order for the proposal to pass for team-sponsored proposals.", + "", + "Can be negative to allow for team-sponsored proposals to pass by default.", + ], + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, + { + name: "proposal", + type: { + kind: "struct", + fields: [ + { + name: "number", + type: "u32", + }, + { + name: "proposer", + type: "publicKey", + }, + { + name: "timestampEnqueued", + type: "i64", + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + }, + { + name: "baseVault", + type: "publicKey", + }, + { + name: "quoteVault", + type: "publicKey", + }, + { + name: "dao", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "question", + type: "publicKey", + }, + { + name: "durationInSeconds", + type: "u32", + }, + { + name: "squadsProposal", + type: "publicKey", + }, + { + name: "passBaseMint", + type: "publicKey", + }, + { + name: "passQuoteMint", + type: "publicKey", + }, + { + name: "failBaseMint", + type: "publicKey", + }, + { + name: "failQuoteMint", + type: "publicKey", + }, + { + name: "isTeamSponsored", + type: "bool", + }, + ], + }, + }, + { + name: "stakeAccount", + type: { + kind: "struct", + fields: [ + { + name: "proposal", + type: "publicKey", + }, + { + name: "staker", + type: "publicKey", + }, + { + name: "amount", + type: "u64", + }, + { + name: "bump", + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "daoSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "ConditionalSwapParams", + type: { + kind: "struct", + fields: [ + { + name: "market", + type: { + defined: "Market", + }, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "inputAmount", + type: "u64", + }, + { + name: "minOutputAmount", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + type: "u64", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "nonce", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + { + name: "teamSponsoredPassThresholdBps", + type: "i16", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, + { + name: "InitiateVaultSpendOptimisticProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "ProvideLiquidityParams", + type: { + kind: "struct", + fields: [ + { + name: "quoteAmount", + docs: ["How much quote token you will deposit to the pool"], + type: "u64", + }, + { + name: "maxBaseAmount", + docs: ["The maximum base token you will deposit to the pool"], + type: "u64", + }, + { + name: "minLiquidity", + docs: ["The minimum liquidity you will be assigned"], + type: "u128", + }, + { + name: "positionAuthority", + docs: [ + "The account that will own the LP position, usually the same as the", + "liquidity provider", + ], + type: "publicKey", + }, + ], + }, + }, + { + name: "SpotSwapParams", + type: { + kind: "struct", + fields: [ + { + name: "inputAmount", + type: "u64", + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "minOutputAmount", + type: "u64", + }, + ], + }, + }, + { + name: "StakeToProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "UnstakeFromProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "secondsPerProposal", + type: { + option: "u32", + }, + }, + { + name: "twapInitialObservation", + type: { + option: "u128", + }, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: { + option: "u128", + }, + }, + { + name: "twapStartDelaySeconds", + type: { + option: "u32", + }, + }, + { + name: "minQuoteFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "minBaseFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "baseToStake", + type: { + option: "u64", + }, + }, + { + name: "teamSponsoredPassThresholdBps", + type: { + option: "i16", + }, + }, + { + name: "teamAddress", + type: { + option: "publicKey", + }, + }, + { + name: "isOptimisticGovernanceEnabled", + type: { + option: "bool", + }, + }, + ], + }, + }, + { + name: "WithdrawLiquidityParams", + type: { + kind: "struct", + fields: [ + { + name: "liquidityToWithdraw", + docs: ["How much liquidity to withdraw"], + type: "u128", + }, + { + name: "minBaseAmount", + docs: ["Minimum base tokens to receive"], + type: "u64", + }, + { + name: "minQuoteAmount", + docs: ["Minimum quote tokens to receive"], + type: "u64", + }, + ], + }, + }, + { + name: "OptimisticProposal", + type: { + kind: "struct", + fields: [ + { + name: "squadsProposal", + docs: [ + "The squads proposal currently enqueued for execution if not challenged by a new proposal.", + ], + type: "publicKey", + }, + { + name: "enqueuedTimestamp", + docs: [ + "The timestamp when the active optimistic squads proposal was enqueued.", + ], + type: "i64", + }, + ], + }, + }, + { + name: "InitialSpendingLimit", + type: { + kind: "struct", + fields: [ + { + name: "amountPerMonth", + type: "u64", + }, + { + name: "members", + type: { + vec: "publicKey", + }, + }, + ], + }, + }, + { + name: "FutarchyAmm", + type: { + kind: "struct", + fields: [ + { + name: "state", + type: { + defined: "PoolState", + }, + }, + { + name: "totalLiquidity", + type: "u128", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "ammBaseVault", + type: "publicKey", + }, + { + name: "ammQuoteVault", + type: "publicKey", + }, + ], + }, + }, + { + name: "TwapOracle", + type: { + kind: "struct", + fields: [ + { + name: "aggregator", + docs: [ + "Running sum of seconds_since_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million seconds worth of observations, which turns out to", + "be ~213 days.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store ~57 years worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ], + type: "u128", + }, + { + name: "lastUpdatedTimestamp", + type: "i64", + }, + { + name: "createdAtTimestamp", + type: "i64", + }, + { + name: "lastPrice", + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ], + type: "u128", + }, + { + name: "lastObservation", + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ], + type: "u128", + }, + { + name: "maxObservationChangePerUpdate", + docs: ["The most that an observation can change per update."], + type: "u128", + }, + { + name: "initialObservation", + docs: ["What the initial `latest_observation` is set to."], + type: "u128", + }, + { + name: "startDelaySeconds", + docs: [ + "Number of seconds after amm.created_at_slot to start recording TWAP", + ], + type: "u32", + }, + ], + }, + }, + { + name: "Pool", + type: { + kind: "struct", + fields: [ + { + name: "oracle", + type: { + defined: "TwapOracle", + }, + }, + { + name: "quoteReserves", + type: "u64", + }, + { + name: "baseReserves", + type: "u64", + }, + { + name: "quoteProtocolFeeBalance", + type: "u64", + }, + { + name: "baseProtocolFeeBalance", + type: "u64", + }, + ], + }, + }, + { + name: "PoolState", + type: { + kind: "enum", + variants: [ + { + name: "Spot", + fields: [ + { + name: "spot", + type: { + defined: "Pool", + }, + }, + ], + }, + { + name: "Futarchy", + fields: [ + { + name: "spot", + type: { + defined: "Pool", + }, + }, + { + name: "pass", + type: { + defined: "Pool", + }, + }, + { + name: "fail", + type: { + defined: "Pool", + }, + }, + ], + }, + ], + }, + }, + { + name: "Market", + type: { + kind: "enum", + variants: [ + { + name: "Spot", + }, + { + name: "Pass", + }, + { + name: "Fail", + }, + ], + }, + }, + { + name: "SwapType", + type: { + kind: "enum", + variants: [ + { + name: "Buy", + }, + { + name: "Sell", + }, + ], + }, + }, + { + name: "Token", + type: { + kind: "enum", + variants: [ + { + name: "Base", + }, + { + name: "Quote", + }, + ], + }, + }, + { + name: "ProposalState", + type: { + kind: "enum", + variants: [ + { + name: "Draft", + fields: [ + { + name: "amountStaked", + type: "u64", + }, + ], + }, + { + name: "Pending", + }, + { + name: "Passed", + }, + { + name: "Failed", + }, + { + name: "Removed", + }, + ], + }, + }, + ], + events: [ + { + name: "CollectFeesEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "baseTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "quoteTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "ammBaseVault", + type: "publicKey", + index: false, + }, + { + name: "ammQuoteVault", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteFeesCollected", + type: "u64", + index: false, + }, + { + name: "baseFeesCollected", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "InitializeDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "secondsPerProposal", + type: "u32", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "twapStartDelaySeconds", + type: "u32", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "baseToStake", + type: "u64", + index: false, + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + { + name: "teamSponsoredPassThresholdBps", + type: "i16", + index: false, + }, + { + name: "teamAddress", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "UpdateDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "secondsPerProposal", + type: "u32", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "twapStartDelaySeconds", + type: "u32", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "baseToStake", + type: "u64", + index: false, + }, + { + name: "teamSponsoredPassThresholdBps", + type: "i16", + index: false, + }, + { + name: "teamAddress", + type: "publicKey", + index: false, + }, + { + name: "isOptimisticGovernanceEnabled", + type: "bool", + index: false, + }, + ], + }, + { + name: "InitializeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "quoteVault", + type: "publicKey", + index: false, + }, + { + name: "baseVault", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "number", + type: "u32", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "durationInSeconds", + type: "u32", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "StakeToProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "staker", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + ], + }, + { + name: "UnstakeFromProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "staker", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "timestampEnqueued", + type: "i64", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "FinalizeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passMarketTwap", + type: "u128", + index: false, + }, + { + name: "failMarketTwap", + type: "u128", + index: false, + }, + { + name: "threshold", + type: "u128", + index: false, + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + { + name: "isTeamSponsored", + type: "bool", + index: false, + }, + ], + }, + { + name: "SpotSwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "minOutputAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "ConditionalSwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "trader", + type: "publicKey", + index: false, + }, + { + name: "market", + type: { + defined: "Market", + }, + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "minOutputAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "ProvideLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "liquidityProvider", + type: "publicKey", + index: false, + }, + { + name: "positionAuthority", + type: "publicKey", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "liquidityMinted", + type: "u128", + index: false, + }, + { + name: "minLiquidity", + type: "u128", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "WithdrawLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "liquidityProvider", + type: "publicKey", + index: false, + }, + { + name: "liquidityWithdrawn", + type: "u128", + index: false, + }, + { + name: "minBaseAmount", + type: "u64", + index: false, + }, + { + name: "minQuoteAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "SponsorProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "teamAddress", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "RemoveProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "admin", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "AdminCancelProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "admin", + type: "publicKey", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "CollectMeteoraDammFeesEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "pool", + type: "publicKey", + index: false, + }, + { + name: "baseTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "quoteTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteFeesCollected", + type: "u64", + index: false, + }, + { + name: "baseFeesCollected", + type: "u64", + index: false, + }, + ], + }, + { + name: "AdminFixPositionAuthorityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "admin", + type: "publicKey", + index: false, + }, + { + name: "ammPosition", + type: "publicKey", + index: false, + }, + { + name: "oldAuthority", + type: "publicKey", + index: false, + }, + { + name: "newAuthority", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "InitiateVaultSpendOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "daoQuoteVaultAccount", + type: "publicKey", + index: false, + }, + { + name: "recipientQuoteAccount", + type: "publicKey", + index: false, + }, + { + name: "enqueuedTimestamp", + type: "i64", + index: false, + }, + ], + }, + { + name: "FinalizeOptimisticProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AmmTooOld", + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", + }, + { + code: 6001, + name: "InvalidInitialObservation", + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", + }, + { + code: 6002, + name: "InvalidMaxObservationChange", + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", + }, + { + code: 6003, + name: "InvalidStartDelaySlots", + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", + }, + { + code: 6004, + name: "InvalidSettlementAuthority", + msg: "One of the vaults has an invalid `settlement_authority`", + }, + { + code: 6005, + name: "ProposalTooYoung", + msg: "Proposal is too young to be executed or rejected", + }, + { + code: 6006, + name: "MarketsTooYoung", + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", + }, + { + code: 6007, + name: "ProposalAlreadyFinalized", + msg: "This proposal has already been finalized", + }, + { + code: 6008, + name: "InvalidVaultNonce", + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", + }, + { + code: 6009, + name: "ProposalNotPassed", + msg: "This proposal can't be executed because it isn't in the passed state", + }, + { + code: 6010, + name: "InsufficientLiquidity", + msg: "More liquidity needs to be in the AMM to launch this proposal", + }, + { + code: 6011, + name: "ProposalDurationTooShort", + msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay", + }, + { + code: 6012, + name: "PassThresholdTooHigh", + msg: "Pass threshold must be less than 10%", + }, + { + code: 6013, + name: "QuestionMustBeBinary", + msg: "Question must have exactly 2 outcomes for binary futarchy", + }, + { + code: 6014, + name: "InvalidSquadsProposalStatus", + msg: "Squads proposal must be in Active status", + }, + { + code: 6015, + name: "CastingOverflow", + msg: "Casting overflow. If you're seeing this, please report this", + }, + { + code: 6016, + name: "InsufficientBalance", + msg: "Insufficient balance", + }, + { + code: 6017, + name: "ZeroLiquidityRemove", + msg: "Cannot remove zero liquidity", + }, + { + code: 6018, + name: "SwapSlippageExceeded", + msg: "Swap slippage exceeded", + }, + { + code: 6019, + name: "AssertFailed", + msg: "Assert failed", + }, + { + code: 6020, + name: "InvalidAdmin", + msg: "Invalid admin", + }, + { + code: 6021, + name: "ProposalNotInDraftState", + msg: "Proposal is not in draft state", + }, + { + code: 6022, + name: "InsufficientTokenBalance", + msg: "Insufficient token balance", + }, + { + code: 6023, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6024, + name: "InsufficientStakeToLaunch", + msg: "Insufficient stake to launch proposal", + }, + { + code: 6025, + name: "StakerNotFound", + msg: "Staker not found in proposal", + }, + { + code: 6026, + name: "PoolNotInSpotState", + msg: "Pool must be in spot state", + }, + { + code: 6027, + name: "InvalidDaoCreateLiquidity", + msg: "If you're providing liquidity, you must provide both base and quote token accounts", + }, + { + code: 6028, + name: "InvalidStakeAccount", + msg: "Invalid stake account", + }, + { + code: 6029, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6030, + name: "ProposalNotActive", + msg: "Proposal needs to be active to perform a conditional swap", + }, + { + code: 6031, + name: "InvalidTransaction", + msg: "This Squads transaction should only contain calls to update spending limits", + }, + { + code: 6032, + name: "ProposalAlreadySponsored", + msg: "Proposal has already been sponsored", + }, + { + code: 6033, + name: "InvalidTeamSponsoredPassThreshold", + msg: "Team sponsored pass threshold must be between -10% and 10%", + }, + { + code: 6034, + name: "InvalidTargetK", + msg: "Target K must be greater than the current K", + }, + { + code: 6035, + name: "InvalidTransactionMessage", + msg: "Failed to compile transaction message for Squads vault transaction", + }, + { + code: 6036, + name: "InvalidMint", + msg: "Base mint and quote mint must be different", + }, + { + code: 6037, + name: "InvalidRecipient", + msg: "Invalid recipient", + }, + { + code: 6038, + name: "OptimisticGovernanceDisabled", + msg: "Optimistic governance is disabled", + }, + { + code: 6039, + name: "ActiveOptimisticProposalAlreadyEnqueued", + msg: "An active optimistic proposal is already enqueued", + }, + { + code: 6040, + name: "NoActiveOptimisticProposal", + msg: "No active optimistic proposal", + }, + { + code: 6041, + name: "OptimisticProposalAlreadyPassed", + msg: "Optimistic proposal has already passed", + }, + { + code: 6042, + name: "CannotSponsorOptimisticProposalChallenge", + msg: "Team cannot sponsor a challenge to an optimistic proposal", + }, + { + code: 6043, + name: "InvalidSpendingLimitMint", + msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", + }, + ], +}; diff --git a/sdk2/src/futarchy/v0.6/types/index.ts b/sdk2/src/futarchy/v0.6/types/index.ts new file mode 100644 index 000000000..40d476c2c --- /dev/null +++ b/sdk2/src/futarchy/v0.6/types/index.ts @@ -0,0 +1,51 @@ +import { Futarchy as FutarchyProgram, IDL as FutarchyIDL } from "./futarchy.js"; +export { FutarchyProgram, FutarchyIDL }; + +export { LowercaseKeys } from "../../../utils.js"; + +import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; + +export type InitializeDaoParams = + IdlTypes["InitializeDaoParams"]; +export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; + +export type Dao = IdlAccounts["dao"]; +export type Proposal = IdlAccounts["proposal"]; + +export type CollectFeesEvent = IdlEvents["CollectFeesEvent"]; +export type InitializeDaoEvent = + IdlEvents["InitializeDaoEvent"]; +export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; +export type InitializeProposalEvent = + IdlEvents["InitializeProposalEvent"]; +export type StakeToProposalEvent = + IdlEvents["StakeToProposalEvent"]; +export type UnstakeFromProposalEvent = + IdlEvents["UnstakeFromProposalEvent"]; +export type LaunchProposalEvent = + IdlEvents["LaunchProposalEvent"]; +export type FinalizeProposalEvent = + IdlEvents["FinalizeProposalEvent"]; +export type SpotSwapEvent = IdlEvents["SpotSwapEvent"]; +export type ConditionalSwapEvent = + IdlEvents["ConditionalSwapEvent"]; +export type ProvideLiquidityEvent = + IdlEvents["ProvideLiquidityEvent"]; +export type WithdrawLiquidityEvent = + IdlEvents["WithdrawLiquidityEvent"]; +export type SponsorProposalEvent = + IdlEvents["SponsorProposalEvent"]; +export type FutarchyEvent = + | CollectFeesEvent + | InitializeDaoEvent + | UpdateDaoEvent + | InitializeProposalEvent + | StakeToProposalEvent + | UnstakeFromProposalEvent + | LaunchProposalEvent + | FinalizeProposalEvent + | SpotSwapEvent + | ConditionalSwapEvent + | ProvideLiquidityEvent + | WithdrawLiquidityEvent + | SponsorProposalEvent; diff --git a/sdk2/src/index.ts b/sdk2/src/index.ts new file mode 100644 index 000000000..0b6b7872a --- /dev/null +++ b/sdk2/src/index.ts @@ -0,0 +1,8 @@ +// Default exports for latest versions of programs +export * from "./conditional_vault/index.js"; +export * from "./futarchy/index.js"; + +// Shared exports +export * from "./utils.js"; +export * from "./constants.js"; +export * from "./pda.js"; diff --git a/sdk2/src/pda.ts b/sdk2/src/pda.ts new file mode 100644 index 000000000..cdbf9c0ae --- /dev/null +++ b/sdk2/src/pda.ts @@ -0,0 +1,22 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; + +import { MPL_TOKEN_METADATA_PROGRAM_ID } from "./constants.js"; + +export const getEventAuthorityAddr = (programId: PublicKey) => { + return PublicKey.findProgramAddressSync( + [Buffer.from("__event_authority")], + programId, + ); +}; + +export const getMetadataAddr = (mint: PublicKey) => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("metadata"), + MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + ], + MPL_TOKEN_METADATA_PROGRAM_ID, + ); +}; diff --git a/sdk2/src/utils.ts b/sdk2/src/utils.ts new file mode 100644 index 000000000..2b3348db6 --- /dev/null +++ b/sdk2/src/utils.ts @@ -0,0 +1,19 @@ +import { TransactionInstruction } from "@solana/web3.js"; + +export type LowercaseKeys = { + [K in keyof T as Lowercase]: T[K]; +}; + +export class InstructionUtils { + public static async getInstructions( + ...methodBuilders: any[] + ): Promise { + let instructions: TransactionInstruction[] = []; + + for (const methodBuilder of methodBuilders) { + instructions.push(...(await methodBuilder.transaction()).instructions); + } + + return instructions; + } +} diff --git a/sdk2/tsconfig.json b/sdk2/tsconfig.json new file mode 100644 index 000000000..72ee660a5 --- /dev/null +++ b/sdk2/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "types": ["mocha", "chai"], + "typeRoots": ["./node_modules/@types"], + "lib": ["esnext"], + "module": "NodeNext", + "target": "esnext", + "esModuleInterop": true, + "skipLibCheck": true, + "moduleResolution": "nodenext", + "sourceMap": true, + "outDir": "dist", + "strict": true, + "declaration": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "target", "tests", "migrations"] +} diff --git a/sdk2/yarn.lock b/sdk2/yarn.lock new file mode 100644 index 000000000..ced234393 --- /dev/null +++ b/sdk2/yarn.lock @@ -0,0 +1,3331 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/runtime@^7.25.0": + version "7.28.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326" + integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ== + +"@bundlr-network/client@^0.8.8": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@bundlr-network/client/-/client-0.8.9.tgz#58e969a5d80f8d25d212d46bb7a060730a3c1736" + integrity sha512-SJ7BAt/KhONeFQ0+nbqrw2DUWrsev6y6cmlXt+3x7fPCkw7OJwudtxV/h2nBteZd65NXjqw8yzkmLiLfZ7CCRA== + dependencies: + "@solana/wallet-adapter-base" "^0.9.2" + "@solana/web3.js" "^1.36.0" + "@supercharge/promise-pool" "^2.1.0" + algosdk "^1.13.1" + arbundles "^0.6.21" + arweave "^1.11.4" + async-retry "^1.3.3" + axios "^0.25.0" + base64url "^3.0.1" + bignumber.js "^9.0.1" + bs58 "^4.0.1" + commander "^8.2.0" + csv "^6.0.5" + ethers "^5.5.1" + inquirer "^8.2.0" + js-sha256 "^0.9.0" + mime-types "^2.1.34" + near-api-js "^0.44.2" + near-seed-phrase "^0.2.0" + +"@coral-xyz/anchor@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" + integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== + dependencies: + "@coral-xyz/borsh" "^0.29.0" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.68.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + crypto-hash "^1.3.0" + eventemitter3 "^4.0.7" + pako "^2.0.3" + snake-case "^3.0.4" + superstruct "^0.15.4" + toml "^3.0.0" + +"@coral-xyz/borsh@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.29.0.tgz#79f7045df2ef66da8006d47f5399c7190363e71f" + integrity sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ== + dependencies: + bn.js "^5.1.2" + buffer-layout "^1.2.0" + +"@esbuild/android-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" + integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== + +"@esbuild/android-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" + integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== + +"@esbuild/android-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" + integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== + +"@esbuild/darwin-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" + integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== + +"@esbuild/darwin-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" + integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== + +"@esbuild/freebsd-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" + integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== + +"@esbuild/freebsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" + integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== + +"@esbuild/linux-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" + integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== + +"@esbuild/linux-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" + integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== + +"@esbuild/linux-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" + integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== + +"@esbuild/linux-loong64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" + integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== + +"@esbuild/linux-mips64el@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" + integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== + +"@esbuild/linux-ppc64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" + integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== + +"@esbuild/linux-riscv64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" + integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== + +"@esbuild/linux-s390x@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" + integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== + +"@esbuild/linux-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" + integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== + +"@esbuild/netbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" + integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== + +"@esbuild/openbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" + integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== + +"@esbuild/sunos-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" + integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== + +"@esbuild/win32-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" + integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== + +"@esbuild/win32-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" + integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== + +"@esbuild/win32-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" + integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== + +"@ethersproject/abi@5.8.0", "@ethersproject/abi@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.8.0.tgz#e79bb51940ac35fe6f3262d7fe2cdb25ad5f07d9" + integrity sha512-b9YS/43ObplgyV6SlyQsG53/vkSal0MNA1fskSC4mbnCMi8R+NkcH8K9FPYNESf6jUefBUniE4SOKms0E/KK1Q== + dependencies: + "@ethersproject/address" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/hash" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + +"@ethersproject/abstract-provider@5.8.0", "@ethersproject/abstract-provider@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.8.0.tgz#7581f9be601afa1d02b95d26b9d9840926a35b0c" + integrity sha512-wC9SFcmh4UK0oKuLJQItoQdzS/qZ51EJegK6EmAWlh+OptpQ/npECOR3QqECd8iGHC0RJb4WKbVdSfif4ammrg== + dependencies: + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/networks" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + "@ethersproject/web" "^5.8.0" + +"@ethersproject/abstract-signer@5.8.0", "@ethersproject/abstract-signer@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.8.0.tgz#8d7417e95e4094c1797a9762e6789c7356db0754" + integrity sha512-N0XhZTswXcmIZQdYtUnd79VJzvEwXQw6PK0dTl9VoYrEBxxCPXqS0Eod7q5TNKRxe1/5WUMuR0u0nqTF/avdCA== + dependencies: + "@ethersproject/abstract-provider" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + +"@ethersproject/address@5.8.0", "@ethersproject/address@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.8.0.tgz#3007a2c352eee566ad745dca1dbbebdb50a6a983" + integrity sha512-GhH/abcC46LJwshoN+uBNoKVFPxUuZm6dA257z0vZkKmU1+t8xTn8oK7B9qrj8W2rFRMch4gbJl6PmVxjxBEBA== + dependencies: + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/rlp" "^5.8.0" + +"@ethersproject/base64@5.8.0", "@ethersproject/base64@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.8.0.tgz#61c669c648f6e6aad002c228465d52ac93ee83eb" + integrity sha512-lN0oIwfkYj9LbPx4xEkie6rAMJtySbpOAFXSDVQaBnAzYfB4X2Qr+FXJGxMoc3Bxp2Sm8OwvzMrywxyw0gLjIQ== + dependencies: + "@ethersproject/bytes" "^5.8.0" + +"@ethersproject/basex@5.8.0", "@ethersproject/basex@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.8.0.tgz#1d279a90c4be84d1c1139114a1f844869e57d03a" + integrity sha512-PIgTszMlDRmNwW9nhS6iqtVfdTAKosA7llYXNmGPw4YAI1PUyMv28988wAb41/gHF/WqGdoLv0erHaRcHRKW2Q== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + +"@ethersproject/bignumber@5.8.0", "@ethersproject/bignumber@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.8.0.tgz#c381d178f9eeb370923d389284efa19f69efa5d7" + integrity sha512-ZyaT24bHaSeJon2tGPKIiHszWjD/54Sz8t57Toch475lCLljC6MgPmxk7Gtzz+ddNN5LuHea9qhAe0x3D+uYPA== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + bn.js "^5.2.1" + +"@ethersproject/bytes@5.8.0", "@ethersproject/bytes@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.8.0.tgz#9074820e1cac7507a34372cadeb035461463be34" + integrity sha512-vTkeohgJVCPVHu5c25XWaWQOZ4v+DkGoC42/TS2ond+PARCxTJvgTFUNDZovyQ/uAQ4EcpqqowKydcdmRKjg7A== + dependencies: + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/constants@5.8.0", "@ethersproject/constants@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.8.0.tgz#12f31c2f4317b113a4c19de94e50933648c90704" + integrity sha512-wigX4lrf5Vu+axVTIvNsuL6YrV4O5AXl5ubcURKMEME5TnWBouUh0CDTWxZ2GpnRn1kcCgE7l8O5+VbV9QTTcg== + dependencies: + "@ethersproject/bignumber" "^5.8.0" + +"@ethersproject/contracts@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.8.0.tgz#243a38a2e4aa3e757215ea64e276f8a8c9d8ed73" + integrity sha512-0eFjGz9GtuAi6MZwhb4uvUM216F38xiuR0yYCjKJpNfSEy4HUM8hvqqBj9Jmm0IUz8l0xKEhWwLIhPgxNY0yvQ== + dependencies: + "@ethersproject/abi" "^5.8.0" + "@ethersproject/abstract-provider" "^5.8.0" + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/address" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + +"@ethersproject/hash@5.8.0", "@ethersproject/hash@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.8.0.tgz#b8893d4629b7f8462a90102572f8cd65a0192b4c" + integrity sha512-ac/lBcTbEWW/VGJij0CNSw/wPcw9bSRgCB0AIBz8CvED/jfvDoV9hsIIiWfvWmFEi8RcXtlNwp2jv6ozWOsooA== + dependencies: + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/address" "^5.8.0" + "@ethersproject/base64" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + +"@ethersproject/hdnode@5.8.0", "@ethersproject/hdnode@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.8.0.tgz#a51ae2a50bcd48ef6fd108c64cbae5e6ff34a761" + integrity sha512-4bK1VF6E83/3/Im0ERnnUeWOY3P1BZml4ZD3wcH8Ys0/d1h1xaFt6Zc+Dh9zXf9TapGro0T4wvO71UTCp3/uoA== + dependencies: + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/basex" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/pbkdf2" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/sha2" "^5.8.0" + "@ethersproject/signing-key" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + "@ethersproject/wordlists" "^5.8.0" + +"@ethersproject/json-wallets@5.8.0", "@ethersproject/json-wallets@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/json-wallets/-/json-wallets-5.8.0.tgz#d18de0a4cf0f185f232eb3c17d5e0744d97eb8c9" + integrity sha512-HxblNck8FVUtNxS3VTEYJAcwiKYsBIF77W15HufqlBF9gGfhmYOJtYZp8fSDZtn9y5EaXTE87zDwzxRoTFk11w== + dependencies: + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/address" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/hdnode" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/pbkdf2" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/random" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + aes-js "3.0.0" + scrypt-js "3.0.1" + +"@ethersproject/keccak256@5.8.0", "@ethersproject/keccak256@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.8.0.tgz#d2123a379567faf2d75d2aaea074ffd4df349e6a" + integrity sha512-A1pkKLZSz8pDaQ1ftutZoaN46I6+jvuqugx5KYNeQOPqq+JZ0Txm7dlWesCHB5cndJSu5vP2VKptKf7cksERng== + dependencies: + "@ethersproject/bytes" "^5.8.0" + js-sha3 "0.8.0" + +"@ethersproject/logger@5.8.0", "@ethersproject/logger@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.8.0.tgz#f0232968a4f87d29623a0481690a2732662713d6" + integrity sha512-Qe6knGmY+zPPWTC+wQrpitodgBfH7XoceCGL5bJVejmH+yCS3R8jJm8iiWuvWbG76RUmyEG53oqv6GMVWqunjA== + +"@ethersproject/networks@5.8.0", "@ethersproject/networks@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.8.0.tgz#8b4517a3139380cba9fb00b63ffad0a979671fde" + integrity sha512-egPJh3aPVAzbHwq8DD7Po53J4OUSsA1MjQp8Vf/OZPav5rlmWUaFLiq8cvQiGK0Z5K6LYzm29+VA/p4RL1FzNg== + dependencies: + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/pbkdf2@5.8.0", "@ethersproject/pbkdf2@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.8.0.tgz#cd2621130e5dd51f6a0172e63a6e4a0c0a0ec37e" + integrity sha512-wuHiv97BrzCmfEaPbUFpMjlVg/IDkZThp9Ri88BpjRleg4iePJaj2SW8AIyE8cXn5V1tuAaMj6lzvsGJkGWskg== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/sha2" "^5.8.0" + +"@ethersproject/properties@5.8.0", "@ethersproject/properties@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.8.0.tgz#405a8affb6311a49a91dabd96aeeae24f477020e" + integrity sha512-PYuiEoQ+FMaZZNGrStmN7+lWjlsoufGIHdww7454FIaGdbe/p5rnaCXTr5MtBYl3NkeoVhHZuyzChPeGeKIpQw== + dependencies: + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/providers@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.8.0.tgz#6c2ae354f7f96ee150439f7de06236928bc04cb4" + integrity sha512-3Il3oTzEx3o6kzcg9ZzbE+oCZYyY+3Zh83sKkn4s1DZfTUjIegHnN2Cm0kbn9YFy45FDVcuCLLONhU7ny0SsCw== + dependencies: + "@ethersproject/abstract-provider" "^5.8.0" + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/address" "^5.8.0" + "@ethersproject/base64" "^5.8.0" + "@ethersproject/basex" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/hash" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/networks" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/random" "^5.8.0" + "@ethersproject/rlp" "^5.8.0" + "@ethersproject/sha2" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + "@ethersproject/web" "^5.8.0" + bech32 "1.1.4" + ws "8.18.0" + +"@ethersproject/random@5.8.0", "@ethersproject/random@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.8.0.tgz#1bced04d49449f37c6437c701735a1a022f0057a" + integrity sha512-E4I5TDl7SVqyg4/kkA/qTfuLWAQGXmSOgYyO01So8hLfwgKvYK5snIlzxJMk72IFdG/7oh8yuSqY2KX7MMwg+A== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/rlp@5.8.0", "@ethersproject/rlp@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.8.0.tgz#5a0d49f61bc53e051532a5179472779141451de5" + integrity sha512-LqZgAznqDbiEunaUvykH2JAoXTT9NV0Atqk8rQN9nx9SEgThA/WMx5DnW8a9FOufo//6FZOCHZ+XiClzgbqV9Q== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/sha2@5.8.0", "@ethersproject/sha2@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.8.0.tgz#8954a613bb78dac9b46829c0a95de561ef74e5e1" + integrity sha512-dDOUrXr9wF/YFltgTBYS0tKslPEKr6AekjqDW2dbn1L1xmjGR+9GiKu4ajxovnrDbwxAKdHjW8jNcwfz8PAz4A== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + hash.js "1.1.7" + +"@ethersproject/signing-key@5.8.0", "@ethersproject/signing-key@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.8.0.tgz#9797e02c717b68239c6349394ea85febf8893119" + integrity sha512-LrPW2ZxoigFi6U6aVkFN/fa9Yx/+4AtIUe4/HACTvKJdhm0eeb107EVCIQcrLZkxaSIgc/eCrX8Q1GtbH+9n3w== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + bn.js "^5.2.1" + elliptic "6.6.1" + hash.js "1.1.7" + +"@ethersproject/solidity@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.8.0.tgz#429bb9fcf5521307a9448d7358c26b93695379b9" + integrity sha512-4CxFeCgmIWamOHwYN9d+QWGxye9qQLilpgTU0XhYs1OahkclF+ewO+3V1U0mvpiuQxm5EHHmv8f7ClVII8EHsA== + dependencies: + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/sha2" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + +"@ethersproject/strings@5.8.0", "@ethersproject/strings@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.8.0.tgz#ad79fafbf0bd272d9765603215ac74fd7953908f" + integrity sha512-qWEAk0MAvl0LszjdfnZ2uC8xbR2wdv4cDabyHiBh3Cldq/T8dPH3V4BbBsAYJUeonwD+8afVXld274Ls+Y1xXg== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/transactions@5.8.0", "@ethersproject/transactions@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.8.0.tgz#1e518822403abc99def5a043d1c6f6fe0007e46b" + integrity sha512-UglxSDjByHG0TuU17bDfCemZ3AnKO2vYrL5/2n2oXvKzvb7Cz+W9gOWXKARjp2URVwcWlQlPOEQyAviKwT4AHg== + dependencies: + "@ethersproject/address" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/rlp" "^5.8.0" + "@ethersproject/signing-key" "^5.8.0" + +"@ethersproject/units@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.8.0.tgz#c12f34ba7c3a2de0e9fa0ed0ee32f3e46c5c2c6a" + integrity sha512-lxq0CAnc5kMGIiWW4Mr041VT8IhNM+Pn5T3haO74XZWFulk7wH1Gv64HqE96hT4a7iiNMdOCFEBgaxWuk8ETKQ== + dependencies: + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/constants" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + +"@ethersproject/wallet@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.8.0.tgz#49c300d10872e6986d953e8310dc33d440da8127" + integrity sha512-G+jnzmgg6UxurVKRKvw27h0kvG75YKXZKdlLYmAHeF32TGUzHkOFd7Zn6QHOTYRFWnfjtSSFjBowKo7vfrXzPA== + dependencies: + "@ethersproject/abstract-provider" "^5.8.0" + "@ethersproject/abstract-signer" "^5.8.0" + "@ethersproject/address" "^5.8.0" + "@ethersproject/bignumber" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/hash" "^5.8.0" + "@ethersproject/hdnode" "^5.8.0" + "@ethersproject/json-wallets" "^5.8.0" + "@ethersproject/keccak256" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/random" "^5.8.0" + "@ethersproject/signing-key" "^5.8.0" + "@ethersproject/transactions" "^5.8.0" + "@ethersproject/wordlists" "^5.8.0" + +"@ethersproject/web@5.8.0", "@ethersproject/web@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.8.0.tgz#3e54badc0013b7a801463a7008a87988efce8a37" + integrity sha512-j7+Ksi/9KfGviws6Qtf9Q7KCqRhpwrYKQPs+JBA/rKVFF/yaWLHJEH3zfVP2plVu+eys0d2DlFmhoQJayFewcw== + dependencies: + "@ethersproject/base64" "^5.8.0" + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + +"@ethersproject/wordlists@5.8.0", "@ethersproject/wordlists@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.8.0.tgz#7a5654ee8d1bb1f4dbe43f91d217356d650ad821" + integrity sha512-2df9bbXicZws2Sb5S6ET493uJ0Z84Fjr3pC4tu/qlnZERibZCeUVuqdtt+7Tv9xxhUxHoIekIA7avrKUWHrezg== + dependencies: + "@ethersproject/bytes" "^5.8.0" + "@ethersproject/hash" "^5.8.0" + "@ethersproject/logger" "^5.8.0" + "@ethersproject/properties" "^5.8.0" + "@ethersproject/strings" "^5.8.0" + +"@inquirer/external-editor@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@inquirer/external-editor/-/external-editor-1.0.3.tgz#c23988291ee676290fdab3fd306e64010a6d13b8" + integrity sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA== + dependencies: + chardet "^2.1.1" + iconv-lite "^0.7.0" + +"@metaplex-foundation/beet-solana@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.0.tgz#52891e78674aaa54e0031f1bca5bfbc40de12e8d" + integrity sha512-B1L94N3ZGMo53b0uOSoznbuM5GBNJ8LwSeznxBxJ+OThvfHQ4B5oMUqb+0zdLRfkKGS7Q6tpHK9P+QK0j3w2cQ== + dependencies: + "@metaplex-foundation/beet" ">=0.1.0" + "@solana/web3.js" "^1.56.2" + bs58 "^5.0.0" + debug "^4.3.4" + +"@metaplex-foundation/beet@0.7.1": + version "0.7.1" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.1.tgz#0975314211643f87b5f6f3e584fa31abcf4c612c" + integrity sha512-hNCEnS2WyCiYyko82rwuISsBY3KYpe828ubsd2ckeqZr7tl0WVLivGkoyA/qdiaaHEBGdGl71OpfWa2rqL3DiA== + dependencies: + ansicolors "^0.3.2" + bn.js "^5.2.0" + debug "^4.3.3" + +"@metaplex-foundation/beet@>=0.1.0": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.2.tgz#fa4726e4cfd4fb6fed6cddc9b5213c1c2a2d0b77" + integrity sha512-K+g3WhyFxKPc0xIvcIjNyV1eaTVJTiuaHZpig7Xx0MuYRMoJLLvhLTnUXhFdR5Tu2l2QSyKwfyXDgZlzhULqFg== + dependencies: + ansicolors "^0.3.2" + assert "^2.1.0" + bn.js "^5.2.0" + debug "^4.3.3" + +"@metaplex-foundation/cusper@^0.0.2": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/cusper/-/cusper-0.0.2.tgz#dc2032a452d6c269e25f016aa4dd63600e2af975" + integrity sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA== + +"@metaplex-foundation/umi-bundle-defaults@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-bundle-defaults/-/umi-bundle-defaults-0.9.2.tgz#f8e296b1a0ecb3a6511dbaca4131bc9263071cfc" + integrity sha512-kV3tfvgvRjVP1p9OFOtH+ibOtN9omVJSwKr0We4/9r45e5LTj+32su0V/rixZUkG1EZzzOYBsxhtIE0kIw/Hrw== + dependencies: + "@metaplex-foundation/umi-downloader-http" "^0.9.2" + "@metaplex-foundation/umi-eddsa-web3js" "^0.9.2" + "@metaplex-foundation/umi-http-fetch" "^0.9.2" + "@metaplex-foundation/umi-program-repository" "^0.9.2" + "@metaplex-foundation/umi-rpc-chunk-get-accounts" "^0.9.2" + "@metaplex-foundation/umi-rpc-web3js" "^0.9.2" + "@metaplex-foundation/umi-serializer-data-view" "^0.9.2" + "@metaplex-foundation/umi-transaction-factory-web3js" "^0.9.2" + +"@metaplex-foundation/umi-downloader-http@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-downloader-http/-/umi-downloader-http-0.9.2.tgz#df84b11df9141854ca1cf7c6c8374658e67de767" + integrity sha512-tzPT9hBwenzTzAQg07rmsrqZfgguAXELbcJrsYMoASp5VqWFXYIP00g94KET6XLjWUXH4P1J2zoa6hGennPXHA== + +"@metaplex-foundation/umi-eddsa-web3js@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-eddsa-web3js/-/umi-eddsa-web3js-0.9.2.tgz#92225595137c5585dae63b148786ab77fcb6d625" + integrity sha512-hhPCxXbYIp4BC4z9gK78sXpWLkNSrfv4ndhF5ruAkdIp7GcRVYKj0QnOUO6lGYGiIkNlw20yoTwOe1CT//OfTQ== + dependencies: + "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" + "@noble/curves" "^1.0.0" + +"@metaplex-foundation/umi-http-fetch@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-http-fetch/-/umi-http-fetch-0.9.2.tgz#e233ec34b789ed5257168b97d72fc9b039155046" + integrity sha512-YCZuBu24T9ZzEDe4+w12LEZm/fO9pkyViZufGgASC5NX93814Lvf6Ssjn/hZzjfA7CvZbvLFbmujc6CV3Q/m9Q== + dependencies: + node-fetch "^2.6.7" + +"@metaplex-foundation/umi-options@^0.8.9": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-options/-/umi-options-0.8.9.tgz#9c9e269d9eee7d055ad6831dcb30a30127dcb0c5" + integrity sha512-jSQ61sZMPSAk/TXn8v8fPqtz3x8d0/blVZXLLbpVbo2/T5XobiI6/MfmlUosAjAUaQl6bHRF8aIIqZEFkJiy4A== + +"@metaplex-foundation/umi-program-repository@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-program-repository/-/umi-program-repository-0.9.2.tgz#53fce2bf506bb97fdb6a53e2118f8d1dd28fd0b5" + integrity sha512-g3+FPqXEmYsBa8eETtUE2gb2Oe3mqac0z3/Ur1TvAg5TtIy3mzRzOy/nza+sgzejnfcxcVg835rmpBaxpBnjDA== + +"@metaplex-foundation/umi-public-keys@^0.8.9": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-public-keys/-/umi-public-keys-0.8.9.tgz#ca7a927c924ed8e28d0f8bb3dc0f2adc1f9011ec" + integrity sha512-CxMzN7dgVGOq9OcNCJe2casKUpJ3RmTVoOvDFyeoTQuK+vkZ1YSSahbqC1iGuHEtKTLSjtWjKvUU6O7zWFTw3Q== + dependencies: + "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" + +"@metaplex-foundation/umi-rpc-chunk-get-accounts@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-chunk-get-accounts/-/umi-rpc-chunk-get-accounts-0.9.2.tgz#f93bd43d4c65cdfdb0a68145a837fb6b13e0e832" + integrity sha512-YRwVf6xH0jPBAUgMhEPi+UbjioAeqTXmjsN2TnmQCPAmHbrHrMRj0rlWYwFLWAgkmoxazYrXP9lqOFRrfOGAEA== + +"@metaplex-foundation/umi-rpc-web3js@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-web3js/-/umi-rpc-web3js-0.9.2.tgz#b00a4cc1a9bd5d930164d1ba43f816107655c0d9" + integrity sha512-MqcsBz8B4wGl6jxsf2Jo/rAEpYReU9VCSR15QSjhvADHMmdFxCIZCCAgE+gDE2Vuanfl437VhOcP3g5Uw8C16Q== + dependencies: + "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" + +"@metaplex-foundation/umi-serializer-data-view@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializer-data-view/-/umi-serializer-data-view-0.9.2.tgz#a05d88e7120b839e3acba35f7b4e12fe8be2becc" + integrity sha512-5vGptadJxUxvUcyrwFZxXlEc6Q7AYySBesizCtrBFUY8w8PnF2vzmS45CP1MLySEATNH6T9mD4Rs0tLb87iQyA== + +"@metaplex-foundation/umi-serializers-core@^0.8.9": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-core/-/umi-serializers-core-0.8.9.tgz#cd5ae763a59e54dd01f1284f4a6bf4e78e4aab9c" + integrity sha512-WT82tkiYJ0Qmscp7uTj1Hz6aWQPETwaKLAENAUN5DeWghkuBKtuxyBKVvEOuoXerJSdhiAk0e8DWA4cxcTTQ/w== + +"@metaplex-foundation/umi-serializers-encodings@^0.8.9": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-encodings/-/umi-serializers-encodings-0.8.9.tgz#0f02605ee3e6fbeac1abc4fb267a7cc96ecb4410" + integrity sha512-N3VWLDTJ0bzzMKcJDL08U3FaqRmwlN79FyE4BHj6bbAaJ9LEHjDQ9RJijZyWqTm0jE7I750fU7Ow5EZL38Xi6Q== + dependencies: + "@metaplex-foundation/umi-serializers-core" "^0.8.9" + +"@metaplex-foundation/umi-serializers-numbers@^0.8.9": + version "0.8.9" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-numbers/-/umi-serializers-numbers-0.8.9.tgz#28c10367f6aebac0276ec1bce81d0d8db54b05de" + integrity sha512-NtBf1fnVNQJHFQjLFzRu2i9GGnigb9hOm/Gfrk628d0q0tRJB7BOM3bs5C61VAs7kJs4yd+pDNVAERJkknQ7Lg== + dependencies: + "@metaplex-foundation/umi-serializers-core" "^0.8.9" + +"@metaplex-foundation/umi-serializers@^0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers/-/umi-serializers-0.9.0.tgz#af6d03a3bf821bf73b7b3450bb8df0407f2f69d6" + integrity sha512-hAOW9Djl4w4ioKeR4erDZl5IG4iJdP0xA19ZomdaCbMhYAAmG/FEs5khh0uT2mq53/MnzWcXSUPoO8WBN4Q+Vg== + dependencies: + "@metaplex-foundation/umi-options" "^0.8.9" + "@metaplex-foundation/umi-public-keys" "^0.8.9" + "@metaplex-foundation/umi-serializers-core" "^0.8.9" + "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" + "@metaplex-foundation/umi-serializers-numbers" "^0.8.9" + +"@metaplex-foundation/umi-transaction-factory-web3js@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-transaction-factory-web3js/-/umi-transaction-factory-web3js-0.9.2.tgz#294c3ca996897bb95b993b808fb9252bd085db15" + integrity sha512-fR1Kf21uylMFd1Smkltmj4jTNxhqSWf416owsJ+T+cvJi2VCOcOwq/3UFzOrpz78fA0RhsajKYKj0HYsRnQI1g== + dependencies: + "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" + +"@metaplex-foundation/umi-uploader-bundlr@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-uploader-bundlr/-/umi-uploader-bundlr-0.9.2.tgz#0d832816a32970cac9f412a0b0a8234415ab8534" + integrity sha512-wmixKqWyEO0lRB2GNvm5XOwi3jEyCtPZ6Oqds6sY5YHYdrn1Cqgd1TcdAuu7+DuojcNFErTjWsaQ1F9QR502QQ== + dependencies: + "@bundlr-network/client" "^0.8.8" + "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" + bignumber.js "^9.0.2" + buffer "^6.0.3" + +"@metaplex-foundation/umi-web3js-adapters@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-web3js-adapters/-/umi-web3js-adapters-0.9.2.tgz#1e0ebb4e3c31e8bead27892b20204292ad6955c5" + integrity sha512-RQqUTtHYY9fmEMnq7s3Hiv/81flGaoI0ZVVoafnFVaQLnxU6QBKxtboRZHk43XtD9CiFh5f9izrMJX7iK7KlOA== + dependencies: + buffer "^6.0.3" + +"@metaplex-foundation/umi@^0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi/-/umi-0.9.2.tgz#6460bff91d2ac7745842eda1ee6a28fba4d2ffb2" + integrity sha512-9i4Acm4pruQfJcpRrc2EauPBwkfDN0I9QTvJyZocIlKgoZwD6A6wH0PViH1AjOVG5CQCd1YI3tJd5XjYE1ElBw== + dependencies: + "@metaplex-foundation/umi-options" "^0.8.9" + "@metaplex-foundation/umi-public-keys" "^0.8.9" + "@metaplex-foundation/umi-serializers" "^0.9.0" + +"@noble/curves@^1.0.0", "@noble/curves@^1.4.2": + version "1.9.7" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951" + integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw== + dependencies: + "@noble/hashes" "1.8.0" + +"@noble/ed25519@^1.6.1": + version "1.7.5" + resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.5.tgz#94df8bdb9fec9c4644a56007eecb57b0e9fbd0d7" + integrity sha512-xuS0nwRMQBvSxDa7UxMb61xTiH3MxTgUfhyPUALVIe0FlOAz4sjELwyDRyUvqeEYfRSG9qNjFIycqLZppg4RSA== + +"@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a" + integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A== + +"@randlabs/communication-bridge@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3" + integrity sha512-CzS0U8IFfXNK7QaJFE4pjbxDGfPjbXBEsEaCn9FN15F+ouSAEUQkva3Gl66hrkBZOGexKFEWMwUHIDKpZ2hfVg== + +"@randlabs/myalgo-connect@^1.1.2": + version "1.4.2" + resolved "https://registry.yarnpkg.com/@randlabs/myalgo-connect/-/myalgo-connect-1.4.2.tgz#ce3ad97b3889ea21da75852187511d3f6be0fa05" + integrity sha512-K9hEyUi7G8tqOp7kWIALJLVbGCByhilcy6123WfcorxWwiE1sbQupPyIU5f3YdQK6wMjBsyTWiLW52ZBMp7sXA== + dependencies: + "@randlabs/communication-bridge" "1.0.1" + +"@solana/buffer-layout-utils@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" + integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/web3.js" "^1.32.0" + bigint-buffer "^1.1.5" + bignumber.js "^9.0.1" + +"@solana/buffer-layout@^4.0.0", "@solana/buffer-layout@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" + integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== + dependencies: + buffer "~6.0.3" + +"@solana/codecs-core@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.0.0-rc.1.tgz#1a2d76b9c7b9e7b7aeb3bd78be81c2ba21e3ce22" + integrity sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ== + dependencies: + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-core@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.3.0.tgz#6bf2bb565cb1ae880f8018635c92f751465d8695" + integrity sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw== + dependencies: + "@solana/errors" "2.3.0" + +"@solana/codecs-data-structures@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-rc.1.tgz#d47b2363d99fb3d643f5677c97d64a812982b888" + integrity sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-numbers@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.0.0-rc.1.tgz#f34978ddf7ea4016af3aaed5f7577c1d9869a614" + integrity sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs-numbers@^2.1.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.3.0.tgz#ac7e7f38aaf7fcd22ce2061fbdcd625e73828dc6" + integrity sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg== + dependencies: + "@solana/codecs-core" "2.3.0" + "@solana/errors" "2.3.0" + +"@solana/codecs-strings@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-2.0.0-rc.1.tgz#e1d9167075b8c5b0b60849f8add69c0f24307018" + integrity sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/codecs@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/codecs/-/codecs-2.0.0-rc.1.tgz#146dc5db58bd3c28e04b4c805e6096c2d2a0a875" + integrity sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-data-structures" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/codecs-strings" "2.0.0-rc.1" + "@solana/options" "2.0.0-rc.1" + +"@solana/errors@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.0.0-rc.1.tgz#3882120886eab98a37a595b85f81558861b29d62" + integrity sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ== + dependencies: + chalk "^5.3.0" + commander "^12.1.0" + +"@solana/errors@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.3.0.tgz#4ac9380343dbeffb9dffbcb77c28d0e457c5fa31" + integrity sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ== + dependencies: + chalk "^5.4.1" + commander "^14.0.0" + +"@solana/options@2.0.0-rc.1": + version "2.0.0-rc.1" + resolved "https://registry.yarnpkg.com/@solana/options/-/options-2.0.0-rc.1.tgz#06924ba316dc85791fc46726a51403144a85fc4d" + integrity sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA== + dependencies: + "@solana/codecs-core" "2.0.0-rc.1" + "@solana/codecs-data-structures" "2.0.0-rc.1" + "@solana/codecs-numbers" "2.0.0-rc.1" + "@solana/codecs-strings" "2.0.0-rc.1" + "@solana/errors" "2.0.0-rc.1" + +"@solana/spl-token-metadata@^0.1.2": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@solana/spl-token-metadata/-/spl-token-metadata-0.1.6.tgz#d240947aed6e7318d637238022a7b0981b32ae80" + integrity sha512-7sMt1rsm/zQOQcUWllQX9mD2O6KhSAtY1hFR2hfFwgqfFWzSY9E9GDvFVNYUI1F0iQKcm6HmePU9QbKRXTEBiA== + dependencies: + "@solana/codecs" "2.0.0-rc.1" + +"@solana/spl-token@^0.3.6", "@solana/spl-token@^0.3.7", "@solana/spl-token@^0.3.8": + version "0.3.11" + resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.11.tgz#cdc10f9472b29b39c8983c92592cadd06627fb9a" + integrity sha512-bvohO3rIMSVL24Pb+I4EYTJ6cL82eFpInEXD/I8K8upOGjpqHsKUoAempR/RnUlI1qSFNyFlWJfu6MNUgfbCQQ== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/buffer-layout-utils" "^0.2.0" + "@solana/spl-token-metadata" "^0.1.2" + buffer "^6.0.3" + +"@solana/wallet-adapter-base@^0.9.2": + version "0.9.27" + resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.27.tgz#f76463db172ac1d7d1f5aa064800363777731dfd" + integrity sha512-kXjeNfNFVs/NE9GPmysBRKQ/nf+foSaq3kfVSeMcO/iVgigyRmB551OjU3WyAolLG/1jeEfKLqF9fKwMCRkUqg== + dependencies: + "@solana/wallet-standard-features" "^1.3.0" + "@wallet-standard/base" "^1.1.0" + "@wallet-standard/features" "^1.1.0" + eventemitter3 "^5.0.1" + +"@solana/wallet-standard-features@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-features/-/wallet-standard-features-1.3.0.tgz#c489eca9d0c78f97084b4af6ca8ad8c1ca197de5" + integrity sha512-ZhpZtD+4VArf6RPitsVExvgkF+nGghd1rzPjd97GmBximpnt1rsUxMOEyoIEuH3XBxPyNB6Us7ha7RHWQR+abg== + dependencies: + "@wallet-standard/base" "^1.1.0" + "@wallet-standard/features" "^1.1.0" + +"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.70.3", "@solana/web3.js@^1.76.0": + version "1.98.4" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" + integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + "@solana/codecs-numbers" "^2.1.0" + agentkeepalive "^4.5.0" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + +"@sqds/multisig@^2.1.4": + version "2.1.4" + resolved "https://registry.yarnpkg.com/@sqds/multisig/-/multisig-2.1.4.tgz#f69067ee8e23e86b1170ae7509cdfbc460ac9d0d" + integrity sha512-5w+NmwHOzl96nI50R/fjSD6uFydRLNUquhoEmmWbGepS4D9DnQyF2TKcUBfTyxV3sgJt00ypBt7SXB3y8WOzUQ== + dependencies: + "@metaplex-foundation/beet" "0.7.1" + "@metaplex-foundation/beet-solana" "0.4.0" + "@metaplex-foundation/cusper" "^0.0.2" + "@solana/spl-token" "^0.3.6" + "@solana/web3.js" "^1.70.3" + "@types/bn.js" "^5.1.1" + assert "^2.0.0" + bn.js "^5.2.1" + buffer "6.0.3" + invariant "2.2.4" + +"@supercharge/promise-pool@^2.1.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-2.4.0.tgz#6050eea8c2d7f92ddd4ddc582ee328b15c034ad3" + integrity sha512-O9CMipBlq5OObdt1uKJGIzm9cdjpPWfj+a+Zw9EgWKxaMNHKC7EU7X9taj3H0EGQNLOSq2jAcOa3EzxlfHsD6w== + +"@swc/helpers@^0.5.11": + version "0.5.17" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.17.tgz#5a7be95ac0f0bf186e7e6e890e7a6f6cda6ce971" + integrity sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A== + dependencies: + tslib "^2.8.0" + +"@types/bn.js@^5.1.0", "@types/bn.js@^5.1.1": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.2.0.tgz#4349b9710e98f9ab3cdc50f1c5e4dcbd8ef29c80" + integrity sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q== + dependencies: + "@types/node" "*" + +"@types/chai@^4.3.0": + version "4.3.20" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.20.tgz#cb291577ed342ca92600430841a00329ba05cecc" + integrity sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ== + +"@types/connect@^3.4.33": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== + +"@types/mocha@^9.0.0": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" + integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== + +"@types/node@*": + version "25.0.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-25.0.3.tgz#79b9ac8318f373fbfaaf6e2784893efa9701f269" + integrity sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA== + dependencies: + undici-types "~7.16.0" + +"@types/node@11.11.6": + version "11.11.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" + integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== + +"@types/node@^12.12.54": + version "12.20.55" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" + integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== + +"@types/uuid@^8.3.4": + version "8.3.4" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" + integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== + +"@types/ws@^7.4.4": + version "7.4.7" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" + integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== + dependencies: + "@types/node" "*" + +"@types/ws@^8.2.2": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.18.1.tgz#48464e4bf2ddfd17db13d845467f6070ffea4aa9" + integrity sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg== + dependencies: + "@types/node" "*" + +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== + +"@wallet-standard/base@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@wallet-standard/base/-/base-1.1.0.tgz#214093c0597a1e724ee6dbacd84191dfec62bb33" + integrity sha512-DJDQhjKmSNVLKWItoKThJS+CsJQjR9AOBOirBVT1F9YpRyC9oYHE+ZnSf8y8bxUphtKqdQMPVQ2mHohYdRvDVQ== + +"@wallet-standard/features@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@wallet-standard/features/-/features-1.1.0.tgz#f256d7b18940c8d134f66164330db358a8f5200e" + integrity sha512-hiEivWNztx73s+7iLxsuD1sOJ28xtRix58W7Xnz4XzzA/pF0+aicnWgjOdA10doVDEDZdUuZCIIqG96SFNlDUg== + dependencies: + "@wallet-standard/base" "^1.1.0" + +aes-js@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" + integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== + +agentkeepalive@^4.5.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.6.0.tgz#35f73e94b3f40bf65f105219c623ad19c136ea6a" + integrity sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ== + dependencies: + humanize-ms "^1.2.1" + +algo-msgpack-with-bigint@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz#38bb717220525b3ff42232eefdcd9efb9ad405d6" + integrity sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ== + +algosdk@^1.13.1: + version "1.24.1" + resolved "https://registry.yarnpkg.com/algosdk/-/algosdk-1.24.1.tgz#afc4102457ae0c38a32de6b84f4d713aedfc9e89" + integrity sha512-9moZxdqeJ6GdE4N6fA/GlUP4LrbLZMYcYkt141J4Ss68OfEgH9qW0wBuZ3ZOKEx/xjc5bg7mLP2Gjg7nwrkmww== + dependencies: + algo-msgpack-with-bigint "^2.1.1" + buffer "^6.0.2" + cross-fetch "^3.1.5" + hi-base32 "^0.5.1" + js-sha256 "^0.9.0" + js-sha3 "^0.8.0" + js-sha512 "^0.8.0" + json-bigint "^1.0.0" + tweetnacl "^1.0.3" + vlq "^2.0.4" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-escapes@^4.2.1: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@=5.0.1, ansi-regex@^4.1.0, ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@=4.3.0, ansi-styles@^4.0.0, ansi-styles@^4.1.0, ansi-styles@^6.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansicolors@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" + integrity sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg== + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arbundles@^0.6.21: + version "0.6.23" + resolved "https://registry.yarnpkg.com/arbundles/-/arbundles-0.6.23.tgz#c00cda953df67fa65d4297486237cc8e0c072c47" + integrity sha512-+gr93F3fivN+6dhiImT6BQNaXz4oECPn2GYjCZjS2yEoq7hM78FRvVp6kQyjEdhnuBFQr/q4oS/nkjnQlHdj9Q== + dependencies: + "@noble/ed25519" "^1.6.1" + "@randlabs/myalgo-connect" "^1.1.2" + "@solana/wallet-adapter-base" "^0.9.2" + algosdk "^1.13.1" + arweave "^1.11.4" + arweave-stream-tx "^1.1.0" + avsc "https://github.com/Irys-xyz/avsc#csp-fixes" + axios "^0.21.3" + base64url "^3.0.1" + bs58 "^4.0.1" + ethers "^5.5.1" + keccak "^3.0.2" + multistream "^4.1.0" + process "^0.11.10" + secp256k1 "^4.0.2" + tmp-promise "^3.0.2" + +arconnect@^0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/arconnect/-/arconnect-0.4.2.tgz#83de7638fb46183e82d7ec7efb5594c5f7cdc806" + integrity sha512-Jkpd4QL3TVqnd3U683gzXmZUVqBUy17DdJDuL/3D9rkysLgX6ymJ2e+sR+xyZF5Rh42CBqDXWNMmCjBXeP7Gbw== + dependencies: + arweave "^1.10.13" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== + +arweave-stream-tx@^1.1.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/arweave-stream-tx/-/arweave-stream-tx-1.2.2.tgz#2d5c66554301baacd02586a152fbb198b422112f" + integrity sha512-bNt9rj0hbAEzoUZEF2s6WJbIz8nasZlZpxIw03Xm8fzb9gRiiZlZGW3lxQLjfc9Z0VRUWDzwtqoYeEoB/JDToQ== + dependencies: + exponential-backoff "^3.1.0" + +arweave@^1.10.13, arweave@^1.11.4: + version "1.15.7" + resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.15.7.tgz#d09265d128e93a471203649de083ba7fec52cb29" + integrity sha512-F+Y4iWU1qea9IsKQ/YNmLsY4DHQVsaJBuhEbFxQn9cfGHOmtXE+bwo14oY8xqymsqSNf/e1PeIfLk7G7qN/hVA== + dependencies: + arconnect "^0.4.2" + asn1.js "^5.4.1" + base64-js "^1.5.1" + bignumber.js "^9.0.2" + +asn1.js@^5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" + integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + safer-buffer "^2.1.0" + +assert@^2.0.0, assert@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-2.1.0.tgz#6d92a238d05dc02e7427c881fb8be81c8448b2dd" + integrity sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw== + dependencies: + call-bind "^1.0.2" + is-nan "^1.3.2" + object-is "^1.1.5" + object.assign "^4.1.4" + util "^0.12.5" + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + +async-retry@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" + integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== + dependencies: + retry "0.13.1" + +available-typed-arrays@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" + integrity sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ== + dependencies: + possible-typed-array-names "^1.0.0" + +"avsc@https://github.com/Irys-xyz/avsc#csp-fixes": + version "5.4.7" + resolved "https://github.com/Irys-xyz/avsc#a730cc8018b79e114b6a3381bbb57760a24c6cef" + +axios@^0.21.3: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + +axios@^0.25.0: + version "0.25.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a" + integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g== + dependencies: + follow-redirects "^1.14.7" + +backslash@=0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/backslash/-/backslash-0.2.0.tgz#6c3c1fce7e7e714ccfc10fd74f0f73410677375f" + integrity sha512-Avs+8FUZ1HF/VFP4YWwHQZSGzRPm37ukU1JQYQWijuHhtXdOuAzcZ8PcAzfIw898a8PyBzdn+RtnKA6MzW0X2A== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base-x@^3.0.2: + version "3.0.11" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff" + integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA== + dependencies: + safe-buffer "^5.0.1" + +base-x@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.1.tgz#817fb7b57143c501f649805cb247617ad016a885" + integrity sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw== + +base64-js@^1.3.1, base64-js@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +base64url@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" + integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== + +bech32@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + +bigint-buffer@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" + integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== + dependencies: + bindings "^1.3.0" + +bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.0.2: + version "9.3.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.3.1.tgz#759c5aaddf2ffdc4f154f7b493e1c8770f88c4d7" + integrity sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ== + +binary-extensions@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== + +bindings@^1.3.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +bip39-light@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/bip39-light/-/bip39-light-1.0.7.tgz#06a72f251b89389a136d3f177f29b03342adc5ba" + integrity sha512-WDTmLRQUsiioBdTs9BmSEmkJza+8xfJmptsNJjxnoq3EydSa/ZBXT6rm66KoT3PJIRYMnhSKNR7S9YL1l7R40Q== + dependencies: + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + +bip39@3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" + integrity sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ== + dependencies: + "@types/node" "11.11.6" + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + randombytes "^2.0.1" + +bl@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" + integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== + dependencies: + buffer "^5.5.0" + inherits "^2.0.4" + readable-stream "^3.4.0" + +bn.js@5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" + integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== + +bn.js@^4.0.0, bn.js@^4.11.9: + version "4.12.2" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.2.tgz#3d8fed6796c24e177737f7cc5172ee04ef39ec99" + integrity sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw== + +bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: + version "5.2.2" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.2.tgz#82c09f9ebbb17107cd72cb7fd39bd1f9d0aaa566" + integrity sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw== + +borsh@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.6.0.tgz#a7c9eeca6a31ca9e0607cb49f329cb659eb791e1" + integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== + dependencies: + bn.js "^5.2.0" + bs58 "^4.0.0" + text-encoding-utf-8 "^1.0.2" + +borsh@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" + integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== + dependencies: + bn.js "^5.2.0" + bs58 "^4.0.0" + text-encoding-utf-8 "^1.0.2" + +brace-expansion@^1.1.7: + version "1.1.12" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" + integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@~3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + +brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +bs58@^4.0.0, bs58@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== + dependencies: + base-x "^3.0.2" + +bs58@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" + integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== + dependencies: + base-x "^4.0.0" + +buffer-from@^1.0.0, buffer-from@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +buffer-layout@^1.2.0, buffer-layout@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" + integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== + +buffer@6.0.3, buffer@^6.0.2, buffer@^6.0.3, buffer@~6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +buffer@^5.5.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +bufferutil@^4.0.1: + version "4.0.9" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.9.tgz#6e81739ad48a95cad45a279588e13e95e24a800a" + integrity sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw== + dependencies: + node-gyp-build "^4.3.0" + +call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" + integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + +call-bind@^1.0.0, call-bind@^1.0.2, call-bind@^1.0.7, call-bind@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.8.tgz#0736a9660f537e3388826f440d5ec45f744eaa4c" + integrity sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww== + dependencies: + call-bind-apply-helpers "^1.0.0" + es-define-property "^1.0.0" + get-intrinsic "^1.2.4" + set-function-length "^1.2.2" + +call-bound@^1.0.2, call-bound@^1.0.3, call-bound@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.4.tgz#238de935d2a2a692928c538c7ccfa91067fd062a" + integrity sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg== + dependencies: + call-bind-apply-helpers "^1.0.2" + get-intrinsic "^1.3.0" + +camelcase@^6.0.0, camelcase@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +capability@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/capability/-/capability-0.2.5.tgz#51ad87353f1936ffd77f2f21c74633a4dea88801" + integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== + +chai@^4.3.4: + version "4.5.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.5.0.tgz#707e49923afdd9b13a8b0b47d33d732d13812fd8" + integrity sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.3" + deep-eql "^4.1.3" + get-func-name "^2.0.2" + loupe "^2.3.6" + pathval "^1.1.1" + type-detect "^4.1.0" + +chalk-template@=0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/chalk-template/-/chalk-template-0.4.0.tgz#692c034d0ed62436b9062c1707fadcd0f753204b" + integrity sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg== + dependencies: + chalk "^4.1.2" + +chalk@=4.1.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@^5.3.0, chalk@^5.4.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chardet@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-2.1.1.tgz#5c75593704a642f71ee53717df234031e65373c8" + integrity sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ== + +check-error@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.3.tgz#a6502e4312a7ee969f646e83bb3ddd56281bd694" + integrity sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg== + dependencies: + get-func-name "^2.0.2" + +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.7" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.7.tgz#bd094bfef42634ccfd9e13b9fc73274997111e39" + integrity sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA== + dependencies: + inherits "^2.0.4" + safe-buffer "^5.2.1" + to-buffer "^1.2.2" + +cli-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== + dependencies: + restore-cursor "^3.1.0" + +cli-spinners@^2.5.0: + version "2.9.2" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" + integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== + +cli-width@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" + integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" + integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== + +color-convert@=2.0.1, color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@=2.0.0, color-name@^2.0.0, color-name@~1.1.4: + version "2.0.0" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-2.0.0.tgz#03ff6b1b5aec9bb3cf1ed82400c2790dfcd01d2d" + integrity sha512-SbtvAMWvASO5TE2QP07jHBMXKafgdZz8Vrsrn96fiL+O92/FN/PLARzUW5sKt013fjAprK2d2iCn2hk2Xb5oow== + +color-string@=2.1.0, color-string@^1.9.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-2.1.0.tgz#a1cc4bb16a23032ff1048a2458a170323b15a23f" + integrity sha512-gNVoDzpaSwvftp6Y8nqk97FtZoXP9Yj7KGYB8yIXuv0JcfqbYihTrd1OU5iZW9btfXde4YAOCRySBHT7O910MA== + dependencies: + color-name "^2.0.0" + +color@=4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/color/-/color-4.2.3.tgz#d781ecb5e57224ee43ea9627560107c0e0c6463a" + integrity sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A== + dependencies: + color-convert "^2.0.1" + color-string "^1.9.0" + +commander@^12.1.0: + version "12.1.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" + integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== + +commander@^14.0.0: + version "14.0.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.2.tgz#b71fd37fe4069e4c3c7c13925252ada4eba14e8e" + integrity sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ== + +commander@^2.20.3: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +commander@^8.2.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" + integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +create-hash@^1.1.0, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@1.1.7, create-hmac@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" + integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +cross-fetch@^3.1.5: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.2.0.tgz#34e9192f53bc757d6614304d9e5e6fb4edb782e3" + integrity sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q== + dependencies: + node-fetch "^2.7.0" + +crypto-hash@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" + integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== + +csv-generate@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/csv-generate/-/csv-generate-4.5.0.tgz#5fbbb89bd9f8ce705871c9baf02e1d4bb4000fb3" + integrity sha512-aQr/vmOKyBSBHNwYhAoXw1+kUsPnMSwmYgpNoo36rIXoG1ecWILnvPGZeQ6oUjzrWknZAD3+jfpqYOBAl4x15A== + +csv-parse@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-6.1.0.tgz#c642ec5b7fc57c1f477a07d179beb5ff0dfd5ed0" + integrity sha512-CEE+jwpgLn+MmtCpVcPtiCZpVtB6Z2OKPTr34pycYYoL7sxdOkXDdQ4lRiw6ioC0q6BLqhc6cKweCVvral8yhw== + +csv-stringify@^6.6.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-6.6.0.tgz#d384859cfb71d0a4a73c5bcc36a4daf5440cb033" + integrity sha512-YW32lKOmIBgbxtu3g5SaiqWNwa/9ISQt2EcgOq0+RAIFufFp9is6tqNnKahqE5kuKvrnYAzs28r+s6pXJR8Vcw== + +csv@^6.0.5: + version "6.4.1" + resolved "https://registry.yarnpkg.com/csv/-/csv-6.4.1.tgz#c9a62130c025f8adb2a85a75d4c2608612995822" + integrity sha512-ajGosmTGnTwYyGl8STqZDu7R6LkDf3xL39XiOmliV/GufQeVUxHzTKIm4NOBCwmEuujK7B6isxs4Uqt9GcRCvA== + dependencies: + csv-generate "^4.5.0" + csv-parse "^6.1.0" + csv-stringify "^6.6.0" + stream-transform "^3.4.0" + +debug@4.3.3, debug@=4.4.1, debug@^4.3.3, debug@^4.3.4: + version "4.4.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" + integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ== + dependencies: + ms "^2.1.3" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +decimal.js@^10.4.3: + version "10.6.0" + resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.6.0.tgz#e649a43e3ab953a72192ff5983865e509f37ed9a" + integrity sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg== + +deep-eql@^4.1.3: + version "4.1.4" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.4.tgz#d0d3912865911bb8fac5afb4e3acfa6a28dc72b7" + integrity sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg== + dependencies: + type-detect "^4.0.0" + +defaults@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" + integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== + dependencies: + clone "^1.0.2" + +define-data-property@^1.0.1, define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +define-properties@^1.1.3, define-properties@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" + integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== + dependencies: + define-data-property "^1.0.1" + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + +delay@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" + integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== + +depd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +dot-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" + integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== + dependencies: + no-case "^3.0.4" + tslib "^2.0.3" + +dunder-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" + integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== + dependencies: + call-bind-apply-helpers "^1.0.1" + es-errors "^1.3.0" + gopd "^1.2.0" + +elliptic@6.6.1, elliptic@^6.5.7: + version "6.6.1" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" + integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +error-ex@=1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +error-polyfill@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/error-polyfill/-/error-polyfill-0.1.3.tgz#df848b61ad8834f7a5db69a70b9913df86721d15" + integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== + dependencies: + capability "^0.2.5" + o3 "^1.0.3" + u3 "^0.1.1" + +es-define-property@^1.0.0, es-define-property@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" + integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz#1c4f2c4837327597ce69d2ca190a7fdd172338c1" + integrity sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA== + dependencies: + es-errors "^1.3.0" + +es6-promise@^4.0.3: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ== + dependencies: + es6-promise "^4.0.3" + +esbuild@^0.17.15: + version "0.17.19" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" + integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== + optionalDependencies: + "@esbuild/android-arm" "0.17.19" + "@esbuild/android-arm64" "0.17.19" + "@esbuild/android-x64" "0.17.19" + "@esbuild/darwin-arm64" "0.17.19" + "@esbuild/darwin-x64" "0.17.19" + "@esbuild/freebsd-arm64" "0.17.19" + "@esbuild/freebsd-x64" "0.17.19" + "@esbuild/linux-arm" "0.17.19" + "@esbuild/linux-arm64" "0.17.19" + "@esbuild/linux-ia32" "0.17.19" + "@esbuild/linux-loong64" "0.17.19" + "@esbuild/linux-mips64el" "0.17.19" + "@esbuild/linux-ppc64" "0.17.19" + "@esbuild/linux-riscv64" "0.17.19" + "@esbuild/linux-s390x" "0.17.19" + "@esbuild/linux-x64" "0.17.19" + "@esbuild/netbsd-x64" "0.17.19" + "@esbuild/openbsd-x64" "0.17.19" + "@esbuild/sunos-x64" "0.17.19" + "@esbuild/win32-arm64" "0.17.19" + "@esbuild/win32-ia32" "0.17.19" + "@esbuild/win32-x64" "0.17.19" + +escalade@^3.1.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +ethers@^5.5.1: + version "5.8.0" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.8.0.tgz#97858dc4d4c74afce83ea7562fe9493cedb4d377" + integrity sha512-DUq+7fHrCg1aPDFCHx6UIPb3nmt2XMpM7Y/g2gLhsl3lIBqeAfOJIl1qEvRf2uq3BiKxmh6Fh5pfp2ieyek7Kg== + dependencies: + "@ethersproject/abi" "5.8.0" + "@ethersproject/abstract-provider" "5.8.0" + "@ethersproject/abstract-signer" "5.8.0" + "@ethersproject/address" "5.8.0" + "@ethersproject/base64" "5.8.0" + "@ethersproject/basex" "5.8.0" + "@ethersproject/bignumber" "5.8.0" + "@ethersproject/bytes" "5.8.0" + "@ethersproject/constants" "5.8.0" + "@ethersproject/contracts" "5.8.0" + "@ethersproject/hash" "5.8.0" + "@ethersproject/hdnode" "5.8.0" + "@ethersproject/json-wallets" "5.8.0" + "@ethersproject/keccak256" "5.8.0" + "@ethersproject/logger" "5.8.0" + "@ethersproject/networks" "5.8.0" + "@ethersproject/pbkdf2" "5.8.0" + "@ethersproject/properties" "5.8.0" + "@ethersproject/providers" "5.8.0" + "@ethersproject/random" "5.8.0" + "@ethersproject/rlp" "5.8.0" + "@ethersproject/sha2" "5.8.0" + "@ethersproject/signing-key" "5.8.0" + "@ethersproject/solidity" "5.8.0" + "@ethersproject/strings" "5.8.0" + "@ethersproject/transactions" "5.8.0" + "@ethersproject/units" "5.8.0" + "@ethersproject/wallet" "5.8.0" + "@ethersproject/web" "5.8.0" + "@ethersproject/wordlists" "5.8.0" + +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + +exponential-backoff@^3.1.0: + version "3.1.3" + resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.3.tgz#51cf92c1c0493c766053f9d3abee4434c244d2f6" + integrity sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA== + +eyes@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" + integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ== + +fast-stable-stringify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" + integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== + +figures@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" + integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== + dependencies: + escape-string-regexp "^1.0.5" + +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +follow-redirects@^1.14.0, follow-redirects@^1.14.7: + version "1.15.11" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340" + integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ== + +for-each@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.5.tgz#d650688027826920feeb0af747ee7b9421a41d47" + integrity sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg== + dependencies: + is-callable "^1.2.7" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +generator-function@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/generator-function/-/generator-function-2.0.1.tgz#0e75dd410d1243687a0ba2e951b94eedb8f737a2" + integrity sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-func-name@^2.0.1, get-func-name@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" + integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== + +get-intrinsic@^1.2.4, get-intrinsic@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" + integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== + dependencies: + call-bind-apply-helpers "^1.0.2" + es-define-property "^1.0.1" + es-errors "^1.3.0" + es-object-atoms "^1.1.1" + function-bind "^1.1.2" + get-proto "^1.0.1" + gopd "^1.2.0" + has-symbols "^1.1.0" + hasown "^2.0.2" + math-intrinsics "^1.1.0" + +get-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" + integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== + dependencies: + dunder-proto "^1.0.1" + es-object-atoms "^1.0.0" + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +gopd@^1.0.1, gopd@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" + integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== + +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + +has-ansi@=4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-4.0.1.tgz#f216a8c8d7b129e490dc15f4a62cc1cdb9603ce8" + integrity sha512-Qr4RtTm30xvEdqUXbSBVWDu+PrTokJOwe/FU+VdfJPk+MXAPoeOzKpRyrDTnZIJwAkQ4oBLTU53nu0HrkF/Z2A== + dependencies: + ansi-regex "^4.1.0" + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-symbols@^1.0.3, has-symbols@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" + integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== + +has-tostringtag@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" + integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== + dependencies: + has-symbols "^1.0.3" + +hash-base@^3.0.0, hash-base@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.2.tgz#79d72def7611c3f6e3c3b5730652638001b10a74" + integrity sha512-Bb33KbowVTIj5s7Ked1OsqHUeCpz//tPwR+E2zJgJKo9Z5XolZ9b6bdUgjmYlwnWhoOQKoTd1TYToZGn5mAYOg== + dependencies: + inherits "^2.0.4" + readable-stream "^2.3.8" + safe-buffer "^5.2.1" + to-buffer "^1.2.1" + +hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +hasown@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +hi-base32@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/hi-base32/-/hi-base32-0.5.1.tgz#1279f2ddae2673219ea5870c2121d2a33132857e" + integrity sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA== + +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + +http-errors@^1.7.2: + version "1.8.1" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" + integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== + dependencies: + depd "~1.1.2" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.1" + +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== + dependencies: + ms "^2.0.0" + +iconv-lite@^0.7.0: + version "0.7.1" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.7.1.tgz#d4af1d2092f2bb05aab6296e5e7cd286d2f15432" + integrity sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +ieee754@^1.1.13, ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inquirer@^8.2.0: + version "8.2.7" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.2.7.tgz#62f6b931a9b7f8735dc42db927316d8fb6f71de8" + integrity sha512-UjOaSel/iddGZJ5xP/Eixh6dY1XghiBw4XK13rCCIJcJfyhhoul/7KhLLUGtebEj6GDYM6Vnx/mVsjx2L/mFIA== + dependencies: + "@inquirer/external-editor" "^1.0.0" + ansi-escapes "^4.2.1" + chalk "^4.1.1" + cli-cursor "^3.1.0" + cli-width "^3.0.0" + figures "^3.0.0" + lodash "^4.17.21" + mute-stream "0.0.8" + ora "^5.4.1" + run-async "^2.4.0" + rxjs "^7.5.5" + string-width "^4.1.0" + strip-ansi "^6.0.0" + through "^2.3.6" + wrap-ansi "^6.0.1" + +invariant@2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + +is-arguments@^1.0.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.2.0.tgz#ad58c6aecf563b78ef2bf04df540da8f5d7d8e1b" + integrity sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA== + dependencies: + call-bound "^1.0.2" + has-tostringtag "^1.0.2" + +is-arrayish@=0.3.2, is-arrayish@^0.2.1, is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-fullwidth-code-point@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" + integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== + +is-generator-function@^1.0.7: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.2.tgz#ae3b61e3d5ea4e4839b90bad22b02335051a17d5" + integrity sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA== + dependencies: + call-bound "^1.0.4" + generator-function "^2.0.0" + get-proto "^1.0.1" + has-tostringtag "^1.0.2" + safe-regex-test "^1.1.0" + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-interactive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" + integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w== + +is-nan@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" + integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-regex@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.2.1.tgz#76d70a3ed10ef9be48eb577887d74205bf0cad22" + integrity sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g== + dependencies: + call-bound "^1.0.2" + gopd "^1.2.0" + has-tostringtag "^1.0.2" + hasown "^2.0.2" + +is-typed-array@^1.1.14, is-typed-array@^1.1.3: + version "1.1.15" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" + integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== + dependencies: + which-typed-array "^1.1.16" + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isomorphic-ws@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" + integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== + +jayson@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.2.0.tgz#b71762393fa40bc9637eaf734ca6f40d3b8c0c93" + integrity sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg== + dependencies: + "@types/connect" "^3.4.33" + "@types/node" "^12.12.54" + "@types/ws" "^7.4.4" + commander "^2.20.3" + delay "^5.0.0" + es6-promisify "^5.0.0" + eyes "^0.1.8" + isomorphic-ws "^4.0.1" + json-stringify-safe "^5.0.1" + stream-json "^1.9.1" + uuid "^8.3.2" + ws "^7.5.10" + +js-sha256@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" + integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== + +js-sha3@0.8.0, js-sha3@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + +js-sha512@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4" + integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ== + +"js-tokens@^3.0.0 || ^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" + integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== + dependencies: + bignumber.js "^9.0.0" + +json-stringify-safe@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== + +json5@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== + dependencies: + minimist "^1.2.0" + +keccak@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" + integrity sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@4.1.0, log-symbols@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + +loupe@^2.3.6: + version "2.3.7" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.7.tgz#6e69b7d4db7d3ab436328013d37d1c8c3540c697" + integrity sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA== + dependencies: + get-func-name "^2.0.1" + +lower-case@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" + integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== + dependencies: + tslib "^2.0.3" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +math-intrinsics@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" + integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== + +minimatch@4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" + integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@^9.0.3: + version "9.2.2" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" + integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.3" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" + growl "1.10.5" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "4.2.1" + ms "2.1.3" + nanoid "3.3.1" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + which "2.0.2" + workerpool "6.2.0" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.1.3, ms@^2.0.0, ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multistream@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8" + integrity sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw== + dependencies: + once "^1.4.0" + readable-stream "^3.6.0" + +mustache@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" + integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== + +mute-stream@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" + integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== + +nanoid@3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" + integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== + +near-api-js@^0.44.2: + version "0.44.2" + resolved "https://registry.yarnpkg.com/near-api-js/-/near-api-js-0.44.2.tgz#e451f68f2c56bd885c7b918db5818a3e6e9423d0" + integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== + dependencies: + bn.js "5.2.0" + borsh "^0.6.0" + bs58 "^4.0.0" + depd "^2.0.0" + error-polyfill "^0.1.3" + http-errors "^1.7.2" + js-sha256 "^0.9.0" + mustache "^4.0.0" + node-fetch "^2.6.1" + text-encoding-utf-8 "^1.0.2" + tweetnacl "^1.0.1" + +near-hd-key@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/near-hd-key/-/near-hd-key-1.2.1.tgz#f508ff15436cf8a439b543220f3cc72188a46756" + integrity sha512-SIrthcL5Wc0sps+2e1xGj3zceEa68TgNZDLuCx0daxmfTP7sFTB3/mtE2pYhlFsCxWoMn+JfID5E1NlzvvbRJg== + dependencies: + bip39 "3.0.2" + create-hmac "1.1.7" + tweetnacl "1.0.3" + +near-seed-phrase@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/near-seed-phrase/-/near-seed-phrase-0.2.1.tgz#7d5b54d5e836d295f10b0bdfdae9086443651d20" + integrity sha512-feMuums+kVL3LSuPcP4ld07xHCb2mu6z48SGfP3W+8tl1Qm5xIcjiQzY2IDPBvFgajRDxWSb8GzsRHoInazByw== + dependencies: + bip39-light "^1.0.7" + bs58 "^4.0.1" + near-hd-key "^1.2.1" + tweetnacl "^1.0.2" + +no-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" + integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== + dependencies: + lower-case "^2.0.2" + tslib "^2.0.3" + +node-addon-api@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" + integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== + +node-addon-api@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" + integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== + +node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: + version "4.8.4" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.4.tgz#8a70ee85464ae52327772a90d66c6077a900cfc8" + integrity sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +o3@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/o3/-/o3-1.0.3.tgz#192ce877a882dfa6751f0412a865fafb2da1dac0" + integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== + dependencies: + capability "^0.2.5" + +object-is@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.6.tgz#1a6a53aed2dd8f7e6775ff870bea58545956ab07" + integrity sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q== + dependencies: + call-bind "^1.0.7" + define-properties "^1.2.1" + +object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object.assign@^4.1.4: + version "4.1.7" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.7.tgz#8c14ca1a424c6a561b0bb2a22f66f5049a945d3d" + integrity sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.3" + define-properties "^1.2.1" + es-object-atoms "^1.0.0" + has-symbols "^1.1.0" + object-keys "^1.1.1" + +once@^1.3.0, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +ora@^5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18" + integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ== + dependencies: + bl "^4.1.0" + chalk "^4.1.0" + cli-cursor "^3.1.0" + cli-spinners "^2.5.0" + is-interactive "^1.0.0" + is-unicode-supported "^0.1.0" + log-symbols "^4.1.0" + strip-ansi "^6.0.0" + wcwidth "^1.0.1" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +pako@^2.0.3: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== + +pbkdf2@^3.0.9: + version "3.1.5" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.5.tgz#444a59d7a259a95536c56e80c89de31cc01ed366" + integrity sha512-Q3CG/cYvCO1ye4QKkuH7EXxs3VC/rI1/trd+qX2+PolbaKG0H+bgcZzrTt96mMyRtejk+JMCiLUn3y29W8qmFQ== + dependencies: + create-hash "^1.2.0" + create-hmac "^1.1.7" + ripemd160 "^2.0.3" + safe-buffer "^5.2.1" + sha.js "^2.4.12" + to-buffer "^1.2.1" + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +possible-typed-array-names@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae" + integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg== + +prettier@3.6.2: + version "3.6.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393" + integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ== + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== + +randombytes@^2.0.1, randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +readable-stream@^2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" + integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.4.0, readable-stream@^3.6.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + +retry@0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + +ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.3.tgz#9be54e4ba5e3559c8eee06a25cd7648bbccdf5a8" + integrity sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA== + dependencies: + hash-base "^3.1.2" + inherits "^2.0.4" + +rpc-websockets@^9.0.2: + version "9.3.2" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.3.2.tgz#26b4d7ebaf8e53422528619a3c314e83590d85bf" + integrity sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA== + dependencies: + "@swc/helpers" "^0.5.11" + "@types/uuid" "^8.3.4" + "@types/ws" "^8.2.2" + buffer "^6.0.3" + eventemitter3 "^5.0.1" + uuid "^8.3.2" + ws "^8.5.0" + optionalDependencies: + bufferutil "^4.0.1" + utf-8-validate "^5.0.2" + +run-async@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" + integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== + +rxjs@^7.5.5: + version "7.8.2" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.2.tgz#955bc473ed8af11a002a2be52071bf475638607b" + integrity sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA== + dependencies: + tslib "^2.1.0" + +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-regex-test@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" + integrity sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw== + dependencies: + call-bound "^1.0.2" + es-errors "^1.3.0" + is-regex "^1.2.1" + +"safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +scrypt-js@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" + integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== + +secp256k1@^4.0.2: + version "4.0.4" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.4.tgz#58f0bfe1830fe777d9ca1ffc7574962a8189f8ab" + integrity sha512-6JfvwvjUOn8F/jUoBY2Q1v5WY5XS+rj8qSe0v8Y4ezH4InLgTEeOOPQsRll9OV429Pvo6BCHGavIyJfr3TAhsw== + dependencies: + elliptic "^6.5.7" + node-addon-api "^5.0.0" + node-gyp-build "^4.2.0" + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +set-function-length@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +sha.js@^2.4.0, sha.js@^2.4.12, sha.js@^2.4.8: + version "2.4.12" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.12.tgz#eb8b568bf383dfd1867a32c3f2b74eb52bdbf23f" + integrity sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w== + dependencies: + inherits "^2.0.4" + safe-buffer "^5.2.1" + to-buffer "^1.2.0" + +signal-exit@^3.0.2: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +simple-swizzle@=0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg== + dependencies: + is-arrayish "^0.3.1" + +slice-ansi@=5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" + integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== + dependencies: + ansi-styles "^6.0.0" + is-fullwidth-code-point "^4.0.0" + +snake-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" + integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== + dependencies: + dot-case "^3.0.4" + tslib "^2.0.3" + +solana-bankrun-darwin-arm64@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.2.0.tgz#747e27f38e30d9022c9cccdead2e8d37cf006d55" + integrity sha512-ENQ5Z/CYeY8ZVWIc2VutY/gMlBaHi93/kDw9w0iVwewoV+/YpQmP2irwrshIKu6ggRPTF3Ehlh2V6fGVIYWcXw== + +solana-bankrun-darwin-universal@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.2.0.tgz#5b325b49578d7a9d74b02f7a05741658e46fd073" + integrity sha512-HE45TvZXzBipm1fMn87+fkHeIuQ/KFAi5G/S29y/TLuBYt4RDI935RkWiT0rEQ7KwnwO6Y1aTsOaQXldY5R7uQ== + +solana-bankrun-darwin-x64@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.2.0.tgz#d03eafd69c8dd9a53c84e993660c67cc71d531de" + integrity sha512-42UsVrnac2Oo4UaIDo60zfI3Xn1i8W6fmcc9ixJQZNTtdO8o2/sY4mFxcJx9lhLMhda5FPHrQbGYgYdIs0kK0g== + +solana-bankrun-linux-x64-gnu@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.2.0.tgz#eb133902e78afc5271ba034bd5353ad5f4005c10" + integrity sha512-WnqQjfBBdcI0ZLysjvRStI8gX7vm1c3CI6CC03lgkUztH+Chcq9C4LI9m2M8mXza8Xkn9ryeKAmX36Bx/yoVzg== + +solana-bankrun-linux-x64-musl@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.2.0.tgz#a99c5187f34ab5979c708281da74093c64baab4a" + integrity sha512-8mtf14ZBoah30+MIJBUwb5BlGLRZyK5cZhCkYnC/ROqaIDN8RxMM44NL63gTUIaNHsFwWGA9xR0KSeljeh3PKQ== + +solana-bankrun@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.2.0.tgz#e1df2126ee887b9eae17962f09db18aaa25d736f" + integrity sha512-TS6vYoO/9YJZng7oiLOVyuz8V7yLow5Hp4SLYWW71XM3702v+z9f1fvUBKudRfa4dfpta4tRNufApSiBIALxJQ== + dependencies: + "@solana/web3.js" "^1.68.0" + bs58 "^4.0.1" + optionalDependencies: + solana-bankrun-darwin-arm64 "0.2.0" + solana-bankrun-darwin-universal "0.2.0" + solana-bankrun-darwin-x64 "0.2.0" + solana-bankrun-linux-x64-gnu "0.2.0" + solana-bankrun-linux-x64-musl "0.2.0" + +source-map-support@^0.5.6: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spl-token-bankrun@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/spl-token-bankrun/-/spl-token-bankrun-0.2.3.tgz#929e7ea8872ad4f2065d97b185b8cb1b92b2366d" + integrity sha512-jQ0V+2GsL6rMrZfqLSbYBtYc5EvdVgsgVeYsZlJLRqrBoVENGve6oDAnJnuiY8JMXGxUs53iYYhG871knI7Vww== + dependencies: + "@solana/spl-token" "^0.3.8" + solana-bankrun "^0.2.0" + +"statuses@>= 1.5.0 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== + +stream-chain@^2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/stream-chain/-/stream-chain-2.2.5.tgz#b30967e8f14ee033c5b9a19bbe8a2cba90ba0d09" + integrity sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA== + +stream-json@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/stream-json/-/stream-json-1.9.1.tgz#e3fec03e984a503718946c170db7d74556c2a187" + integrity sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw== + dependencies: + stream-chain "^2.2.5" + +stream-transform@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/stream-transform/-/stream-transform-3.4.0.tgz#38d562fbdad38c3b6cda959ad36751014bb26e18" + integrity sha512-QO3OGhKyeIV8p6eRQdG+W6WounFw519zk690hHCNfhgfP9bylVS+NTXsuBc7n+RsGn31UgFPGrWYIgoAbArKEw== + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@=6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +superstruct@^0.15.4: + version "0.15.5" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" + integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== + +superstruct@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54" + integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A== + +supports-color@8.1.1, supports-color@=7.2.0, supports-color@^7.0.0, supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-hyperlinks@=2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" + integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== + dependencies: + has-flag "^4.0.0" + supports-color "^7.0.0" + +text-encoding-utf-8@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" + integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== + +through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== + +tmp-promise@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.3.tgz#60a1a1cc98c988674fcbfd23b6e3367bdeac4ce7" + integrity sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ== + dependencies: + tmp "^0.2.0" + +tmp@^0.2.0: + version "0.2.5" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" + integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== + +to-buffer@^1.2.0, to-buffer@^1.2.1, to-buffer@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.2.2.tgz#ffe59ef7522ada0a2d1cb5dfe03bb8abc3cdc133" + integrity sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw== + dependencies: + isarray "^2.0.5" + safe-buffer "^5.2.1" + typed-array-buffer "^1.0.3" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +toml@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" + integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +ts-mocha@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.1.0.tgz#17a1c055f5f7733fd82447c4420740db87221bc8" + integrity sha512-T0C0Xm3/WqCuF2tpa0GNGESTBoKZaiqdUP8guNv4ZY316AFXlyidnrzQ1LUrCT0Wb1i3J0zFTgOh/55Un44WdA== + dependencies: + ts-node "7.0.1" + optionalDependencies: + tsconfig-paths "^3.5.0" + +ts-node@7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" + integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== + dependencies: + arrify "^1.0.0" + buffer-from "^1.1.0" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.5.6" + yn "^2.0.0" + +tsconfig-paths@^3.5.0: + version "3.15.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz#5299ec605e55b1abb23ec939ef15edaf483070d4" + integrity sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + +tslib@^2.0.3, tslib@^2.1.0, tslib@^2.8.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + +tweetnacl@1.0.3, tweetnacl@^1.0.1, tweetnacl@^1.0.2, tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + +type-detect@^4.0.0, type-detect@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.1.0.tgz#deb2453e8f08dcae7ae98c626b13dddb0155906c" + integrity sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw== + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +typed-array-buffer@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536" + integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw== + dependencies: + call-bound "^1.0.3" + es-errors "^1.3.0" + is-typed-array "^1.1.14" + +typescript@^5.5.5: + version "5.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== + +u3@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/u3/-/u3-0.1.1.tgz#5f52044f42ee76cd8de33148829e14528494b73b" + integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== + +undici-types@~7.16.0: + version "7.16.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" + integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== + +utf-8-validate@^5.0.2: + version "5.0.10" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" + integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== + dependencies: + node-gyp-build "^4.3.0" + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +util@^0.12.5: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +vlq@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/vlq/-/vlq-2.0.4.tgz#6057b85729245b9829e3cc7755f95b228d4fe041" + integrity sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA== + +wcwidth@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" + integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== + dependencies: + defaults "^1.0.3" + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +which-typed-array@^1.1.16, which-typed-array@^1.1.2: + version "1.1.19" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.19.tgz#df03842e870b6b88e117524a4b364b6fc689f956" + integrity sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw== + dependencies: + available-typed-arrays "^1.0.7" + call-bind "^1.0.8" + call-bound "^1.0.4" + for-each "^0.3.5" + get-proto "^1.0.1" + gopd "^1.2.0" + has-tostringtag "^1.0.2" + +which@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +workerpool@6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" + integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== + +wrap-ansi@=7.0.0, wrap-ansi@^6.0.1, wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +ws@8.18.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" + integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== + +ws@^7.5.10: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + +ws@^8.5.0: + version "8.18.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" + integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 03ca7d474366226fbb1a781701dab960ce159061 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 25 Mar 2026 00:33:32 +0100 Subject: [PATCH 026/100] add more programs to new SDK --- sdk2/src/bid_wall/index.ts | 1 + sdk2/src/bid_wall/v0.7/BidWallClient.ts | 318 ++ sdk2/src/bid_wall/v0.7/index.ts | 3 + sdk2/src/bid_wall/v0.7/pda.ts | 25 + sdk2/src/bid_wall/v0.7/types/bid_wall.ts | 1435 ++++++ sdk2/src/bid_wall/v0.7/types/index.ts | 24 + sdk2/src/constants.ts | 6 +- sdk2/src/launchpad/index.ts | 1 + sdk2/src/launchpad/v0.7/LaunchpadClient.ts | 741 +++ sdk2/src/launchpad/v0.7/index.ts | 1 + sdk2/src/launchpad/v0.7/pda.ts | 33 + sdk2/src/launchpad/v0.7/types/index.ts | 40 + sdk2/src/launchpad/v0.7/types/launchpad_v7.ts | 4069 +++++++++++++++++ sdk2/src/liquidation/index.ts | 1 + .../src/liquidation/v0.7/LiquidationClient.ts | 335 ++ sdk2/src/liquidation/v0.7/index.ts | 2 + sdk2/src/liquidation/v0.7/pda.ts | 43 + sdk2/src/liquidation/v0.7/types/index.ts | 12 + .../src/liquidation/v0.7/types/liquidation.ts | 1515 ++++++ sdk2/src/mint_governor/index.ts | 1 + .../mint_governor/v0.7/MintGovernorClient.ts | 251 + sdk2/src/mint_governor/v0.7/index.ts | 3 + sdk2/src/mint_governor/v0.7/pda.ts | 36 + sdk2/src/mint_governor/v0.7/types/index.ts | 37 + .../mint_governor/v0.7/types/mint_governor.ts | 1473 ++++++ .../price_based_performance_package/index.ts | 1 + .../PriceBasedPerformancePackageClient.ts | 225 + .../v0.6/index.ts | 3 + .../v0.6/pda.ts | 38 + .../v0.6/types/index.ts | 35 + .../types/price_based_performance_package.ts | 1941 ++++++++ 31 files changed, 12646 insertions(+), 3 deletions(-) create mode 100644 sdk2/src/bid_wall/index.ts create mode 100644 sdk2/src/bid_wall/v0.7/BidWallClient.ts create mode 100644 sdk2/src/bid_wall/v0.7/index.ts create mode 100644 sdk2/src/bid_wall/v0.7/pda.ts create mode 100644 sdk2/src/bid_wall/v0.7/types/bid_wall.ts create mode 100644 sdk2/src/bid_wall/v0.7/types/index.ts create mode 100644 sdk2/src/launchpad/index.ts create mode 100644 sdk2/src/launchpad/v0.7/LaunchpadClient.ts create mode 100644 sdk2/src/launchpad/v0.7/index.ts create mode 100644 sdk2/src/launchpad/v0.7/pda.ts create mode 100644 sdk2/src/launchpad/v0.7/types/index.ts create mode 100644 sdk2/src/launchpad/v0.7/types/launchpad_v7.ts create mode 100644 sdk2/src/liquidation/index.ts create mode 100644 sdk2/src/liquidation/v0.7/LiquidationClient.ts create mode 100644 sdk2/src/liquidation/v0.7/index.ts create mode 100644 sdk2/src/liquidation/v0.7/pda.ts create mode 100644 sdk2/src/liquidation/v0.7/types/index.ts create mode 100644 sdk2/src/liquidation/v0.7/types/liquidation.ts create mode 100644 sdk2/src/mint_governor/index.ts create mode 100644 sdk2/src/mint_governor/v0.7/MintGovernorClient.ts create mode 100644 sdk2/src/mint_governor/v0.7/index.ts create mode 100644 sdk2/src/mint_governor/v0.7/pda.ts create mode 100644 sdk2/src/mint_governor/v0.7/types/index.ts create mode 100644 sdk2/src/mint_governor/v0.7/types/mint_governor.ts create mode 100644 sdk2/src/price_based_performance_package/index.ts create mode 100644 sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts create mode 100644 sdk2/src/price_based_performance_package/v0.6/index.ts create mode 100644 sdk2/src/price_based_performance_package/v0.6/pda.ts create mode 100644 sdk2/src/price_based_performance_package/v0.6/types/index.ts create mode 100644 sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts diff --git a/sdk2/src/bid_wall/index.ts b/sdk2/src/bid_wall/index.ts new file mode 100644 index 000000000..6b187d27b --- /dev/null +++ b/sdk2/src/bid_wall/index.ts @@ -0,0 +1 @@ +export * from "./v0.7/index.js"; diff --git a/sdk2/src/bid_wall/v0.7/BidWallClient.ts b/sdk2/src/bid_wall/v0.7/BidWallClient.ts new file mode 100644 index 000000000..da56f78ee --- /dev/null +++ b/sdk2/src/bid_wall/v0.7/BidWallClient.ts @@ -0,0 +1,318 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; +import { + MAINNET_USDC, + BID_WALL_V0_7_PROGRAM_ID, + METADAO_MULTISIG_VAULT, +} from "../../constants.js"; +import { BidWallProgram, BidWallIDL, BidWall } from "./types/index.js"; +import BN from "bn.js"; +import { + ASSOCIATED_TOKEN_PROGRAM_ID, + getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { getBidWallAddr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; + +export type CreateBidWallClientParams = { + provider: AnchorProvider; + bidWallProgramId?: PublicKey; +}; + +export class BidWallClient { + public readonly provider: AnchorProvider; + public readonly bidWallProgram: Program; + public readonly programId: PublicKey; + + constructor(provider: AnchorProvider, bidWallProgramId: PublicKey) { + this.provider = provider; + this.programId = bidWallProgramId; + this.bidWallProgram = new Program( + BidWallIDL, + bidWallProgramId, + provider, + ); + } + + public static createClient( + createBidWallClientParams: CreateBidWallClientParams, + ): BidWallClient { + let { provider, bidWallProgramId } = createBidWallClientParams; + + return new BidWallClient( + provider, + bidWallProgramId || BID_WALL_V0_7_PROGRAM_ID, + ); + } + + async fetchBidWall(bidWall: PublicKey): Promise { + return this.bidWallProgram.account.bidWall.fetchNullable(bidWall); + } + + async deserializeBidWall(accountInfo: AccountInfo): Promise { + return this.bidWallProgram.coder.accounts.decode( + "bidWall", + accountInfo.data, + ); + } + + initializeBidWallIx({ + amount, + durationSeconds, + initialAmmQuoteReserves, + daoTreasury, + authority, + baseMint, + creator = this.provider.publicKey, + nonce = new BN(0), + feeRecipient = METADAO_MULTISIG_VAULT, + quoteMint = MAINNET_USDC, + payer = this.provider.publicKey, + }: { + amount: number; + durationSeconds: number; + initialAmmQuoteReserves: number; + daoTreasury: PublicKey; + creator?: PublicKey; + nonce?: BN; + authority?: PublicKey; + baseMint: PublicKey; + feeRecipient?: PublicKey; + quoteMint?: PublicKey; + payer?: PublicKey; + }) { + const [bidWall] = getBidWallAddr({ creator, baseMint, nonce }); + + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + + const creatorQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + creator, + true, + ); + + return this.bidWallProgram.methods + .initializeBidWall({ + amount: new BN(amount), + nonce, + durationSeconds, + initialAmmQuoteReserves: new BN(initialAmmQuoteReserves), + }) + .accounts({ + bidWall, + payer, + bidWallQuoteTokenAccount, + creator, + creatorQuoteTokenAccount, + authority: authority ?? creator, + baseMint, + quoteMint, + feeRecipient, + daoTreasury, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }); + } + + sellTokensIx({ + amount, + minAmountOut = 0, + bidWall, + baseMint, + daoTreasury, + quoteMint = MAINNET_USDC, + user = this.provider.publicKey, + }: { + amount: number; + minAmountOut?: number; + bidWall: PublicKey; + baseMint: PublicKey; + daoTreasury: PublicKey; + quoteMint: PublicKey; + user: PublicKey; + }) { + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + + const userTokenAccount = getAssociatedTokenAddressSync( + baseMint, + user, + true, + ); + + const userQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + user, + true, + ); + + const daoTreasuryQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + daoTreasury, + true, + ); + + return this.bidWallProgram.methods + .sellTokens({ + amountIn: new BN(amount), + minAmountOut: new BN(minAmountOut), + }) + .accounts({ + bidWall, + user, + userTokenAccount, + userQuoteTokenAccount, + bidWallQuoteTokenAccount, + baseMint, + quoteMint, + daoTreasury, + daoTreasuryQuoteTokenAccount, + tokenProgram: TOKEN_PROGRAM_ID, + }); + } + + collectFeesIx({ + bidWall, + admin = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + bidWall: PublicKey; + admin?: PublicKey; + quoteMint?: PublicKey; + }) { + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + + const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + METADAO_MULTISIG_VAULT, + true, + ); + + return this.bidWallProgram.methods.collectFees().accounts({ + bidWall, + cranker: admin, + bidWallQuoteTokenAccount, + feeRecipientQuoteTokenAccount, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + }); + } + + closeBidWallIx({ + bidWall, + authority, + baseMint, + feeRecipient = METADAO_MULTISIG_VAULT, + quoteMint = MAINNET_USDC, + }: { + bidWall: PublicKey; + authority: PublicKey; + baseMint: PublicKey; + feeRecipient: PublicKey; + quoteMint: PublicKey; + }) { + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + const authorityQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + authority, + true, + ); + const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + feeRecipient, + true, + ); + + return this.bidWallProgram.methods.closeBidWall().accounts({ + bidWall, + authority, + feeRecipient, + bidWallQuoteTokenAccount, + authorityQuoteTokenAccount, + feeRecipientQuoteTokenAccount, + baseMint, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }); + } + + cancelBidWallIx({ + bidWall, + authority, + baseMint, + feeRecipient = METADAO_MULTISIG_VAULT, + quoteMint = MAINNET_USDC, + payer = this.provider.publicKey, + }: { + bidWall: PublicKey; + authority: PublicKey; + baseMint: PublicKey; + feeRecipient: PublicKey; + quoteMint: PublicKey; + payer: PublicKey; + }) { + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + const authorityQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + authority, + true, + ); + const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + feeRecipient, + true, + ); + + return this.bidWallProgram.methods.cancelBidWall().accounts({ + bidWall, + payer, + authority, + feeRecipient, + bidWallQuoteTokenAccount, + authorityQuoteTokenAccount, + feeRecipientQuoteTokenAccount, + baseMint, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }); + } + + public getBidWallAddress({ + baseMint, + creator, + nonce, + }: { + baseMint: PublicKey; + creator: PublicKey; + nonce: BN; + }): PublicKey { + return getBidWallAddr({ baseMint, creator, nonce })[0]; + } + + public getEventAuthorityAddress(): PublicKey { + return getEventAuthorityAddr(this.programId)[0]; + } +} diff --git a/sdk2/src/bid_wall/v0.7/index.ts b/sdk2/src/bid_wall/v0.7/index.ts new file mode 100644 index 000000000..c0cf6aaff --- /dev/null +++ b/sdk2/src/bid_wall/v0.7/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./BidWallClient.js"; diff --git a/sdk2/src/bid_wall/v0.7/pda.ts b/sdk2/src/bid_wall/v0.7/pda.ts new file mode 100644 index 000000000..a599a3d90 --- /dev/null +++ b/sdk2/src/bid_wall/v0.7/pda.ts @@ -0,0 +1,25 @@ +import { BN } from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; +import { BID_WALL_V0_7_PROGRAM_ID } from "../../constants.js"; + +export const getBidWallAddr = ({ + programId = BID_WALL_V0_7_PROGRAM_ID, + baseMint, + creator, + nonce, +}: { + programId?: PublicKey; + baseMint: PublicKey; + creator: PublicKey; + nonce: BN; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("bid_wall"), + baseMint.toBuffer(), + creator.toBuffer(), + nonce.toArrayLike(Buffer, "le", 8), + ], + programId, + ); +}; diff --git a/sdk2/src/bid_wall/v0.7/types/bid_wall.ts b/sdk2/src/bid_wall/v0.7/types/bid_wall.ts new file mode 100644 index 000000000..d54b464bd --- /dev/null +++ b/sdk2/src/bid_wall/v0.7/types/bid_wall.ts @@ -0,0 +1,1435 @@ +export type BidWall = { + version: "0.7.0"; + name: "bid_wall"; + instructions: [ + { + name: "initializeBidWall"; + accounts: [ + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "creator"; + isMut: false; + isSigner: true; + }, + { + name: "authority"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "creatorQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "daoTreasury"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeBidWallArgs"; + }; + }, + ]; + }, + { + name: "closeBidWall"; + accounts: [ + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authorityQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipientQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "sellTokens"; + accounts: [ + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "user"; + isMut: false; + isSigner: true; + }, + { + name: "userTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "daoTreasury"; + isMut: false; + isSigner: false; + }, + { + name: "daoTreasuryQuoteTokenAccount"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "SellTokensArgs"; + }; + }, + ]; + }, + { + name: "collectFees"; + accounts: [ + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "cranker"; + isMut: false; + isSigner: true; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipientQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "cancelBidWall"; + accounts: [ + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authorityQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipientQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "bidWall"; + type: { + kind: "struct"; + fields: [ + { + name: "nonce"; + docs: ["The nonce of the bid wall."]; + type: "u64"; + }, + { + name: "createdTimestamp"; + docs: ["When the bid wall was created."]; + type: "i64"; + }, + { + name: "initialAmmQuoteReserves"; + docs: ["The initial quote (USDC) reserves of the Futarchy AMM."]; + type: "u64"; + }, + { + name: "quoteAmount"; + docs: [ + "The current amount of quote tokens assigned to the bid wall.", + "This is different from the amount in the bid wall quote token account,", + "because anyone can transfer quote tokens to the bid wall, and we don't want that to affect the bid wall's NAV calculation.", + ]; + type: "u64"; + }, + { + name: "feesCollected"; + docs: ["The fees collected by the bid wall."]; + type: "u64"; + }, + { + name: "baseBoughtAmount"; + docs: ["The amount of base tokens bought up by the bid wall."]; + type: "u64"; + }, + { + name: "seqNum"; + docs: ["The event sequence number of the bid wall."]; + type: "u64"; + }, + { + name: "creator"; + docs: ["The authority of the bid wall."]; + type: "publicKey"; + }, + { + name: "authority"; + docs: ["The authority of the bid wall."]; + type: "publicKey"; + }, + { + name: "daoTreasury"; + docs: ["The DAO treasury address."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: ["The mint of the token being sold into the bid wall."]; + type: "publicKey"; + }, + { + name: "feeRecipient"; + docs: ["The recipient of the fees collected by the bid wall."]; + type: "publicKey"; + }, + { + name: "durationSeconds"; + docs: [ + "The minimum duration in seconds before the bid wall can be closed.", + ]; + type: "u32"; + }, + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "bidWallSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeBidWallArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + { + name: "nonce"; + type: "u64"; + }, + { + name: "initialAmmQuoteReserves"; + type: "u64"; + }, + { + name: "durationSeconds"; + type: "u32"; + }, + ]; + }; + }, + { + name: "SellTokensArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "amountIn"; + type: "u64"; + }, + { + name: "minAmountOut"; + type: "u64"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "BidWallInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "bidWall"; + type: "publicKey"; + index: false; + }, + { + name: "nonce"; + type: "u64"; + index: false; + }, + { + name: "initialAmmQuoteReserves"; + type: "u64"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "creator"; + type: "publicKey"; + index: false; + }, + { + name: "authority"; + type: "publicKey"; + index: false; + }, + { + name: "daoTreasury"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "feeRecipient"; + type: "publicKey"; + index: false; + }, + { + name: "durationSeconds"; + type: "u32"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + ]; + }, + { + name: "BidWallTokensSoldEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "bidWall"; + type: "publicKey"; + index: false; + }, + { + name: "amountIn"; + type: "u64"; + index: false; + }, + { + name: "amountOut"; + type: "u64"; + index: false; + }, + { + name: "fee"; + type: "u64"; + index: false; + }, + { + name: "postBidWallQuoteTokenAccountAmount"; + type: "u64"; + index: false; + }, + { + name: "postBidWallBaseBoughtAmount"; + type: "u64"; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "BidWallFeesCollectedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "bidWall"; + type: "publicKey"; + index: false; + }, + { + name: "feesCollected"; + type: "u64"; + index: false; + }, + { + name: "postBidWallQuoteTokenAccountAmount"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "BidWallClosedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "bidWall"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "BidWallCanceledEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "bidWall"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "BidWallExpired"; + msg: "Bid wall expired"; + }, + { + code: 6001; + name: "BidWallNotExpired"; + msg: "Bid wall not expired"; + }, + { + code: 6002; + name: "FeeRecipientMismatch"; + msg: "Fee recipient mismatch"; + }, + { + code: 6003; + name: "InsufficientQuoteReserves"; + msg: "Insufficient quote reserves"; + }, + { + code: 6004; + name: "BidWallDepleted"; + msg: "Bid wall depleted"; + }, + { + code: 6005; + name: "InvalidInputAmount"; + msg: "Invalid input amount"; + }, + { + code: 6006; + name: "InvalidCrankAddress"; + msg: "Invalid crank address"; + }, + { + code: 6007; + name: "InsufficientOutputAmount"; + msg: "Insufficient output amount"; + }, + ]; +}; + +export const IDL: BidWall = { + version: "0.7.0", + name: "bid_wall", + instructions: [ + { + name: "initializeBidWall", + accounts: [ + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "creator", + isMut: false, + isSigner: true, + }, + { + name: "authority", + isMut: false, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "creatorQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "daoTreasury", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeBidWallArgs", + }, + }, + ], + }, + { + name: "closeBidWall", + accounts: [ + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authorityQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipientQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "sellTokens", + accounts: [ + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "user", + isMut: false, + isSigner: true, + }, + { + name: "userTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "daoTreasury", + isMut: false, + isSigner: false, + }, + { + name: "daoTreasuryQuoteTokenAccount", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "SellTokensArgs", + }, + }, + ], + }, + { + name: "collectFees", + accounts: [ + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "cranker", + isMut: false, + isSigner: true, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipientQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "cancelBidWall", + accounts: [ + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authorityQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipientQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "bidWall", + type: { + kind: "struct", + fields: [ + { + name: "nonce", + docs: ["The nonce of the bid wall."], + type: "u64", + }, + { + name: "createdTimestamp", + docs: ["When the bid wall was created."], + type: "i64", + }, + { + name: "initialAmmQuoteReserves", + docs: ["The initial quote (USDC) reserves of the Futarchy AMM."], + type: "u64", + }, + { + name: "quoteAmount", + docs: [ + "The current amount of quote tokens assigned to the bid wall.", + "This is different from the amount in the bid wall quote token account,", + "because anyone can transfer quote tokens to the bid wall, and we don't want that to affect the bid wall's NAV calculation.", + ], + type: "u64", + }, + { + name: "feesCollected", + docs: ["The fees collected by the bid wall."], + type: "u64", + }, + { + name: "baseBoughtAmount", + docs: ["The amount of base tokens bought up by the bid wall."], + type: "u64", + }, + { + name: "seqNum", + docs: ["The event sequence number of the bid wall."], + type: "u64", + }, + { + name: "creator", + docs: ["The authority of the bid wall."], + type: "publicKey", + }, + { + name: "authority", + docs: ["The authority of the bid wall."], + type: "publicKey", + }, + { + name: "daoTreasury", + docs: ["The DAO treasury address."], + type: "publicKey", + }, + { + name: "baseMint", + docs: ["The mint of the token being sold into the bid wall."], + type: "publicKey", + }, + { + name: "feeRecipient", + docs: ["The recipient of the fees collected by the bid wall."], + type: "publicKey", + }, + { + name: "durationSeconds", + docs: [ + "The minimum duration in seconds before the bid wall can be closed.", + ], + type: "u32", + }, + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "bidWallSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeBidWallArgs", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + { + name: "nonce", + type: "u64", + }, + { + name: "initialAmmQuoteReserves", + type: "u64", + }, + { + name: "durationSeconds", + type: "u32", + }, + ], + }, + }, + { + name: "SellTokensArgs", + type: { + kind: "struct", + fields: [ + { + name: "amountIn", + type: "u64", + }, + { + name: "minAmountOut", + type: "u64", + }, + ], + }, + }, + ], + events: [ + { + name: "BidWallInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "bidWall", + type: "publicKey", + index: false, + }, + { + name: "nonce", + type: "u64", + index: false, + }, + { + name: "initialAmmQuoteReserves", + type: "u64", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "creator", + type: "publicKey", + index: false, + }, + { + name: "authority", + type: "publicKey", + index: false, + }, + { + name: "daoTreasury", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "feeRecipient", + type: "publicKey", + index: false, + }, + { + name: "durationSeconds", + type: "u32", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + ], + }, + { + name: "BidWallTokensSoldEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "bidWall", + type: "publicKey", + index: false, + }, + { + name: "amountIn", + type: "u64", + index: false, + }, + { + name: "amountOut", + type: "u64", + index: false, + }, + { + name: "fee", + type: "u64", + index: false, + }, + { + name: "postBidWallQuoteTokenAccountAmount", + type: "u64", + index: false, + }, + { + name: "postBidWallBaseBoughtAmount", + type: "u64", + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "BidWallFeesCollectedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "bidWall", + type: "publicKey", + index: false, + }, + { + name: "feesCollected", + type: "u64", + index: false, + }, + { + name: "postBidWallQuoteTokenAccountAmount", + type: "u64", + index: false, + }, + ], + }, + { + name: "BidWallClosedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "bidWall", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "BidWallCanceledEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "bidWall", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "BidWallExpired", + msg: "Bid wall expired", + }, + { + code: 6001, + name: "BidWallNotExpired", + msg: "Bid wall not expired", + }, + { + code: 6002, + name: "FeeRecipientMismatch", + msg: "Fee recipient mismatch", + }, + { + code: 6003, + name: "InsufficientQuoteReserves", + msg: "Insufficient quote reserves", + }, + { + code: 6004, + name: "BidWallDepleted", + msg: "Bid wall depleted", + }, + { + code: 6005, + name: "InvalidInputAmount", + msg: "Invalid input amount", + }, + { + code: 6006, + name: "InvalidCrankAddress", + msg: "Invalid crank address", + }, + { + code: 6007, + name: "InsufficientOutputAmount", + msg: "Insufficient output amount", + }, + ], +}; diff --git a/sdk2/src/bid_wall/v0.7/types/index.ts b/sdk2/src/bid_wall/v0.7/types/index.ts new file mode 100644 index 000000000..4403d9092 --- /dev/null +++ b/sdk2/src/bid_wall/v0.7/types/index.ts @@ -0,0 +1,24 @@ +import { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +import { BidWall as BidWallProgram, IDL as BidWallIDL } from "./bid_wall.js"; + +export { BidWallProgram, BidWallIDL }; + +export type BidWall = IdlAccounts["bidWall"]; + +export type BidWallInitializedEvent = + IdlEvents["BidWallInitializedEvent"]; +export type BidWallTokensSoldEvent = + IdlEvents["BidWallTokensSoldEvent"]; +export type BidWallFeesCollectedEvent = + IdlEvents["BidWallFeesCollectedEvent"]; +export type BidWallClosedEvent = + IdlEvents["BidWallClosedEvent"]; +export type BidWallCanceledEvent = + IdlEvents["BidWallCanceledEvent"]; +export type BidWallEvent = + | BidWallInitializedEvent + | BidWallTokensSoldEvent + | BidWallFeesCollectedEvent + | BidWallClosedEvent + | BidWallCanceledEvent; diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index 780cfe31e..df7bbfe45 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -20,16 +20,16 @@ export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( export const PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID = new PublicKey( "pbPPQH7jyKoSLu8QYs3rSY3YkDRXEBojKbTgnUg7NDS", ); -export const BID_WALL_V0_1_PROGRAM_ID = new PublicKey( +export const BID_WALL_V0_7_PROGRAM_ID = new PublicKey( "WALL8ucBuUyL46QYxwYJjidaFYhdvxUFrgvBxPshERx", ); -export const MINT_GOVERNOR_V0_1_PROGRAM_ID = new PublicKey( +export const MINT_GOVERNOR_V0_7_PROGRAM_ID = new PublicKey( "gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH", ); export const PERFORMANCE_PACKAGE_V2_PROGRAM_ID = new PublicKey( "pPV2pfrxnmstSb9j7kEeCLny5BGj6SNwCWGd6xbGGzz", ); -export const LIQUIDATION_V0_1_PROGRAM_ID = new PublicKey( +export const LIQUIDATION_V0_7_PROGRAM_ID = new PublicKey( "LiQnowFbFQdYyZhF4pUbpsrZCjxRTQ1upKJxZ2VXjde", ); diff --git a/sdk2/src/launchpad/index.ts b/sdk2/src/launchpad/index.ts new file mode 100644 index 000000000..6b187d27b --- /dev/null +++ b/sdk2/src/launchpad/index.ts @@ -0,0 +1 @@ +export * from "./v0.7/index.js"; diff --git a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts new file mode 100644 index 000000000..d23398eef --- /dev/null +++ b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts @@ -0,0 +1,741 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + PublicKey, + AccountInfo, + ComputeBudgetProgram, + SystemProgram, +} from "@solana/web3.js"; +import { + LaunchpadV7 as Launchpad, + IDL as LaunchpadIDL, +} from "./types/launchpad_v7.js"; +import { + LAUNCHPAD_V0_7_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, + SQUADS_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + DAMM_V2_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + METADAO_MULTISIG_VAULT, +} from "../../constants.js"; +import { + ASSOCIATED_TOKEN_PROGRAM_ID, + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { FundingRecord, Launch } from "./types/index.js"; +import { + getFundingRecordAddr, + getLaunchAddr, + getLaunchSignerAddr, +} from "./pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; + +import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; +import * as multisig from "@sqds/multisig"; +import { + PriceBasedPerformancePackageClient, + getPerformancePackageAddr, +} from "../../price_based_performance_package/v0.6/index.js"; +import { BidWallClient } from "../../bid_wall/v0.7/index.js"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + priceBasedUnlockProgramId?: PublicKey; + bidWallProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + public autocratClient: FutarchyClient; + public priceBasedUnlock: PriceBasedPerformancePackageClient; + public bidWall: BidWallClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + this.launchpad = new Program( + LaunchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_7_PROGRAM_ID, + this.provider, + ); + this.autocratClient = FutarchyClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + }); + this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ + provider: this.provider, + priceBasedTokenLockProgramId: params.priceBasedUnlockProgramId, + }); + this.bidWall = BidWallClient.createClient({ + provider: this.provider, + bidWallProgramId: params.bidWallProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord( + fundingRecord: PublicKey, + ): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable( + fundingRecord, + ); + } + + async deserializeFundingRecord( + accountInfo: AccountInfo, + ): Promise { + return this.launchpad.coder.accounts.decode( + "fundingRecord", + accountInfo.data, + ); + } + + initializeLaunchIx({ + tokenName, + tokenSymbol, + tokenUri, + minimumRaiseAmount, + secondsForLaunch = 60 * 60 * 24 * 5, // 5 days + baseMint, + quoteMint = MAINNET_USDC, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + launchAuthority = this.provider.publicKey, + payer = this.provider.publicKey, + additionalTokensRecipient, + additionalTokensAmount, + accumulatorActivationDelaySeconds = 0, + hasBidWall = false, + }: { + tokenName: string; + tokenSymbol: string; + tokenUri: string; + minimumRaiseAmount: BN; + secondsForLaunch?: number; + baseMint: PublicKey; + quoteMint?: PublicKey; + monthlySpendingLimitAmount: BN; + monthlySpendingLimitMembers: PublicKey[]; + performancePackageGrantee: PublicKey; + performancePackageTokenAmount: BN; + monthsUntilInsidersCanUnlock: number; + teamAddress: PublicKey; + launchAuthority?: PublicKey; + payer?: PublicKey; + additionalTokensRecipient?: PublicKey; + additionalTokensAmount?: BN; + accumulatorActivationDelaySeconds?: number; + hasBidWall: boolean; + }) { + const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const quoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + + const baseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + const [tokenMetadata] = getMetadataAddr(baseMint); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, + tokenSymbol, + tokenUri, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + additionalTokensAmount: additionalTokensAmount ?? new BN(0), + accumulatorActivationDelaySeconds, + hasBidWall, + }) + .accounts({ + launch, + launchSigner, + quoteVault, + baseVault, + launchAuthority, + quoteMint, + baseMint, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + additionalTokensRecipient: additionalTokensRecipient ?? null, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, launchSigner, true), + launchSigner, + quoteMint, + ), + ]); + // .signers([tokenMintKp]); + } + + startLaunchIx({ + launch, + launchAuthority = this.provider.publicKey, + }: { + launch: PublicKey; + launchAuthority?: PublicKey; + }) { + return this.launchpad.methods.startLaunch().accounts({ + launch, + launchAuthority, + }); + } + + fundIx({ + launch, + amount, + funder = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + amount: BN; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods.fund(amount).accounts({ + launch, + launchQuoteVault, + fundingRecord, + funder, + funderQuoteAccount, + }); + } + + closeLaunchIx({ launch }: { launch: PublicKey }) { + return this.launchpad.methods.closeLaunch().accounts({ + launch, + }); + } + + completeLaunchIx({ + launch, + quoteMint = MAINNET_USDC, + baseMint, + launchAuthority, + isDevnet = false, + meteoraConfig = LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + feeRecipient = METADAO_MULTISIG_VAULT, + }: { + launch: PublicKey; + quoteMint?: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey | null; + isDevnet?: boolean; + meteoraConfig?: PublicKey; + feeRecipient?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const launchBaseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + + // const daoKp = Keypair.generate(); + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [futarchyEventAuthority] = getEventAuthorityAddr( + this.autocratClient.getProgramId(), + ); + + const [tokenMetadata] = getMetadataAddr(baseMint); + + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ + multisigPda, + index: 0, + }); + + const [spendingLimit] = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + }); + + const treasuryQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + multisigVault, + true, + ); + + const [ammPosition] = PublicKey.findProgramAddressSync( + [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], + this.autocratClient.getProgramId(), + ); + + const [performancePackage] = getPerformancePackageAddr({ + createKey: launchSigner, + }); + const performancePackageTokenAccount = getAssociatedTokenAddressSync( + baseMint, + performancePackage, + true, + ); + + const [poolAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], + DAMM_V2_PROGRAM_ID, + ); + + const [positionNftMint] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_mint"), baseMint.toBuffer()], + LAUNCHPAD_V0_7_PROGRAM_ID, + ); + + const [positionNftAccount] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + function getFirstKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf1; + } + return buf2; + } + + function getSecondKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf2; + } + return buf1; + } + + const [pool] = PublicKey.findProgramAddressSync( + [ + Buffer.from("pool"), + meteoraConfig.toBuffer(), + getFirstKey(baseMint, quoteMint), + getSecondKey(baseMint, quoteMint), + ], + DAMM_V2_PROGRAM_ID, + ); + + const [position] = PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenAVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenBVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + LAUNCHPAD_V0_7_PROGRAM_ID, + ); + + const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); + + const bidWall = this.bidWall.getBidWallAddress({ + baseMint, + creator: launchSigner, + nonce: new BN(0), + }); + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + + return this.launchpad.methods + .completeLaunch() + .accounts({ + launch, + launchSigner, + launchQuoteVault, + launchBaseVault, + launchAuthority, + dao, + treasuryQuoteAccount, + quoteMint, + baseMint, + tokenMetadata, + daoOwnedLpPosition: ammPosition, + futarchyAmmQuoteVault: getAssociatedTokenAddressSync( + quoteMint, + dao, + true, + ), + futarchyAmmBaseVault: getAssociatedTokenAddressSync( + baseMint, + dao, + true, + ), + staticAccounts: { + futarchyProgram: this.autocratClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + futarchyEventAuthority, + squadsProgram: SQUADS_PROGRAM_ID, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury: isDevnet + ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET + : SQUADS_PROGRAM_CONFIG_TREASURY, + bidWallProgram: this.bidWall.programId, + bidWallEventAuthority: this.bidWall.getEventAuthorityAddress(), + }, + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + spendingLimit, + bidWall, + bidWallQuoteTokenAccount, + feeRecipient, + meteoraAccounts: { + dammV2Program: DAMM_V2_PROGRAM_ID, + positionNftMint, + baseMint, + quoteMint, + config: meteoraConfig, + token2022Program: TOKEN_2022_PROGRAM_ID, + positionNftAccount, + pool, + // baseMint, + // quoteMint, + poolCreatorAuthority, + position, + tokenAVault, + tokenBVault, + poolAuthority, + dammV2EventAuthority, + }, + // poolCreatorAuthority, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), + ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), + ]); + } + + refundIx({ + launch, + funder = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + + return this.launchpad.methods.refund().accounts({ + launch, + launchSigner, + launchQuoteVault, + funder, + funderQuoteAccount, + fundingRecord, + }); + } + + claimIx( + launch: PublicKey, + baseMint: PublicKey, + funder: PublicKey = this.provider.publicKey, + ) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods + .claim() + .accounts({ + launch, + fundingRecord, + launchSigner, + funder, + funderTokenAccount: getAssociatedTokenAddressSync( + baseMint, + funder, + true, + ), + baseMint, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, funder, true), + funder, + baseMint, + ), + ]); + } + + setFundingRecordApprovalIx({ + launch, + funder, + launchAuthority = this.provider.publicKey, + approvedAmount, + }: { + launch: PublicKey; + funder: PublicKey; + launchAuthority?: PublicKey; + approvedAmount: BN; + }) { + let fundingRecord = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + )[0]; + + return this.launchpad.methods + .setFundingRecordApproval(approvedAmount) + .accounts({ + launch, + fundingRecord, + launchAuthority, + }); + } + + claimAdditionalTokenAllocationIx({ + launch, + baseMint, + additionalTokensRecipient, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + additionalTokensRecipient: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return this.launchpad.methods.claimAdditionalTokenAllocation().accounts({ + launch, + payer, + launchSigner, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + baseMint, + additionalTokensRecipient, + additionalTokensRecipientTokenAccount: getAssociatedTokenAddressSync( + baseMint, + additionalTokensRecipient, + true, + ), + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + }); + } + + initializePerformancePackageIx({ + launch, + baseMint, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ + multisigPda, + index: 0, + }); + + const launchBaseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + + const performancePackage = this.getLaunchPerformancePackageAddress({ + launch, + }); + + const performancePackageTokenAccount = getAssociatedTokenAddressSync( + baseMint, + performancePackage, + true, + ); + + return this.launchpad.methods.initializePerformancePackage().accounts({ + launch, + performancePackage, + performancePackageTokenAccount, + dao, + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + launchBaseVault, + baseMint, + payer, + launchSigner, + squadsProgram: SQUADS_PROGRAM_ID, + priceBasedPerformancePackageEventAuthority: + this.priceBasedUnlock.getEventAuthorityAddress(), + priceBasedPerformancePackageProgram: this.priceBasedUnlock.programId, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }); + } + + getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { + return getLaunchAddr(this.launchpad.programId, baseMint)[0]; + } + + getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { + return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; + } + + getLaunchPerformancePackageAddress({ + launch, + }: { + launch: PublicKey; + }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return getPerformancePackageAddr({ createKey: launchSigner })[0]; + } + + getLaunchDaoAddress({ launch }: { launch: PublicKey }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner })[0]; + } + + getFundingRecordAddress({ + launch, + funder, + }: { + launch: PublicKey; + funder: PublicKey; + }): PublicKey { + return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; + } +} diff --git a/sdk2/src/launchpad/v0.7/index.ts b/sdk2/src/launchpad/v0.7/index.ts new file mode 100644 index 000000000..2f88e3015 --- /dev/null +++ b/sdk2/src/launchpad/v0.7/index.ts @@ -0,0 +1 @@ +export * from "./types/index.js"; diff --git a/sdk2/src/launchpad/v0.7/pda.ts b/sdk2/src/launchpad/v0.7/pda.ts new file mode 100644 index 000000000..b931cc1fb --- /dev/null +++ b/sdk2/src/launchpad/v0.7/pda.ts @@ -0,0 +1,33 @@ +import { PublicKey } from "@solana/web3.js"; +import { LAUNCHPAD_V0_7_PROGRAM_ID } from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_7_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_7_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_7_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/launchpad/v0.7/types/index.ts b/sdk2/src/launchpad/v0.7/types/index.ts new file mode 100644 index 000000000..7e63bbfc3 --- /dev/null +++ b/sdk2/src/launchpad/v0.7/types/index.ts @@ -0,0 +1,40 @@ +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +import { + LaunchpadV7 as LaunchpadProgram, + IDL as LaunchpadIDL, +} from "./launchpad_v7.js"; +export { LaunchpadProgram, LaunchpadIDL }; + +export type Launch = IdlAccounts["launch"]; +export type FundingRecord = IdlAccounts["fundingRecord"]; + +export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; +export type LaunchCompletedEvent = + IdlEvents["LaunchCompletedEvent"]; +export type LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type LaunchCloseEvent = IdlEvents["LaunchCloseEvent"]; +export type FundingRecordApprovalSetEvent = + IdlEvents["FundingRecordApprovalSetEvent"]; +export type LaunchClaimAdditionalTokenAllocationEvent = + IdlEvents["LaunchClaimAdditionalTokenAllocationEvent"]; +export type LaunchPerformancePackageInitializedEvent = + IdlEvents["LaunchPerformancePackageInitializedEvent"]; +export type LaunchpadEvent = + | LaunchClaimEvent + | LaunchCompletedEvent + | LaunchFundedEvent + | LaunchInitializedEvent + | LaunchRefundedEvent + | LaunchStartedEvent + | LaunchCloseEvent + | FundingRecordApprovalSetEvent + | LaunchClaimAdditionalTokenAllocationEvent + | LaunchPerformancePackageInitializedEvent; diff --git a/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts b/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts new file mode 100644 index 000000000..fb82a3b6e --- /dev/null +++ b/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts @@ -0,0 +1,4069 @@ +export type LaunchpadV7 = { + version: "0.7.0"; + name: "launchpad_v7"; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + isOptional: true; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "setFundingRecordApproval"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "approvedAmount"; + type: "u64"; + }, + ]; + }, + { + name: "completeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + isOptional: true; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "daoOwnedLpPosition"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "futarchyProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "futarchyEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallProgram"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "meteoraAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "config"; + isMut: false; + isSigner: false; + }, + { + name: "token2022Program"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: true; + isSigner: false; + }, + { + name: "pool"; + isMut: true; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "positionNftMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolCreatorAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "closeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claimAdditionalTokenAllocation"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipientTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "initializePerformancePackage"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackageTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageProgram"; + isMut: false; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "resizeFundingRecord"; + accounts: [ + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "resizeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + { + name: "approvedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ]; + type: "u64"; + }, + { + name: "committedAmountAccumulator"; + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ]; + type: "u128"; + }, + { + name: "lastAccumulatorUpdate"; + docs: ["Unix timestamp of the last accumulator update."]; + type: "i64"; + }, + ]; + }; + }, + { + name: "oldFundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + { + name: "approvedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + { + name: "teamAddress"; + docs: ["The initial address used to sponsor team proposals."]; + type: "publicKey"; + }, + { + name: "totalApprovedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ]; + type: "u64"; + }, + { + name: "additionalTokensAmount"; + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ]; + type: "u64"; + }, + { + name: "additionalTokensRecipient"; + docs: [ + "The token account that will receive the additional tokens.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "additionalTokensClaimed"; + docs: ["Are the additional tokens claimed"]; + type: "bool"; + }, + { + name: "unixTimestampCompleted"; + docs: ["The unix timestamp when the launch was completed."]; + type: { + option: "i64"; + }; + }, + { + name: "isPerformancePackageInitialized"; + docs: ["Whether the performance package has been initialized."]; + type: "bool"; + }, + { + name: "accumulatorActivationDelaySeconds"; + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ]; + type: "u32"; + }, + { + name: "hasBidWall"; + docs: ["Whether the launch has a bid wall."]; + type: "bool"; + }, + ]; + }; + }, + { + name: "oldLaunch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + { + name: "teamAddress"; + docs: ["The initial address used to sponsor team proposals."]; + type: "publicKey"; + }, + { + name: "totalApprovedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ]; + type: "u64"; + }, + { + name: "additionalTokensAmount"; + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ]; + type: "u64"; + }, + { + name: "additionalTokensRecipient"; + docs: [ + "The token account that will receive the additional tokens.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "additionalTokensClaimed"; + docs: ["Are the additional tokens claimed"]; + type: "bool"; + }, + { + name: "unixTimestampCompleted"; + docs: ["The unix timestamp when the launch was completed."]; + type: { + option: "i64"; + }; + }, + { + name: "isPerformancePackageInitialized"; + type: "bool"; + }, + { + name: "accumulatorActivationDelaySeconds"; + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ]; + type: "u32"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + }, + { + name: "hasBidWall"; + type: "bool"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Closed"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + index: false; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + index: false; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + index: false; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + index: false; + }, + { + name: "hasBidWall"; + type: "bool"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "committedAmountAccumulator"; + type: "u128"; + index: false; + }, + ]; + }, + { + name: "FundingRecordApprovalSetEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "approvedAmount"; + type: "u64"; + index: false; + }, + { + name: "totalApproved"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "totalApprovedAmount"; + type: "u64"; + index: false; + }, + { + name: "bidWall"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "bidWallAmount"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchCloseEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "newState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchPerformancePackageInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidTokenKey"; + msg: "Token mint key must end in 'meta'"; + }, + { + code: 6005; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6006; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6007; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6008; + name: "LaunchNotRefunding"; + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; + }, + { + code: 6009; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6010; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; + }, + { + code: 6012; + name: "InvalidMonthlySpendingLimitMembers"; + msg: "There can only be at most 10 monthly spending limit members"; + }, + { + code: 6013; + name: "InvalidPriceBasedPremineAmount"; + msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; + }, + { + code: 6014; + name: "InvalidPerformancePackageMinUnlockTime"; + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; + }, + { + code: 6015; + name: "LaunchAuthorityNotSet"; + msg: "Launch authority must be set to complete the launch until 2 days after closing"; + }, + { + code: 6016; + name: "FinalRaiseAmountTooLow"; + msg: "The final amount raised must be greater than or equal to the minimum raise amount"; + }, + { + code: 6017; + name: "TokensAlreadyClaimed"; + msg: "Tokens already claimed"; + }, + { + code: 6018; + name: "MoneyAlreadyRefunded"; + msg: "Money already refunded"; + }, + { + code: 6019; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6020; + name: "LaunchNotLive"; + msg: "Launch must be live to be closed"; + }, + { + code: 6021; + name: "InvalidMinimumRaiseAmount"; + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; + }, + { + code: 6022; + name: "FinalRaiseAmountAlreadySet"; + msg: "The final raise amount has already been set"; + }, + { + code: 6023; + name: "TotalApprovedAmountTooLow"; + msg: "Total approved amount must be greater than or equal to the minimum raise amount"; + }, + { + code: 6024; + name: "InvalidAdditionalTokensRecipient"; + msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0"; + }, + { + code: 6025; + name: "NoAdditionalTokensRecipientSet"; + msg: "No additional tokens recipient set"; + }, + { + code: 6026; + name: "AdditionalTokensAlreadyClaimed"; + msg: "Additional tokens already claimed"; + }, + { + code: 6027; + name: "FundingRecordApprovalPeriodOver"; + msg: "Funding record approval period is over"; + }, + { + code: 6028; + name: "PerformancePackageAlreadyInitialized"; + msg: "Performance package already initialized"; + }, + { + code: 6029; + name: "InvalidDao"; + msg: "Invalid DAO"; + }, + { + code: 6030; + name: "InvalidAccumulatorActivationDelaySeconds"; + msg: "Accumulator activation delay must be less than the launch duration"; + }, + ]; +}; + +export const IDL: LaunchpadV7 = { + version: "0.7.0", + name: "launchpad_v7", + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + isOptional: true, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "setFundingRecordApproval", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "approvedAmount", + type: "u64", + }, + ], + }, + { + name: "completeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + isOptional: true, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "daoOwnedLpPosition", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "futarchyProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "futarchyEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "bidWallProgram", + isMut: false, + isSigner: false, + }, + { + name: "bidWallEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "meteoraAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "config", + isMut: false, + isSigner: false, + }, + { + name: "token2022Program", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: true, + isSigner: false, + }, + { + name: "pool", + isMut: true, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "positionNftMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "poolCreatorAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "closeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claimAdditionalTokenAllocation", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipientTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "initializePerformancePackage", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "performancePackageTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageProgram", + isMut: false, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "resizeFundingRecord", + accounts: [ + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "resizeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + { + name: "approvedAmount", + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ], + type: "u64", + }, + { + name: "committedAmountAccumulator", + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ], + type: "u128", + }, + { + name: "lastAccumulatorUpdate", + docs: ["Unix timestamp of the last accumulator update."], + type: "i64", + }, + ], + }, + }, + { + name: "oldFundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + { + name: "approvedAmount", + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ], + type: "u64", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + { + name: "teamAddress", + docs: ["The initial address used to sponsor team proposals."], + type: "publicKey", + }, + { + name: "totalApprovedAmount", + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ], + type: "u64", + }, + { + name: "additionalTokensAmount", + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ], + type: "u64", + }, + { + name: "additionalTokensRecipient", + docs: [ + "The token account that will receive the additional tokens.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "additionalTokensClaimed", + docs: ["Are the additional tokens claimed"], + type: "bool", + }, + { + name: "unixTimestampCompleted", + docs: ["The unix timestamp when the launch was completed."], + type: { + option: "i64", + }, + }, + { + name: "isPerformancePackageInitialized", + docs: ["Whether the performance package has been initialized."], + type: "bool", + }, + { + name: "accumulatorActivationDelaySeconds", + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ], + type: "u32", + }, + { + name: "hasBidWall", + docs: ["Whether the launch has a bid wall."], + type: "bool", + }, + ], + }, + }, + { + name: "oldLaunch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + { + name: "teamAddress", + docs: ["The initial address used to sponsor team proposals."], + type: "publicKey", + }, + { + name: "totalApprovedAmount", + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ], + type: "u64", + }, + { + name: "additionalTokensAmount", + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ], + type: "u64", + }, + { + name: "additionalTokensRecipient", + docs: [ + "The token account that will receive the additional tokens.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "additionalTokensClaimed", + docs: ["Are the additional tokens claimed"], + type: "bool", + }, + { + name: "unixTimestampCompleted", + docs: ["The unix timestamp when the launch was completed."], + type: { + option: "i64", + }, + }, + { + name: "isPerformancePackageInitialized", + type: "bool", + }, + { + name: "accumulatorActivationDelaySeconds", + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ], + type: "u32", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + { + name: "performancePackageGrantee", + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + }, + { + name: "teamAddress", + type: "publicKey", + }, + { + name: "additionalTokensAmount", + type: "u64", + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + }, + { + name: "hasBidWall", + type: "bool", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Closed", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "performancePackageGrantee", + type: "publicKey", + index: false, + }, + { + name: "performancePackageTokenAmount", + type: "u64", + index: false, + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + index: false, + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + index: false, + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + index: false, + }, + { + name: "hasBidWall", + type: "bool", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "committedAmountAccumulator", + type: "u128", + index: false, + }, + ], + }, + { + name: "FundingRecordApprovalSetEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "approvedAmount", + type: "u64", + index: false, + }, + { + name: "totalApproved", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "totalApprovedAmount", + type: "u64", + index: false, + }, + { + name: "bidWall", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "bidWallAmount", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchCloseEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "newState", + type: { + defined: "LaunchState", + }, + index: false, + }, + ], + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchPerformancePackageInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidTokenKey", + msg: "Token mint key must end in 'meta'", + }, + { + code: 6005, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6006, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6007, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6008, + name: "LaunchNotRefunding", + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", + }, + { + code: 6009, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6010, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", + }, + { + code: 6012, + name: "InvalidMonthlySpendingLimitMembers", + msg: "There can only be at most 10 monthly spending limit members", + }, + { + code: 6013, + name: "InvalidPriceBasedPremineAmount", + msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", + }, + { + code: 6014, + name: "InvalidPerformancePackageMinUnlockTime", + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", + }, + { + code: 6015, + name: "LaunchAuthorityNotSet", + msg: "Launch authority must be set to complete the launch until 2 days after closing", + }, + { + code: 6016, + name: "FinalRaiseAmountTooLow", + msg: "The final amount raised must be greater than or equal to the minimum raise amount", + }, + { + code: 6017, + name: "TokensAlreadyClaimed", + msg: "Tokens already claimed", + }, + { + code: 6018, + name: "MoneyAlreadyRefunded", + msg: "Money already refunded", + }, + { + code: 6019, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6020, + name: "LaunchNotLive", + msg: "Launch must be live to be closed", + }, + { + code: 6021, + name: "InvalidMinimumRaiseAmount", + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", + }, + { + code: 6022, + name: "FinalRaiseAmountAlreadySet", + msg: "The final raise amount has already been set", + }, + { + code: 6023, + name: "TotalApprovedAmountTooLow", + msg: "Total approved amount must be greater than or equal to the minimum raise amount", + }, + { + code: 6024, + name: "InvalidAdditionalTokensRecipient", + msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0", + }, + { + code: 6025, + name: "NoAdditionalTokensRecipientSet", + msg: "No additional tokens recipient set", + }, + { + code: 6026, + name: "AdditionalTokensAlreadyClaimed", + msg: "Additional tokens already claimed", + }, + { + code: 6027, + name: "FundingRecordApprovalPeriodOver", + msg: "Funding record approval period is over", + }, + { + code: 6028, + name: "PerformancePackageAlreadyInitialized", + msg: "Performance package already initialized", + }, + { + code: 6029, + name: "InvalidDao", + msg: "Invalid DAO", + }, + { + code: 6030, + name: "InvalidAccumulatorActivationDelaySeconds", + msg: "Accumulator activation delay must be less than the launch duration", + }, + ], +}; diff --git a/sdk2/src/liquidation/index.ts b/sdk2/src/liquidation/index.ts new file mode 100644 index 000000000..6b187d27b --- /dev/null +++ b/sdk2/src/liquidation/index.ts @@ -0,0 +1 @@ +export * from "./v0.7/index.js"; diff --git a/sdk2/src/liquidation/v0.7/LiquidationClient.ts b/sdk2/src/liquidation/v0.7/LiquidationClient.ts new file mode 100644 index 000000000..68f1c5db7 --- /dev/null +++ b/sdk2/src/liquidation/v0.7/LiquidationClient.ts @@ -0,0 +1,335 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import BN from "bn.js"; +import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; +import { + ASSOCIATED_TOKEN_PROGRAM_ID, + getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import { LIQUIDATION_V0_7_PROGRAM_ID } from "../../constants.js"; +import { + LiquidationProgram, + LiquidationIDL, + LiquidationAccount, + RefundRecordAccount, +} from "./types/index.js"; +import { getLiquidationAddr, getRefundRecordAddr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; + +export type CreateLiquidationClientParams = { + provider: AnchorProvider; + liquidationProgramId?: PublicKey; +}; + +export class LiquidationClient { + public readonly provider: AnchorProvider; + public readonly liquidationProgram: Program; + public readonly programId: PublicKey; + + constructor(provider: AnchorProvider, liquidationProgramId: PublicKey) { + this.provider = provider; + this.programId = liquidationProgramId; + this.liquidationProgram = new Program( + LiquidationIDL, + liquidationProgramId, + provider, + ); + } + + public static createClient( + createLiquidationClientParams: CreateLiquidationClientParams, + ): LiquidationClient { + let { provider, liquidationProgramId } = createLiquidationClientParams; + + return new LiquidationClient( + provider, + liquidationProgramId || LIQUIDATION_V0_7_PROGRAM_ID, + ); + } + + public getProgramId(): PublicKey { + return this.programId; + } + + async fetchLiquidation( + liquidation: PublicKey, + ): Promise { + return this.liquidationProgram.account.liquidation.fetchNullable( + liquidation, + ); + } + + async deserializeLiquidation( + accountInfo: AccountInfo, + ): Promise { + return this.liquidationProgram.coder.accounts.decode( + "liquidation", + accountInfo.data, + ); + } + + async fetchRefundRecord( + refundRecord: PublicKey, + ): Promise { + return this.liquidationProgram.account.refundRecord.fetchNullable( + refundRecord, + ); + } + + async deserializeRefundRecord( + accountInfo: AccountInfo, + ): Promise { + return this.liquidationProgram.coder.accounts.decode( + "refundRecord", + accountInfo.data, + ); + } + + async getLiquidation({ + baseMint, + quoteMint, + createKey, + }: { + baseMint: PublicKey; + quoteMint: PublicKey; + createKey: PublicKey; + }): Promise { + const liquidation = this.getLiquidationAddress({ + baseMint, + quoteMint, + createKey, + }); + return this.fetchLiquidation(liquidation); + } + + initializeLiquidationIx({ + durationSeconds, + createKey, + recordAuthority, + liquidationAuthority, + baseMint, + quoteMint, + payer = this.provider.publicKey, + }: { + durationSeconds: number; + createKey: PublicKey; + recordAuthority: PublicKey; + liquidationAuthority: PublicKey; + baseMint: PublicKey; + quoteMint: PublicKey; + payer?: PublicKey; + }) { + const liquidation = this.getLiquidationAddress({ + baseMint, + quoteMint, + createKey, + }); + + const liquidationQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + liquidation, + true, + ); + + return this.liquidationProgram.methods + .initializeLiquidation({ durationSeconds }) + .accounts({ + payer, + createKey, + recordAuthority, + liquidationAuthority, + baseMint, + quoteMint, + liquidation, + liquidationQuoteVault, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + }); + } + + setRefundRecordIx({ + baseAssigned, + quoteRefundable, + recordAuthority, + liquidation, + recipient, + payer = this.provider.publicKey, + }: { + baseAssigned: BN; + quoteRefundable: BN; + recordAuthority: PublicKey; + liquidation: PublicKey; + recipient: PublicKey; + payer?: PublicKey; + }) { + const refundRecord = this.getRefundRecordAddress({ + liquidation, + recipient, + }); + + return this.liquidationProgram.methods + .setRefundRecord({ baseAssigned, quoteRefundable }) + .accounts({ + payer, + recordAuthority, + liquidation, + recipient, + refundRecord, + systemProgram: SystemProgram.programId, + }); + } + + activateLiquidationIx({ + liquidationAuthority, + liquidation, + liquidationAuthorityQuoteAccount, + quoteMint, + }: { + liquidationAuthority: PublicKey; + liquidation: PublicKey; + liquidationAuthorityQuoteAccount?: PublicKey; + quoteMint: PublicKey; + }) { + const liquidationQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + liquidation, + true, + ); + + const resolvedLiquidationAuthorityQuoteAccount = + liquidationAuthorityQuoteAccount ?? + getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true); + + return this.liquidationProgram.methods.activateLiquidation().accounts({ + liquidationAuthority, + liquidation, + liquidationAuthorityQuoteAccount: + resolvedLiquidationAuthorityQuoteAccount, + liquidationQuoteVault, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + }); + } + + refundIx({ + recipient, + liquidation, + baseMint, + recipientBaseAccount, + quoteMint, + }: { + recipient: PublicKey; + liquidation: PublicKey; + baseMint: PublicKey; + recipientBaseAccount?: PublicKey; + quoteMint: PublicKey; + }) { + const refundRecord = this.getRefundRecordAddress({ + liquidation, + recipient, + }); + + const resolvedRecipientBaseAccount = + recipientBaseAccount ?? + getAssociatedTokenAddressSync(baseMint, recipient, true); + + const liquidationQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + liquidation, + true, + ); + + const recipientQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + recipient, + true, + ); + + return this.liquidationProgram.methods.refund().accounts({ + recipient, + liquidation, + refundRecord, + baseMint, + recipientBaseAccount: resolvedRecipientBaseAccount, + liquidationQuoteVault, + recipientQuoteAccount, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + }); + } + + withdrawRemainingQuoteIx({ + liquidationAuthority, + liquidation, + liquidationAuthorityQuoteAccount, + quoteMint, + }: { + liquidationAuthority: PublicKey; + liquidation: PublicKey; + liquidationAuthorityQuoteAccount?: PublicKey; + quoteMint: PublicKey; + }) { + const liquidationQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + liquidation, + true, + ); + + const resolvedLiquidationAuthorityQuoteAccount = + liquidationAuthorityQuoteAccount ?? + getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true); + + return this.liquidationProgram.methods.withdrawRemainingQuote().accounts({ + liquidationAuthority, + liquidation, + liquidationQuoteVault, + liquidationAuthorityQuoteAccount: + resolvedLiquidationAuthorityQuoteAccount, + quoteMint, + tokenProgram: TOKEN_PROGRAM_ID, + }); + } + + async getRefundRecord({ + liquidation, + recipient, + }: { + liquidation: PublicKey; + recipient: PublicKey; + }): Promise { + const refundRecord = this.getRefundRecordAddress({ + liquidation, + recipient, + }); + return this.fetchRefundRecord(refundRecord); + } + + public getLiquidationAddress({ + baseMint, + quoteMint, + createKey, + }: { + baseMint: PublicKey; + quoteMint: PublicKey; + createKey: PublicKey; + }): PublicKey { + return getLiquidationAddr({ baseMint, quoteMint, createKey })[0]; + } + + public getRefundRecordAddress({ + liquidation, + recipient, + }: { + liquidation: PublicKey; + recipient: PublicKey; + }): PublicKey { + return getRefundRecordAddr({ liquidation, recipient })[0]; + } + + public getEventAuthorityAddress(): PublicKey { + return getEventAuthorityAddr(this.programId)[0]; + } +} diff --git a/sdk2/src/liquidation/v0.7/index.ts b/sdk2/src/liquidation/v0.7/index.ts new file mode 100644 index 000000000..3a387db23 --- /dev/null +++ b/sdk2/src/liquidation/v0.7/index.ts @@ -0,0 +1,2 @@ +export * from "./types/index.js"; +export * from "./pda.js"; diff --git a/sdk2/src/liquidation/v0.7/pda.ts b/sdk2/src/liquidation/v0.7/pda.ts new file mode 100644 index 000000000..4a885352b --- /dev/null +++ b/sdk2/src/liquidation/v0.7/pda.ts @@ -0,0 +1,43 @@ +import { PublicKey } from "@solana/web3.js"; +import { LIQUIDATION_V0_7_PROGRAM_ID } from "../../constants.js"; + +export const getLiquidationAddr = ({ + programId = LIQUIDATION_V0_7_PROGRAM_ID, + baseMint, + quoteMint, + createKey, +}: { + programId?: PublicKey; + baseMint: PublicKey; + quoteMint: PublicKey; + createKey: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("liquidation"), + baseMint.toBuffer(), + quoteMint.toBuffer(), + createKey.toBuffer(), + ], + programId, + ); +}; + +export const getRefundRecordAddr = ({ + programId = LIQUIDATION_V0_7_PROGRAM_ID, + liquidation, + recipient, +}: { + programId?: PublicKey; + liquidation: PublicKey; + recipient: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("refund_record"), + liquidation.toBuffer(), + recipient.toBuffer(), + ], + programId, + ); +}; diff --git a/sdk2/src/liquidation/v0.7/types/index.ts b/sdk2/src/liquidation/v0.7/types/index.ts new file mode 100644 index 000000000..65cd7e412 --- /dev/null +++ b/sdk2/src/liquidation/v0.7/types/index.ts @@ -0,0 +1,12 @@ +import { IdlAccounts } from "@coral-xyz/anchor"; + +import { + Liquidation as LiquidationProgram, + IDL as LiquidationIDL, +} from "./liquidation.js"; + +export { LiquidationProgram, LiquidationIDL }; + +export type LiquidationAccount = IdlAccounts["liquidation"]; +export type RefundRecordAccount = + IdlAccounts["refundRecord"]; diff --git a/sdk2/src/liquidation/v0.7/types/liquidation.ts b/sdk2/src/liquidation/v0.7/types/liquidation.ts new file mode 100644 index 000000000..a83a162cf --- /dev/null +++ b/sdk2/src/liquidation/v0.7/types/liquidation.ts @@ -0,0 +1,1515 @@ +export type Liquidation = { + version: "0.1.0"; + name: "liquidation"; + instructions: [ + { + name: "initializeLiquidation"; + accounts: [ + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "createKey"; + isMut: false; + isSigner: true; + }, + { + name: "recordAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "liquidationAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "liquidation"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLiquidationArgs"; + }; + }, + ]; + }, + { + name: "setRefundRecord"; + accounts: [ + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "recordAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "liquidation"; + isMut: true; + isSigner: false; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "refundRecord"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "SetRefundRecordArgs"; + }; + }, + ]; + }, + { + name: "activateLiquidation"; + accounts: [ + { + name: "liquidationAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "liquidation"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationAuthorityQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "refund"; + accounts: [ + { + name: "recipient"; + isMut: true; + isSigner: true; + }, + { + name: "liquidation"; + isMut: true; + isSigner: false; + }, + { + name: "refundRecord"; + isMut: true; + isSigner: false; + }, + { + name: "recipientBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "recipientQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "withdrawRemainingQuote"; + accounts: [ + { + name: "liquidationAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "liquidation"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "liquidationAuthorityQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "liquidation"; + type: { + kind: "struct"; + fields: [ + { + name: "createKey"; + docs: ["Arbitrary keypair used to make the PDA unique."]; + type: "publicKey"; + }, + { + name: "recordAuthority"; + docs: [ + "The address that can create and modify RefundRecords during setup.", + ]; + type: "publicKey"; + }, + { + name: "liquidationAuthority"; + docs: [ + "The address that activates the liquidation and receives remaining quote tokens post-deadline.", + ]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: ["The project token mint (tokens to be burned)."]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The refund token mint (USDC)."]; + type: "publicKey"; + }, + { + name: "totalQuoteRefundable"; + docs: ["Sum of all RefundRecord quote_refundable values."]; + type: "u64"; + }, + { + name: "totalQuoteRefunded"; + docs: [ + "Sum of all quote tokens actually transferred to users so far.", + ]; + type: "u64"; + }, + { + name: "totalBaseAssigned"; + docs: ["Sum of all RefundRecord base_assigned values."]; + type: "u64"; + }, + { + name: "totalBaseBurned"; + docs: ["Sum of all base tokens actually burned so far."]; + type: "u64"; + }, + { + name: "startedAt"; + docs: [ + "Unix timestamp when ActivateLiquidation was called. 0 before activation.", + ]; + type: "i64"; + }, + { + name: "durationSeconds"; + docs: ["How long the refund window lasts after activation."]; + type: "u32"; + }, + { + name: "seqNum"; + docs: ["Event sequence number for indexing."]; + type: "u64"; + }, + { + name: "isRefunding"; + docs: ["Whether refunds are currently enabled."]; + type: "bool"; + }, + { + name: "pdaBump"; + docs: ["PDA bump seed."]; + type: "u8"; + }, + ]; + }; + }, + { + name: "refundRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidation"; + docs: ["The parent Liquidation account."]; + type: "publicKey"; + }, + { + name: "recipient"; + docs: ["The user this record belongs to."]; + type: "publicKey"; + }, + { + name: "baseAssigned"; + docs: ["Total base tokens this user is eligible to burn."]; + type: "u64"; + }, + { + name: "baseBurned"; + docs: ["Base tokens this user has burned so far."]; + type: "u64"; + }, + { + name: "quoteRefundable"; + docs: [ + "Total quote tokens this user can receive if they burn all assigned base.", + ]; + type: "u64"; + }, + { + name: "quoteRefunded"; + docs: ["Quote tokens already transferred to this user."]; + type: "u64"; + }, + { + name: "pdaBump"; + docs: ["PDA bump seed."]; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "liquidationSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeLiquidationArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "durationSeconds"; + type: "u32"; + }, + ]; + }; + }, + { + name: "SetRefundRecordArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "baseAssigned"; + type: "u64"; + }, + { + name: "quoteRefundable"; + type: "u64"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LiquidationCreatedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "liquidation"; + type: "publicKey"; + index: false; + }, + { + name: "createKey"; + type: "publicKey"; + index: false; + }, + { + name: "recordAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "liquidationAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "durationSeconds"; + type: "u32"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + ]; + }, + { + name: "LiquidationActivatedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "liquidation"; + type: "publicKey"; + index: false; + }, + { + name: "totalQuoteFunded"; + type: "u64"; + index: false; + }, + { + name: "startedAt"; + type: "i64"; + index: false; + }, + ]; + }, + { + name: "RefundRecordSetEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "liquidation"; + type: "publicKey"; + index: false; + }, + { + name: "refundRecord"; + type: "publicKey"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "baseAssigned"; + type: "u64"; + index: false; + }, + { + name: "quoteRefundable"; + type: "u64"; + index: false; + }, + { + name: "liquidationTotalBaseAssigned"; + type: "u64"; + index: false; + }, + { + name: "liquidationTotalQuoteRefundable"; + type: "u64"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + ]; + }, + { + name: "RefundEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "liquidation"; + type: "publicKey"; + index: false; + }, + { + name: "refundRecord"; + type: "publicKey"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "baseBurned"; + type: "u64"; + index: false; + }, + { + name: "quoteRefunded"; + type: "u64"; + index: false; + }, + { + name: "postRecordBaseBurned"; + type: "u64"; + index: false; + }, + { + name: "postRecordQuoteRefunded"; + type: "u64"; + index: false; + }, + { + name: "postLiquidationTotalBaseBurned"; + type: "u64"; + index: false; + }, + { + name: "postLiquidationTotalQuoteRefunded"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "WithdrawRemainingQuoteEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "liquidation"; + type: "publicKey"; + index: false; + }, + { + name: "liquidationAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "RefundingNotEnabled"; + msg: "Refunding is not enabled"; + }, + { + code: 6001; + name: "AlreadyActivated"; + msg: "Liquidation is already activated"; + }, + { + code: 6002; + name: "NothingToFund"; + msg: "No quote tokens to fund"; + }, + { + code: 6003; + name: "NoBaseAssigned"; + msg: "No base tokens assigned"; + }, + { + code: 6004; + name: "RefundWindowExpired"; + msg: "Refund window has expired"; + }, + { + code: 6005; + name: "RefundWindowNotExpired"; + msg: "Refund window has not expired"; + }, + { + code: 6006; + name: "InvalidDuration"; + msg: "Duration must be greater than zero"; + }, + { + code: 6007; + name: "NothingToRefund"; + msg: "Nothing to refund"; + }, + { + code: 6008; + name: "InvalidAllocation"; + msg: "Invalid allocation"; + }, + { + code: 6009; + name: "InvalidAuthority"; + msg: "Invalid authority"; + }, + { + code: 6010; + name: "InvalidMint"; + msg: "Invalid mint"; + }, + ]; +}; + +export const IDL: Liquidation = { + version: "0.1.0", + name: "liquidation", + instructions: [ + { + name: "initializeLiquidation", + accounts: [ + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "createKey", + isMut: false, + isSigner: true, + }, + { + name: "recordAuthority", + isMut: false, + isSigner: false, + }, + { + name: "liquidationAuthority", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "liquidation", + isMut: true, + isSigner: false, + }, + { + name: "liquidationQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLiquidationArgs", + }, + }, + ], + }, + { + name: "setRefundRecord", + accounts: [ + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "recordAuthority", + isMut: false, + isSigner: true, + }, + { + name: "liquidation", + isMut: true, + isSigner: false, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "refundRecord", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "SetRefundRecordArgs", + }, + }, + ], + }, + { + name: "activateLiquidation", + accounts: [ + { + name: "liquidationAuthority", + isMut: false, + isSigner: true, + }, + { + name: "liquidation", + isMut: true, + isSigner: false, + }, + { + name: "liquidationAuthorityQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidationQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "refund", + accounts: [ + { + name: "recipient", + isMut: true, + isSigner: true, + }, + { + name: "liquidation", + isMut: true, + isSigner: false, + }, + { + name: "refundRecord", + isMut: true, + isSigner: false, + }, + { + name: "recipientBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidationQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "recipientQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "withdrawRemainingQuote", + accounts: [ + { + name: "liquidationAuthority", + isMut: false, + isSigner: true, + }, + { + name: "liquidation", + isMut: true, + isSigner: false, + }, + { + name: "liquidationQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "liquidationAuthorityQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "liquidation", + type: { + kind: "struct", + fields: [ + { + name: "createKey", + docs: ["Arbitrary keypair used to make the PDA unique."], + type: "publicKey", + }, + { + name: "recordAuthority", + docs: [ + "The address that can create and modify RefundRecords during setup.", + ], + type: "publicKey", + }, + { + name: "liquidationAuthority", + docs: [ + "The address that activates the liquidation and receives remaining quote tokens post-deadline.", + ], + type: "publicKey", + }, + { + name: "baseMint", + docs: ["The project token mint (tokens to be burned)."], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The refund token mint (USDC)."], + type: "publicKey", + }, + { + name: "totalQuoteRefundable", + docs: ["Sum of all RefundRecord quote_refundable values."], + type: "u64", + }, + { + name: "totalQuoteRefunded", + docs: [ + "Sum of all quote tokens actually transferred to users so far.", + ], + type: "u64", + }, + { + name: "totalBaseAssigned", + docs: ["Sum of all RefundRecord base_assigned values."], + type: "u64", + }, + { + name: "totalBaseBurned", + docs: ["Sum of all base tokens actually burned so far."], + type: "u64", + }, + { + name: "startedAt", + docs: [ + "Unix timestamp when ActivateLiquidation was called. 0 before activation.", + ], + type: "i64", + }, + { + name: "durationSeconds", + docs: ["How long the refund window lasts after activation."], + type: "u32", + }, + { + name: "seqNum", + docs: ["Event sequence number for indexing."], + type: "u64", + }, + { + name: "isRefunding", + docs: ["Whether refunds are currently enabled."], + type: "bool", + }, + { + name: "pdaBump", + docs: ["PDA bump seed."], + type: "u8", + }, + ], + }, + }, + { + name: "refundRecord", + type: { + kind: "struct", + fields: [ + { + name: "liquidation", + docs: ["The parent Liquidation account."], + type: "publicKey", + }, + { + name: "recipient", + docs: ["The user this record belongs to."], + type: "publicKey", + }, + { + name: "baseAssigned", + docs: ["Total base tokens this user is eligible to burn."], + type: "u64", + }, + { + name: "baseBurned", + docs: ["Base tokens this user has burned so far."], + type: "u64", + }, + { + name: "quoteRefundable", + docs: [ + "Total quote tokens this user can receive if they burn all assigned base.", + ], + type: "u64", + }, + { + name: "quoteRefunded", + docs: ["Quote tokens already transferred to this user."], + type: "u64", + }, + { + name: "pdaBump", + docs: ["PDA bump seed."], + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "liquidationSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeLiquidationArgs", + type: { + kind: "struct", + fields: [ + { + name: "durationSeconds", + type: "u32", + }, + ], + }, + }, + { + name: "SetRefundRecordArgs", + type: { + kind: "struct", + fields: [ + { + name: "baseAssigned", + type: "u64", + }, + { + name: "quoteRefundable", + type: "u64", + }, + ], + }, + }, + ], + events: [ + { + name: "LiquidationCreatedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "liquidation", + type: "publicKey", + index: false, + }, + { + name: "createKey", + type: "publicKey", + index: false, + }, + { + name: "recordAuthority", + type: "publicKey", + index: false, + }, + { + name: "liquidationAuthority", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "durationSeconds", + type: "u32", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + ], + }, + { + name: "LiquidationActivatedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "liquidation", + type: "publicKey", + index: false, + }, + { + name: "totalQuoteFunded", + type: "u64", + index: false, + }, + { + name: "startedAt", + type: "i64", + index: false, + }, + ], + }, + { + name: "RefundRecordSetEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "liquidation", + type: "publicKey", + index: false, + }, + { + name: "refundRecord", + type: "publicKey", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "baseAssigned", + type: "u64", + index: false, + }, + { + name: "quoteRefundable", + type: "u64", + index: false, + }, + { + name: "liquidationTotalBaseAssigned", + type: "u64", + index: false, + }, + { + name: "liquidationTotalQuoteRefundable", + type: "u64", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + ], + }, + { + name: "RefundEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "liquidation", + type: "publicKey", + index: false, + }, + { + name: "refundRecord", + type: "publicKey", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "baseBurned", + type: "u64", + index: false, + }, + { + name: "quoteRefunded", + type: "u64", + index: false, + }, + { + name: "postRecordBaseBurned", + type: "u64", + index: false, + }, + { + name: "postRecordQuoteRefunded", + type: "u64", + index: false, + }, + { + name: "postLiquidationTotalBaseBurned", + type: "u64", + index: false, + }, + { + name: "postLiquidationTotalQuoteRefunded", + type: "u64", + index: false, + }, + ], + }, + { + name: "WithdrawRemainingQuoteEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "liquidation", + type: "publicKey", + index: false, + }, + { + name: "liquidationAuthority", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "RefundingNotEnabled", + msg: "Refunding is not enabled", + }, + { + code: 6001, + name: "AlreadyActivated", + msg: "Liquidation is already activated", + }, + { + code: 6002, + name: "NothingToFund", + msg: "No quote tokens to fund", + }, + { + code: 6003, + name: "NoBaseAssigned", + msg: "No base tokens assigned", + }, + { + code: 6004, + name: "RefundWindowExpired", + msg: "Refund window has expired", + }, + { + code: 6005, + name: "RefundWindowNotExpired", + msg: "Refund window has not expired", + }, + { + code: 6006, + name: "InvalidDuration", + msg: "Duration must be greater than zero", + }, + { + code: 6007, + name: "NothingToRefund", + msg: "Nothing to refund", + }, + { + code: 6008, + name: "InvalidAllocation", + msg: "Invalid allocation", + }, + { + code: 6009, + name: "InvalidAuthority", + msg: "Invalid authority", + }, + { + code: 6010, + name: "InvalidMint", + msg: "Invalid mint", + }, + ], +}; diff --git a/sdk2/src/mint_governor/index.ts b/sdk2/src/mint_governor/index.ts new file mode 100644 index 000000000..6b187d27b --- /dev/null +++ b/sdk2/src/mint_governor/index.ts @@ -0,0 +1 @@ +export * from "./v0.7/index.js"; diff --git a/sdk2/src/mint_governor/v0.7/MintGovernorClient.ts b/sdk2/src/mint_governor/v0.7/MintGovernorClient.ts new file mode 100644 index 000000000..78f070135 --- /dev/null +++ b/sdk2/src/mint_governor/v0.7/MintGovernorClient.ts @@ -0,0 +1,251 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { AccountInfo, PublicKey } from "@solana/web3.js"; +import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; +import { MINT_GOVERNOR_V0_7_PROGRAM_ID } from "../../constants.js"; +import { getMintGovernorAddr, getMintAuthorityAddr } from "./pda.js"; +import BN from "bn.js"; +import { + MintGovernor as MintGovernorProgram, + IDL as MintGovernorIDL, +} from "./types/mint_governor.js"; +import type { + MintGovernorAccount, + MintAuthorityAccount, +} from "./types/index.js"; + +export type CreateMintGovernorClientParams = { + provider: AnchorProvider; + programId?: PublicKey; +}; + +export class MintGovernorClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly programId: PublicKey; + + constructor(provider: AnchorProvider, programId: PublicKey) { + this.provider = provider; + this.programId = programId; + this.program = new Program( + MintGovernorIDL, + programId, + provider, + ); + } + + public static createClient( + params: CreateMintGovernorClientParams, + ): MintGovernorClient { + const { provider, programId } = params; + return new MintGovernorClient( + provider, + programId || MINT_GOVERNOR_V0_7_PROGRAM_ID, + ); + } + + async fetchMintGovernor( + mintGovernor: PublicKey, + ): Promise { + return this.program.account.mintGovernor.fetchNullable(mintGovernor); + } + + async deserializeMintGovernor( + accountInfo: AccountInfo, + ): Promise { + return this.program.coder.accounts.decode("mintGovernor", accountInfo.data); + } + + async fetchMintAuthority( + mintAuthority: PublicKey, + ): Promise { + return this.program.account.mintAuthority.fetchNullable(mintAuthority); + } + + async deserializeMintAuthority( + accountInfo: AccountInfo, + ): Promise { + return this.program.coder.accounts.decode( + "mintAuthority", + accountInfo.data, + ); + } + + initializeMintGovernorIx({ + mint, + createKey, + admin, + payer = this.provider.publicKey, + }: { + mint: PublicKey; + createKey: PublicKey; + admin: PublicKey; + payer?: PublicKey; + }) { + const [mintGovernor] = getMintGovernorAddr({ + programId: this.programId, + mint, + createKey, + }); + + return this.program.methods.initializeMintGovernor().accounts({ + mint, + mintGovernor, + createKey, + admin, + payer, + }); + } + + transferAuthorityToGovernorIx({ + mintGovernor, + mint, + currentAuthority, + tokenProgram = TOKEN_PROGRAM_ID, + }: { + mintGovernor: PublicKey; + mint: PublicKey; + currentAuthority: PublicKey; + tokenProgram?: PublicKey; + }) { + return this.program.methods.transferAuthorityToGovernor().accounts({ + mintGovernor, + mint, + currentAuthority, + tokenProgram, + }); + } + + addMintAuthorityIx({ + mintGovernor, + admin, + authorizedMinter, + payer = this.provider.publicKey, + maxTotal, + }: { + mintGovernor: PublicKey; + admin: PublicKey; + authorizedMinter: PublicKey; + payer?: PublicKey; + maxTotal: BN | null; + }) { + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.programId, + mintGovernor, + authorizedMinter, + }); + + return this.program.methods.addMintAuthority({ maxTotal }).accounts({ + mintGovernor, + mintAuthority, + admin, + authorizedMinter, + payer, + }); + } + + updateMintAuthorityIx({ + mintGovernor, + mintAuthority, + admin, + maxTotal, + }: { + mintGovernor: PublicKey; + mintAuthority: PublicKey; + admin: PublicKey; + maxTotal: BN | null; + }) { + return this.program.methods.updateMintAuthority({ maxTotal }).accounts({ + mintGovernor, + mintAuthority, + admin, + }); + } + + removeMintAuthorityIx({ + mintGovernor, + mintAuthority, + admin, + rentDestination, + }: { + mintGovernor: PublicKey; + mintAuthority: PublicKey; + admin: PublicKey; + rentDestination: PublicKey; + }) { + return this.program.methods.removeMintAuthority().accounts({ + mintGovernor, + mintAuthority, + admin, + rentDestination, + }); + } + + mintTokensIx({ + mintGovernor, + mint, + destinationAta, + authorizedMinter, + tokenProgram = TOKEN_PROGRAM_ID, + amount, + }: { + mintGovernor: PublicKey; + mint: PublicKey; + destinationAta: PublicKey; + authorizedMinter: PublicKey; + tokenProgram?: PublicKey; + amount: BN; + }) { + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.programId, + mintGovernor, + authorizedMinter, + }); + + return this.program.methods.mintTokens({ amount }).accounts({ + mintGovernor, + mintAuthority, + mint, + destinationAta, + authorizedMinter, + tokenProgram, + }); + } + + updateMintGovernorAdminIx({ + mintGovernor, + admin, + newAdmin, + }: { + mintGovernor: PublicKey; + admin: PublicKey; + newAdmin: PublicKey; + }) { + return this.program.methods.updateMintGovernorAdmin().accounts({ + mintGovernor, + admin, + newAdmin, + }); + } + + reclaimAuthorityIx({ + mintGovernor, + mint, + admin, + newAuthority, + tokenProgram = TOKEN_PROGRAM_ID, + }: { + mintGovernor: PublicKey; + mint: PublicKey; + admin: PublicKey; + newAuthority: PublicKey; + tokenProgram?: PublicKey; + }) { + return this.program.methods.reclaimAuthority().accounts({ + mintGovernor, + mint, + admin, + newAuthority, + tokenProgram, + }); + } +} diff --git a/sdk2/src/mint_governor/v0.7/index.ts b/sdk2/src/mint_governor/v0.7/index.ts new file mode 100644 index 000000000..ad86e24c4 --- /dev/null +++ b/sdk2/src/mint_governor/v0.7/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./MintGovernorClient.js"; diff --git a/sdk2/src/mint_governor/v0.7/pda.ts b/sdk2/src/mint_governor/v0.7/pda.ts new file mode 100644 index 000000000..9bc4247af --- /dev/null +++ b/sdk2/src/mint_governor/v0.7/pda.ts @@ -0,0 +1,36 @@ +import { PublicKey } from "@solana/web3.js"; +import { MINT_GOVERNOR_V0_7_PROGRAM_ID } from "../../constants.js"; + +export const getMintGovernorAddr = ({ + programId = MINT_GOVERNOR_V0_7_PROGRAM_ID, + mint, + createKey, +}: { + programId?: PublicKey; + mint: PublicKey; + createKey: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [Buffer.from("mint_governor"), mint.toBuffer(), createKey.toBuffer()], + programId, + ); +}; + +export const getMintAuthorityAddr = ({ + programId = MINT_GOVERNOR_V0_7_PROGRAM_ID, + mintGovernor, + authorizedMinter, +}: { + programId?: PublicKey; + mintGovernor: PublicKey; + authorizedMinter: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("mint_authority"), + mintGovernor.toBuffer(), + authorizedMinter.toBuffer(), + ], + programId, + ); +}; diff --git a/sdk2/src/mint_governor/v0.7/types/index.ts b/sdk2/src/mint_governor/v0.7/types/index.ts new file mode 100644 index 000000000..ce730c722 --- /dev/null +++ b/sdk2/src/mint_governor/v0.7/types/index.ts @@ -0,0 +1,37 @@ +import { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; +import { + MintGovernor as MintGovernorProgram, + IDL as MintGovernorIDL, +} from "./mint_governor.js"; +export { MintGovernorProgram, MintGovernorIDL }; + +export type MintGovernorAccount = + IdlAccounts["mintGovernor"]; +export type MintAuthorityAccount = + IdlAccounts["mintAuthority"]; + +export type MintGovernorInitializedEvent = + IdlEvents["MintGovernorInitializedEvent"]; +export type MintAuthorityTransferredEvent = + IdlEvents["MintAuthorityTransferredEvent"]; +export type MintAuthorityAddedEvent = + IdlEvents["MintAuthorityAddedEvent"]; +export type TokensMintedEvent = + IdlEvents["TokensMintedEvent"]; +export type MintAuthorityUpdatedEvent = + IdlEvents["MintAuthorityUpdatedEvent"]; +export type MintAuthorityRemovedEvent = + IdlEvents["MintAuthorityRemovedEvent"]; +export type MintGovernorAdminUpdatedEvent = + IdlEvents["MintGovernorAdminUpdatedEvent"]; +export type MintAuthorityReclaimedEvent = + IdlEvents["MintAuthorityReclaimedEvent"]; +export type MintGovernorEvent = + | MintGovernorInitializedEvent + | MintAuthorityTransferredEvent + | MintAuthorityAddedEvent + | TokensMintedEvent + | MintAuthorityUpdatedEvent + | MintAuthorityRemovedEvent + | MintGovernorAdminUpdatedEvent + | MintAuthorityReclaimedEvent; diff --git a/sdk2/src/mint_governor/v0.7/types/mint_governor.ts b/sdk2/src/mint_governor/v0.7/types/mint_governor.ts new file mode 100644 index 000000000..b2d9b02c2 --- /dev/null +++ b/sdk2/src/mint_governor/v0.7/types/mint_governor.ts @@ -0,0 +1,1473 @@ +export type MintGovernor = { + version: "0.7.0"; + name: "mint_governor"; + instructions: [ + { + name: "initializeMintGovernor"; + accounts: [ + { + name: "mint"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "createKey"; + isMut: false; + isSigner: true; + }, + { + name: "admin"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "transferAuthorityToGovernor"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mint"; + isMut: true; + isSigner: false; + }, + { + name: "currentAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "addMintAuthority"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "authorizedMinter"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddMintAuthorityArgs"; + }; + }, + ]; + }, + { + name: "mintTokens"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "mint"; + isMut: true; + isSigner: false; + }, + { + name: "destinationAta"; + isMut: true; + isSigner: false; + }, + { + name: "authorizedMinter"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "MintTokensArgs"; + }; + }, + ]; + }, + { + name: "updateMintAuthority"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "UpdateMintAuthorityArgs"; + }; + }, + ]; + }, + { + name: "removeMintAuthority"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "rentDestination"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateMintGovernorAdmin"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "newAdmin"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "reclaimAuthority"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mint"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "newAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "mintAuthority"; + type: { + kind: "struct"; + fields: [ + { + name: "mintGovernor"; + type: "publicKey"; + }, + { + name: "authorizedMinter"; + type: "publicKey"; + }, + { + name: "maxTotal"; + type: { + option: "u64"; + }; + }, + { + name: "totalMinted"; + type: "u64"; + }, + { + name: "bump"; + type: "u8"; + }, + ]; + }; + }, + { + name: "mintGovernor"; + type: { + kind: "struct"; + fields: [ + { + name: "mint"; + type: "publicKey"; + }, + { + name: "admin"; + type: "publicKey"; + }, + { + name: "createKey"; + type: "publicKey"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "bump"; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "mintGovernorSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "AddMintAuthorityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "maxTotal"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "MintTokensArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateMintAuthorityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "maxTotal"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + ]; + events: [ + { + name: "MintGovernorInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mint"; + type: "publicKey"; + index: false; + }, + { + name: "admin"; + type: "publicKey"; + index: false; + }, + { + name: "createKey"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + ]; + }, + { + name: "MintAuthorityTransferredEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mint"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "MintAuthorityAddedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mintAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "authorizedMinter"; + type: "publicKey"; + index: false; + }, + { + name: "maxTotal"; + type: { + option: "u64"; + }; + index: false; + }, + ]; + }, + { + name: "TokensMintedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mint"; + type: "publicKey"; + index: false; + }, + { + name: "authorizedMinter"; + type: "publicKey"; + index: false; + }, + { + name: "destinationAta"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "postTotalMinted"; + type: "u64"; + index: false; + }, + { + name: "postMintSupply"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "MintAuthorityUpdatedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mintAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "authorizedMinter"; + type: "publicKey"; + index: false; + }, + { + name: "maxTotal"; + type: { + option: "u64"; + }; + index: false; + }, + ]; + }, + { + name: "MintAuthorityRemovedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "authorizedMinter"; + type: "publicKey"; + index: false; + }, + { + name: "totalMinted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "MintGovernorAdminUpdatedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "newAdmin"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "MintAuthorityReclaimedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mint"; + type: "publicKey"; + index: false; + }, + { + name: "newAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "UnauthorizedAdmin"; + msg: "Unauthorized: signer is not the admin"; + }, + { + code: 6001; + name: "UnauthorizedMinter"; + msg: "Unauthorized: signer is not the authorized minter"; + }, + { + code: 6002; + name: "MintMismatch"; + msg: "Mint mismatch: mint_governor.mint does not match provided mint"; + }, + { + code: 6003; + name: "MintLimitExceeded"; + msg: "Mint limit exceeded: would exceed max_total"; + }, + ]; +}; + +export const IDL: MintGovernor = { + version: "0.7.0", + name: "mint_governor", + instructions: [ + { + name: "initializeMintGovernor", + accounts: [ + { + name: "mint", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "createKey", + isMut: false, + isSigner: true, + }, + { + name: "admin", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "transferAuthorityToGovernor", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mint", + isMut: true, + isSigner: false, + }, + { + name: "currentAuthority", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "addMintAuthority", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "authorizedMinter", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddMintAuthorityArgs", + }, + }, + ], + }, + { + name: "mintTokens", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "mint", + isMut: true, + isSigner: false, + }, + { + name: "destinationAta", + isMut: true, + isSigner: false, + }, + { + name: "authorizedMinter", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "MintTokensArgs", + }, + }, + ], + }, + { + name: "updateMintAuthority", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "UpdateMintAuthorityArgs", + }, + }, + ], + }, + { + name: "removeMintAuthority", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "rentDestination", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateMintGovernorAdmin", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "newAdmin", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "reclaimAuthority", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mint", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "newAuthority", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "mintAuthority", + type: { + kind: "struct", + fields: [ + { + name: "mintGovernor", + type: "publicKey", + }, + { + name: "authorizedMinter", + type: "publicKey", + }, + { + name: "maxTotal", + type: { + option: "u64", + }, + }, + { + name: "totalMinted", + type: "u64", + }, + { + name: "bump", + type: "u8", + }, + ], + }, + }, + { + name: "mintGovernor", + type: { + kind: "struct", + fields: [ + { + name: "mint", + type: "publicKey", + }, + { + name: "admin", + type: "publicKey", + }, + { + name: "createKey", + type: "publicKey", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "bump", + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "mintGovernorSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "AddMintAuthorityArgs", + type: { + kind: "struct", + fields: [ + { + name: "maxTotal", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "MintTokensArgs", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateMintAuthorityArgs", + type: { + kind: "struct", + fields: [ + { + name: "maxTotal", + type: { + option: "u64", + }, + }, + ], + }, + }, + ], + events: [ + { + name: "MintGovernorInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mint", + type: "publicKey", + index: false, + }, + { + name: "admin", + type: "publicKey", + index: false, + }, + { + name: "createKey", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + ], + }, + { + name: "MintAuthorityTransferredEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mint", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "MintAuthorityAddedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mintAuthority", + type: "publicKey", + index: false, + }, + { + name: "authorizedMinter", + type: "publicKey", + index: false, + }, + { + name: "maxTotal", + type: { + option: "u64", + }, + index: false, + }, + ], + }, + { + name: "TokensMintedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mint", + type: "publicKey", + index: false, + }, + { + name: "authorizedMinter", + type: "publicKey", + index: false, + }, + { + name: "destinationAta", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "postTotalMinted", + type: "u64", + index: false, + }, + { + name: "postMintSupply", + type: "u64", + index: false, + }, + ], + }, + { + name: "MintAuthorityUpdatedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mintAuthority", + type: "publicKey", + index: false, + }, + { + name: "authorizedMinter", + type: "publicKey", + index: false, + }, + { + name: "maxTotal", + type: { + option: "u64", + }, + index: false, + }, + ], + }, + { + name: "MintAuthorityRemovedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "authorizedMinter", + type: "publicKey", + index: false, + }, + { + name: "totalMinted", + type: "u64", + index: false, + }, + ], + }, + { + name: "MintGovernorAdminUpdatedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "newAdmin", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "MintAuthorityReclaimedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mint", + type: "publicKey", + index: false, + }, + { + name: "newAuthority", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "UnauthorizedAdmin", + msg: "Unauthorized: signer is not the admin", + }, + { + code: 6001, + name: "UnauthorizedMinter", + msg: "Unauthorized: signer is not the authorized minter", + }, + { + code: 6002, + name: "MintMismatch", + msg: "Mint mismatch: mint_governor.mint does not match provided mint", + }, + { + code: 6003, + name: "MintLimitExceeded", + msg: "Mint limit exceeded: would exceed max_total", + }, + ], +}; diff --git a/sdk2/src/price_based_performance_package/index.ts b/sdk2/src/price_based_performance_package/index.ts new file mode 100644 index 000000000..f77abe821 --- /dev/null +++ b/sdk2/src/price_based_performance_package/index.ts @@ -0,0 +1 @@ +export * from "./v0.6/index.js"; diff --git a/sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts b/sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts new file mode 100644 index 000000000..389150a27 --- /dev/null +++ b/sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts @@ -0,0 +1,225 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + PublicKey, + Transaction, + TransactionInstruction, + SystemProgram, +} from "@solana/web3.js"; +import { + TOKEN_PROGRAM_ID, + ASSOCIATED_TOKEN_PROGRAM_ID, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import { + PriceBasedPerformancePackage, + IDL as PriceBasedPerformancePackageIDL, +} from "./types/price_based_performance_package.js"; +import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID } from "../../constants.js"; +import BN from "bn.js"; +// import { OracleConfig } from "./types/index.js"; +import { getChangeRequestAddr, getPerformancePackageAddr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { InitializePerformancePackageParams } from "./types/index.js"; + +export type CreatePriceBasedPerformancePackageClientParams = { + provider: AnchorProvider; + priceBasedTokenLockProgramId?: PublicKey; +}; + +export class PriceBasedPerformancePackageClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly programId: PublicKey; + + constructor( + provider: AnchorProvider, + priceBasedTokenLockProgramId: PublicKey, + ) { + this.provider = provider; + this.programId = priceBasedTokenLockProgramId; + this.program = new Program( + PriceBasedPerformancePackageIDL, + priceBasedTokenLockProgramId, + provider, + ); + } + + public static createClient( + createClientParams: CreatePriceBasedPerformancePackageClientParams, + ): PriceBasedPerformancePackageClient { + let { provider, priceBasedTokenLockProgramId } = createClientParams; + + if (!priceBasedTokenLockProgramId) { + priceBasedTokenLockProgramId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID; + } + + return new PriceBasedPerformancePackageClient( + provider, + priceBasedTokenLockProgramId, + ); + } + + public initializePerformancePackageIx(params: { + params: InitializePerformancePackageParams; + createKey: PublicKey; + tokenMint: PublicKey; + grantor: PublicKey; + grantorTokenAccount?: PublicKey; + }) { + const performancePackage = getPerformancePackageAddr({ + createKey: params.createKey, + })[0]; + + const grantorTokenAccount = + params.grantorTokenAccount ?? + getAssociatedTokenAddressSync(params.tokenMint, params.grantor, true); + + return this.program.methods + .initializePerformancePackage(params.params) + .accounts({ + performancePackage, + createKey: params.createKey, + tokenMint: params.tokenMint, + grantorTokenAccount, + performancePackageTokenVault: getAssociatedTokenAddressSync( + params.tokenMint, + performancePackage, + true, + ), + grantor: params.grantor, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + }); + } + + public startUnlockIx(params: { + performancePackage: PublicKey; + oracleAccount: PublicKey; + recipient: PublicKey; + }) { + return this.program.methods.startUnlock().accounts({ + performancePackage: params.performancePackage, + oracleAccount: params.oracleAccount, + recipient: params.recipient, + }); + } + + public completeUnlockIx(params: { + performancePackage: PublicKey; + oracleAccount: PublicKey; + tokenMint: PublicKey; + tokenRecipient: PublicKey; + }) { + return this.program.methods.completeUnlock().accounts({ + performancePackage: params.performancePackage, + oracleAccount: params.oracleAccount, + performancePackageTokenVault: getAssociatedTokenAddressSync( + params.tokenMint, + params.performancePackage, + true, + ), + tokenMint: params.tokenMint, + recipientTokenAccount: getAssociatedTokenAddressSync( + params.tokenMint, + params.tokenRecipient, + true, + ), + tokenRecipient: params.tokenRecipient, + systemProgram: SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + }); + } + + public proposeChangeIx(params: { + params: { + changeType: any; + pdaNonce: number; + }; + performancePackage: PublicKey; + proposer: PublicKey; + }) { + const changeRequestAddress = this.getChangeRequestAddress( + params.performancePackage, + params.proposer, + params.params.pdaNonce, + ); + + return this.program.methods.proposeChange(params.params).accounts({ + changeRequest: changeRequestAddress, + performancePackage: params.performancePackage, + proposer: params.proposer, + systemProgram: SystemProgram.programId, + }); + } + + public executeChangeIx(params: { + performancePackage: PublicKey; + changeRequest: PublicKey; + executor: PublicKey; + }) { + return this.program.methods.executeChange().accounts({ + changeRequest: params.changeRequest, + performancePackage: params.performancePackage, + executor: params.executor, + }); + } + + public changePerformancePackageAuthorityIx(params: { + performancePackage: PublicKey; + currentAuthority: PublicKey; + newPerformancePackageAuthority: PublicKey; + }) { + return this.program.methods + .changePerformancePackageAuthority({ + newPerformancePackageAuthority: params.newPerformancePackageAuthority, + }) + .accounts({ + performancePackage: params.performancePackage, + currentAuthority: params.currentAuthority, + }); + } + + public async getPerformancePackage(performancePackageAddress: PublicKey) { + return await this.program.account.performancePackage.fetch( + performancePackageAddress, + ); + } + + public async getChangeRequest(changeRequestAddress: PublicKey) { + return await this.program.account.changeRequest.fetch(changeRequestAddress); + } + + public getChangeRequestAddress( + performancePackage: PublicKey, + proposer: PublicKey, + pdaNonce: number, + ): PublicKey { + const [changeRequestAddress] = getChangeRequestAddr({ + programId: this.programId, + performancePackage, + proposer, + pdaNonce, + }); + return changeRequestAddress; + } + + public getPerformancePackageTokenAccountAddress( + performancePackage: PublicKey, + ): PublicKey { + const [performancePackageTokenAccountAddress] = + PublicKey.findProgramAddressSync( + [ + Buffer.from("performance_package_token_account"), + performancePackage.toBuffer(), + ], + this.programId, + ); + return performancePackageTokenAccountAddress; + } + + public getEventAuthorityAddress(): PublicKey { + return getEventAuthorityAddr(this.programId)[0]; + } +} diff --git a/sdk2/src/price_based_performance_package/v0.6/index.ts b/sdk2/src/price_based_performance_package/v0.6/index.ts new file mode 100644 index 000000000..4b649117c --- /dev/null +++ b/sdk2/src/price_based_performance_package/v0.6/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./PriceBasedPerformancePackageClient.js"; diff --git a/sdk2/src/price_based_performance_package/v0.6/pda.ts b/sdk2/src/price_based_performance_package/v0.6/pda.ts new file mode 100644 index 000000000..910b8577d --- /dev/null +++ b/sdk2/src/price_based_performance_package/v0.6/pda.ts @@ -0,0 +1,38 @@ +import { PublicKey } from "@solana/web3.js"; + +import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID } from "../../constants.js"; + +export const getPerformancePackageAddr = ({ + programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, + createKey, +}: { + programId?: PublicKey; + createKey: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [Buffer.from("performance_package"), createKey.toBuffer()], + programId, + ); +}; + +export const getChangeRequestAddr = ({ + programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, + performancePackage, + proposer, + pdaNonce, +}: { + programId?: PublicKey; + performancePackage: PublicKey; + proposer: PublicKey; + pdaNonce: number; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("change_request"), + performancePackage.toBuffer(), + proposer.toBuffer(), + Buffer.from(new Uint8Array(new Uint32Array([pdaNonce]).buffer)), + ], + programId, + ); +}; diff --git a/sdk2/src/price_based_performance_package/v0.6/types/index.ts b/sdk2/src/price_based_performance_package/v0.6/types/index.ts new file mode 100644 index 000000000..25186353e --- /dev/null +++ b/sdk2/src/price_based_performance_package/v0.6/types/index.ts @@ -0,0 +1,35 @@ +import { IdlAccounts, IdlEvents, IdlTypes } from "@coral-xyz/anchor"; + +import { + PriceBasedPerformancePackage as PriceBasedPerformancePackageProgram, + IDL as PriceBasedPerformancePackageIDL, +} from "./price_based_performance_package.js"; +export { PriceBasedPerformancePackageProgram, PriceBasedPerformancePackageIDL }; + +export type InitializePerformancePackageParams = + IdlTypes["InitializePerformancePackageParams"]; +export type PerformancePackage = + IdlAccounts["performancePackage"]; +export type OracleConfig = + IdlTypes["OracleConfig"]; +export type Tranche = IdlTypes["Tranche"]; + +export type PerformancePackageInitializedEvent = + IdlEvents["PerformancePackageInitialized"]; +export type UnlockStartedEvent = + IdlEvents["UnlockStarted"]; +export type UnlockCompletedEvent = + IdlEvents["UnlockCompleted"]; +export type ChangeProposedEvent = + IdlEvents["ChangeProposed"]; +export type ChangeExecutedEvent = + IdlEvents["ChangeExecuted"]; +export type PerformancePackageAuthorityChangedEvent = + IdlEvents["PerformancePackageAuthorityChanged"]; +export type PriceBasedPerformancePackageEvent = + | PerformancePackageInitializedEvent + | UnlockStartedEvent + | UnlockCompletedEvent + | ChangeProposedEvent + | ChangeExecutedEvent + | PerformancePackageAuthorityChangedEvent; diff --git a/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts b/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts new file mode 100644 index 000000000..16224ab94 --- /dev/null +++ b/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts @@ -0,0 +1,1941 @@ +export type PriceBasedPerformancePackage = { + version: "0.6.0"; + name: "price_based_performance_package"; + constants: [ + { + name: "MAX_TRANCHES"; + type: { + defined: "usize"; + }; + value: "10"; + }, + ]; + instructions: [ + { + name: "initializePerformancePackage"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "createKey"; + isMut: false; + isSigner: true; + docs: ["Used to derive the PDA"]; + }, + { + name: "tokenMint"; + isMut: false; + isSigner: false; + docs: ["The mint of the tokens to be locked"]; + }, + { + name: "grantorTokenAccount"; + isMut: true; + isSigner: false; + docs: ["The token account containing the tokens to be locked"]; + }, + { + name: "grantor"; + isMut: false; + isSigner: true; + docs: ["The authority of the token account"]; + }, + { + name: "performancePackageTokenVault"; + isMut: true; + isSigner: false; + docs: ["The locker's token account where tokens will be stored"]; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializePerformancePackageParams"; + }; + }, + ]; + }, + { + name: "startUnlock"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "oracleAccount"; + isMut: false; + isSigner: false; + }, + { + name: "recipient"; + isMut: false; + isSigner: true; + docs: ["Only the token recipient can start unlock"]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "completeUnlock"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "oracleAccount"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageTokenVault"; + isMut: true; + isSigner: false; + docs: ["The token account where locked tokens are stored"]; + }, + { + name: "tokenMint"; + isMut: false; + isSigner: false; + docs: ["The token mint - validated via has_one constraint on locker"]; + }, + { + name: "recipientTokenAccount"; + isMut: true; + isSigner: false; + docs: [ + "The recipient's ATA where tokens will be sent - created if needed", + ]; + }, + { + name: "tokenRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + docs: ["Payer for creating the ATA if needed"]; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "proposeChange"; + accounts: [ + { + name: "changeRequest"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ProposeChangeParams"; + }; + }, + ]; + }, + { + name: "executeChange"; + accounts: [ + { + name: "changeRequest"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "executor"; + isMut: true; + isSigner: true; + docs: [ + "The party executing the change (must be opposite of proposer)", + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "changePerformancePackageAuthority"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "currentAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ChangePerformancePackageAuthorityParams"; + }; + }, + ]; + }, + { + name: "burnPerformancePackage"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackageTokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: true; + isSigner: true; + }, + { + name: "spillAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "performancePackage"; + type: { + kind: "struct"; + fields: [ + { + name: "tranches"; + docs: ["The tranches that make up the performance package"]; + type: { + vec: { + defined: "StoredTranche"; + }; + }; + }, + { + name: "totalTokenAmount"; + docs: ["Total amount of tokens in the performance package"]; + type: "u64"; + }, + { + name: "alreadyUnlockedAmount"; + docs: ["Amount of tokens already unlocked"]; + type: "u64"; + }, + { + name: "minUnlockTimestamp"; + docs: ["The timestamp when unlocking can begin"]; + type: "i64"; + }, + { + name: "oracleConfig"; + docs: ["Where to pull price data from"]; + type: { + defined: "OracleConfig"; + }; + }, + { + name: "twapLengthSeconds"; + docs: [ + "Length of time in seconds for TWAP calculation, between 1 day and 1 year", + ]; + type: "u32"; + }, + { + name: "recipient"; + docs: ["The recipient of the tokens when unlocked"]; + type: "publicKey"; + }, + { + name: "state"; + docs: ["The current state of the locker"]; + type: { + defined: "PerformancePackageState"; + }; + }, + { + name: "createKey"; + docs: ["Used to derive the PDA"]; + type: "publicKey"; + }, + { + name: "pdaBump"; + docs: ["The PDA bump"]; + type: "u8"; + }, + { + name: "performancePackageAuthority"; + docs: [ + "The authorized locker authority that can execute changes, usually the organization", + ]; + type: "publicKey"; + }, + { + name: "tokenMint"; + docs: ["The mint of the locked tokens"]; + type: "publicKey"; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of the performance package, used for indexing events", + ]; + type: "u64"; + }, + { + name: "performancePackageTokenVault"; + docs: ["The vault that stores the tokens"]; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "changeRequest"; + type: { + kind: "struct"; + fields: [ + { + name: "performancePackage"; + docs: ["The performance package this change applies to"]; + type: "publicKey"; + }, + { + name: "changeType"; + docs: ["What is being changed"]; + type: { + defined: "ChangeType"; + }; + }, + { + name: "proposedAt"; + docs: ["When the change was proposed"]; + type: "i64"; + }, + { + name: "proposerType"; + docs: [ + "Who proposed this change (either token_recipient or locker_authority)", + ]; + type: { + defined: "ProposerType"; + }; + }, + { + name: "pdaNonce"; + docs: ["Used to derive the PDA along with the proposer"]; + type: "u32"; + }, + { + name: "pdaBump"; + docs: ["The PDA bump"]; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "performancePackageSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "ChangePerformancePackageAuthorityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "newPerformancePackageAuthority"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "InitializePerformancePackageParams"; + type: { + kind: "struct"; + fields: [ + { + name: "tranches"; + type: { + vec: { + defined: "Tranche"; + }; + }; + }, + { + name: "minUnlockTimestamp"; + type: "i64"; + }, + { + name: "oracleConfig"; + type: { + defined: "OracleConfig"; + }; + }, + { + name: "twapLengthSeconds"; + type: "u32"; + }, + { + name: "grantee"; + type: "publicKey"; + }, + { + name: "performancePackageAuthority"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "ProposeChangeParams"; + type: { + kind: "struct"; + fields: [ + { + name: "changeType"; + type: { + defined: "ChangeType"; + }; + }, + { + name: "pdaNonce"; + type: "u32"; + }, + ]; + }; + }, + { + name: "OracleConfig"; + docs: [ + "Starting at `byte_offset` in `oracle_account`, this program expects to read:", + "- 16 bytes for the aggregator, stored as a little endian u128", + "- 8 bytes for the slot that the aggregator was last updated, stored as a", + "little endian u64", + "", + "The aggregator should be a weighted sum of prices, where the weight is the", + "number of seconds between prices. Here's an example:", + "- at second 0, the aggregator is 0", + "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", + "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", + "10 + 11 * 3 = 43", + "", + "This allows our program to read a TWAP over a time period by reading the", + "aggregator value at the beginning and at the end, and dividing the difference", + "by the number of seconds between the two.", + ]; + type: { + kind: "struct"; + fields: [ + { + name: "oracleAccount"; + type: "publicKey"; + }, + { + name: "byteOffset"; + type: "u32"; + }, + ]; + }; + }, + { + name: "Tranche"; + type: { + kind: "struct"; + fields: [ + { + name: "priceThreshold"; + docs: ["The price at which this tranch unlocks"]; + type: "u128"; + }, + { + name: "tokenAmount"; + docs: ["The amount of tokens in this tranch"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "StoredTranche"; + type: { + kind: "struct"; + fields: [ + { + name: "priceThreshold"; + type: "u128"; + }, + { + name: "tokenAmount"; + type: "u64"; + }, + { + name: "isUnlocked"; + type: "bool"; + }, + ]; + }; + }, + { + name: "PerformancePackageState"; + type: { + kind: "enum"; + variants: [ + { + name: "Locked"; + }, + { + name: "Unlocking"; + fields: [ + { + name: "startAggregator"; + docs: ["The aggregator value when unlocking started"]; + type: "u128"; + }, + { + name: "startTimestamp"; + docs: ["The timestamp when unlocking started"]; + type: "i64"; + }, + ]; + }, + ]; + }; + }, + { + name: "ChangeType"; + type: { + kind: "enum"; + variants: [ + { + name: "Oracle"; + fields: [ + { + name: "newOracleConfig"; + type: { + defined: "OracleConfig"; + }; + }, + ]; + }, + { + name: "Recipient"; + fields: [ + { + name: "newRecipient"; + type: "publicKey"; + }, + ]; + }, + ]; + }; + }, + { + name: "ProposerType"; + type: { + kind: "enum"; + variants: [ + { + name: "Recipient"; + }, + { + name: "Authority"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "PerformancePackageInitialized"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "UnlockStarted"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "startAggregator"; + type: "u128"; + index: false; + }, + { + name: "startTimestamp"; + type: "i64"; + index: false; + }, + ]; + }, + { + name: "UnlockCompleted"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "tokenAmount"; + type: "u64"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "twapPrice"; + type: "u128"; + index: false; + }, + ]; + }, + { + name: "ChangeProposed"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "locker"; + type: "publicKey"; + index: false; + }, + { + name: "changeRequest"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "changeType"; + type: { + defined: "ChangeType"; + }; + index: false; + }, + ]; + }, + { + name: "ChangeExecuted"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "changeRequest"; + type: "publicKey"; + index: false; + }, + { + name: "executor"; + type: "publicKey"; + index: false; + }, + { + name: "changeType"; + type: { + defined: "ChangeType"; + }; + index: false; + }, + ]; + }, + { + name: "PerformancePackageAuthorityChanged"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "locker"; + type: "publicKey"; + index: false; + }, + { + name: "oldAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "newAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "UnlockTimestampNotReached"; + msg: "Unlock timestamp has not been reached yet"; + }, + { + code: 6001; + name: "UnlockTimestampInThePast"; + msg: "Unlock timestamp must be in the future"; + }, + { + code: 6002; + name: "InvalidPerformancePackageState"; + msg: "Performance package is not in the expected state"; + }, + { + code: 6003; + name: "TwapPeriodNotElapsed"; + msg: "TWAP calculation failed"; + }, + { + code: 6004; + name: "PriceThresholdNotMet"; + msg: "Price threshold not met"; + }, + { + code: 6005; + name: "InvalidOracleData"; + msg: "Invalid oracle account data"; + }, + { + code: 6006; + name: "UnauthorizedChangeRequest"; + msg: "Unauthorized to create or execute change request"; + }, + { + code: 6007; + name: "InvalidChangeRequest"; + msg: "Change request does not match locker"; + }, + { + code: 6008; + name: "UnauthorizedLockerAuthority"; + msg: "Unauthorized locker authority"; + }, + { + code: 6009; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6010; + name: "TranchePriceThresholdsNotMonotonic"; + msg: "Tranche price thresholds must be monotonically increasing"; + }, + { + code: 6011; + name: "TrancheTokenAmountZero"; + msg: "Tranche token amount must be greater than 0"; + }, + { + code: 6012; + name: "InvalidTwapLength"; + msg: "TWAP length must be greater than or equal to 1 day and less than 1 year"; + }, + { + code: 6013; + name: "InvalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6014; + name: "TotalTokenAmountOverflow"; + msg: "Total token amount calculation would overflow"; + }, + { + code: 6015; + name: "RecipientAuthorityMustDiffer"; + msg: "Recipient and performance package authority must be different keys"; + }, + ]; +}; + +export const IDL: PriceBasedPerformancePackage = { + version: "0.6.0", + name: "price_based_performance_package", + constants: [ + { + name: "MAX_TRANCHES", + type: { + defined: "usize", + }, + value: "10", + }, + ], + instructions: [ + { + name: "initializePerformancePackage", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "createKey", + isMut: false, + isSigner: true, + docs: ["Used to derive the PDA"], + }, + { + name: "tokenMint", + isMut: false, + isSigner: false, + docs: ["The mint of the tokens to be locked"], + }, + { + name: "grantorTokenAccount", + isMut: true, + isSigner: false, + docs: ["The token account containing the tokens to be locked"], + }, + { + name: "grantor", + isMut: false, + isSigner: true, + docs: ["The authority of the token account"], + }, + { + name: "performancePackageTokenVault", + isMut: true, + isSigner: false, + docs: ["The locker's token account where tokens will be stored"], + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializePerformancePackageParams", + }, + }, + ], + }, + { + name: "startUnlock", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "oracleAccount", + isMut: false, + isSigner: false, + }, + { + name: "recipient", + isMut: false, + isSigner: true, + docs: ["Only the token recipient can start unlock"], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "completeUnlock", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "oracleAccount", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageTokenVault", + isMut: true, + isSigner: false, + docs: ["The token account where locked tokens are stored"], + }, + { + name: "tokenMint", + isMut: false, + isSigner: false, + docs: ["The token mint - validated via has_one constraint on locker"], + }, + { + name: "recipientTokenAccount", + isMut: true, + isSigner: false, + docs: [ + "The recipient's ATA where tokens will be sent - created if needed", + ], + }, + { + name: "tokenRecipient", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + docs: ["Payer for creating the ATA if needed"], + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "proposeChange", + accounts: [ + { + name: "changeRequest", + isMut: true, + isSigner: false, + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ProposeChangeParams", + }, + }, + ], + }, + { + name: "executeChange", + accounts: [ + { + name: "changeRequest", + isMut: true, + isSigner: false, + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "executor", + isMut: true, + isSigner: true, + docs: [ + "The party executing the change (must be opposite of proposer)", + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "changePerformancePackageAuthority", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "currentAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ChangePerformancePackageAuthorityParams", + }, + }, + ], + }, + { + name: "burnPerformancePackage", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "performancePackageTokenVault", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: true, + isSigner: true, + }, + { + name: "spillAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "performancePackage", + type: { + kind: "struct", + fields: [ + { + name: "tranches", + docs: ["The tranches that make up the performance package"], + type: { + vec: { + defined: "StoredTranche", + }, + }, + }, + { + name: "totalTokenAmount", + docs: ["Total amount of tokens in the performance package"], + type: "u64", + }, + { + name: "alreadyUnlockedAmount", + docs: ["Amount of tokens already unlocked"], + type: "u64", + }, + { + name: "minUnlockTimestamp", + docs: ["The timestamp when unlocking can begin"], + type: "i64", + }, + { + name: "oracleConfig", + docs: ["Where to pull price data from"], + type: { + defined: "OracleConfig", + }, + }, + { + name: "twapLengthSeconds", + docs: [ + "Length of time in seconds for TWAP calculation, between 1 day and 1 year", + ], + type: "u32", + }, + { + name: "recipient", + docs: ["The recipient of the tokens when unlocked"], + type: "publicKey", + }, + { + name: "state", + docs: ["The current state of the locker"], + type: { + defined: "PerformancePackageState", + }, + }, + { + name: "createKey", + docs: ["Used to derive the PDA"], + type: "publicKey", + }, + { + name: "pdaBump", + docs: ["The PDA bump"], + type: "u8", + }, + { + name: "performancePackageAuthority", + docs: [ + "The authorized locker authority that can execute changes, usually the organization", + ], + type: "publicKey", + }, + { + name: "tokenMint", + docs: ["The mint of the locked tokens"], + type: "publicKey", + }, + { + name: "seqNum", + docs: [ + "The sequence number of the performance package, used for indexing events", + ], + type: "u64", + }, + { + name: "performancePackageTokenVault", + docs: ["The vault that stores the tokens"], + type: "publicKey", + }, + ], + }, + }, + { + name: "changeRequest", + type: { + kind: "struct", + fields: [ + { + name: "performancePackage", + docs: ["The performance package this change applies to"], + type: "publicKey", + }, + { + name: "changeType", + docs: ["What is being changed"], + type: { + defined: "ChangeType", + }, + }, + { + name: "proposedAt", + docs: ["When the change was proposed"], + type: "i64", + }, + { + name: "proposerType", + docs: [ + "Who proposed this change (either token_recipient or locker_authority)", + ], + type: { + defined: "ProposerType", + }, + }, + { + name: "pdaNonce", + docs: ["Used to derive the PDA along with the proposer"], + type: "u32", + }, + { + name: "pdaBump", + docs: ["The PDA bump"], + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "performancePackageSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "ChangePerformancePackageAuthorityParams", + type: { + kind: "struct", + fields: [ + { + name: "newPerformancePackageAuthority", + type: "publicKey", + }, + ], + }, + }, + { + name: "InitializePerformancePackageParams", + type: { + kind: "struct", + fields: [ + { + name: "tranches", + type: { + vec: { + defined: "Tranche", + }, + }, + }, + { + name: "minUnlockTimestamp", + type: "i64", + }, + { + name: "oracleConfig", + type: { + defined: "OracleConfig", + }, + }, + { + name: "twapLengthSeconds", + type: "u32", + }, + { + name: "grantee", + type: "publicKey", + }, + { + name: "performancePackageAuthority", + type: "publicKey", + }, + ], + }, + }, + { + name: "ProposeChangeParams", + type: { + kind: "struct", + fields: [ + { + name: "changeType", + type: { + defined: "ChangeType", + }, + }, + { + name: "pdaNonce", + type: "u32", + }, + ], + }, + }, + { + name: "OracleConfig", + docs: [ + "Starting at `byte_offset` in `oracle_account`, this program expects to read:", + "- 16 bytes for the aggregator, stored as a little endian u128", + "- 8 bytes for the slot that the aggregator was last updated, stored as a", + "little endian u64", + "", + "The aggregator should be a weighted sum of prices, where the weight is the", + "number of seconds between prices. Here's an example:", + "- at second 0, the aggregator is 0", + "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", + "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", + "10 + 11 * 3 = 43", + "", + "This allows our program to read a TWAP over a time period by reading the", + "aggregator value at the beginning and at the end, and dividing the difference", + "by the number of seconds between the two.", + ], + type: { + kind: "struct", + fields: [ + { + name: "oracleAccount", + type: "publicKey", + }, + { + name: "byteOffset", + type: "u32", + }, + ], + }, + }, + { + name: "Tranche", + type: { + kind: "struct", + fields: [ + { + name: "priceThreshold", + docs: ["The price at which this tranch unlocks"], + type: "u128", + }, + { + name: "tokenAmount", + docs: ["The amount of tokens in this tranch"], + type: "u64", + }, + ], + }, + }, + { + name: "StoredTranche", + type: { + kind: "struct", + fields: [ + { + name: "priceThreshold", + type: "u128", + }, + { + name: "tokenAmount", + type: "u64", + }, + { + name: "isUnlocked", + type: "bool", + }, + ], + }, + }, + { + name: "PerformancePackageState", + type: { + kind: "enum", + variants: [ + { + name: "Locked", + }, + { + name: "Unlocking", + fields: [ + { + name: "startAggregator", + docs: ["The aggregator value when unlocking started"], + type: "u128", + }, + { + name: "startTimestamp", + docs: ["The timestamp when unlocking started"], + type: "i64", + }, + ], + }, + ], + }, + }, + { + name: "ChangeType", + type: { + kind: "enum", + variants: [ + { + name: "Oracle", + fields: [ + { + name: "newOracleConfig", + type: { + defined: "OracleConfig", + }, + }, + ], + }, + { + name: "Recipient", + fields: [ + { + name: "newRecipient", + type: "publicKey", + }, + ], + }, + ], + }, + }, + { + name: "ProposerType", + type: { + kind: "enum", + variants: [ + { + name: "Recipient", + }, + { + name: "Authority", + }, + ], + }, + }, + ], + events: [ + { + name: "PerformancePackageInitialized", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "UnlockStarted", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "startAggregator", + type: "u128", + index: false, + }, + { + name: "startTimestamp", + type: "i64", + index: false, + }, + ], + }, + { + name: "UnlockCompleted", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "tokenAmount", + type: "u64", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "twapPrice", + type: "u128", + index: false, + }, + ], + }, + { + name: "ChangeProposed", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "locker", + type: "publicKey", + index: false, + }, + { + name: "changeRequest", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "changeType", + type: { + defined: "ChangeType", + }, + index: false, + }, + ], + }, + { + name: "ChangeExecuted", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "changeRequest", + type: "publicKey", + index: false, + }, + { + name: "executor", + type: "publicKey", + index: false, + }, + { + name: "changeType", + type: { + defined: "ChangeType", + }, + index: false, + }, + ], + }, + { + name: "PerformancePackageAuthorityChanged", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "locker", + type: "publicKey", + index: false, + }, + { + name: "oldAuthority", + type: "publicKey", + index: false, + }, + { + name: "newAuthority", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "UnlockTimestampNotReached", + msg: "Unlock timestamp has not been reached yet", + }, + { + code: 6001, + name: "UnlockTimestampInThePast", + msg: "Unlock timestamp must be in the future", + }, + { + code: 6002, + name: "InvalidPerformancePackageState", + msg: "Performance package is not in the expected state", + }, + { + code: 6003, + name: "TwapPeriodNotElapsed", + msg: "TWAP calculation failed", + }, + { + code: 6004, + name: "PriceThresholdNotMet", + msg: "Price threshold not met", + }, + { + code: 6005, + name: "InvalidOracleData", + msg: "Invalid oracle account data", + }, + { + code: 6006, + name: "UnauthorizedChangeRequest", + msg: "Unauthorized to create or execute change request", + }, + { + code: 6007, + name: "InvalidChangeRequest", + msg: "Change request does not match locker", + }, + { + code: 6008, + name: "UnauthorizedLockerAuthority", + msg: "Unauthorized locker authority", + }, + { + code: 6009, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6010, + name: "TranchePriceThresholdsNotMonotonic", + msg: "Tranche price thresholds must be monotonically increasing", + }, + { + code: 6011, + name: "TrancheTokenAmountZero", + msg: "Tranche token amount must be greater than 0", + }, + { + code: 6012, + name: "InvalidTwapLength", + msg: "TWAP length must be greater than or equal to 1 day and less than 1 year", + }, + { + code: 6013, + name: "InvalidAdmin", + msg: "Invalid admin", + }, + { + code: 6014, + name: "TotalTokenAmountOverflow", + msg: "Total token amount calculation would overflow", + }, + { + code: 6015, + name: "RecipientAuthorityMustDiffer", + msg: "Recipient and performance package authority must be different keys", + }, + ], +}; From 303c9cf21e9bb9ecbd24adbeab1b46e29daccf8a Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 25 Mar 2026 00:37:21 +0100 Subject: [PATCH 027/100] new sdk - performance package v2 --- sdk2/src/performance_package_v2/index.ts | 1 + .../v0.7/PerformancePackageV2Client.ts | 307 +++ sdk2/src/performance_package_v2/v0.7/index.ts | 3 + sdk2/src/performance_package_v2/v0.7/pda.ts | 37 + .../v0.7/types/index.ts | 19 + .../v0.7/types/performance_package_v2.ts | 2139 +++++++++++++++++ 6 files changed, 2506 insertions(+) create mode 100644 sdk2/src/performance_package_v2/index.ts create mode 100644 sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts create mode 100644 sdk2/src/performance_package_v2/v0.7/index.ts create mode 100644 sdk2/src/performance_package_v2/v0.7/pda.ts create mode 100644 sdk2/src/performance_package_v2/v0.7/types/index.ts create mode 100644 sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts diff --git a/sdk2/src/performance_package_v2/index.ts b/sdk2/src/performance_package_v2/index.ts new file mode 100644 index 000000000..6b187d27b --- /dev/null +++ b/sdk2/src/performance_package_v2/index.ts @@ -0,0 +1 @@ +export * from "./v0.7/index.js"; diff --git a/sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts b/sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts new file mode 100644 index 000000000..d70bed07c --- /dev/null +++ b/sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts @@ -0,0 +1,307 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; +import { + TOKEN_PROGRAM_ID, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { + PERFORMANCE_PACKAGE_V2_PROGRAM_ID, + MINT_GOVERNOR_V0_7_PROGRAM_ID, +} from "../../constants.js"; +import { getPerformancePackageV2Addr, getChangeRequestV2Addr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { + PerformancePackageV2 as PerformancePackageV2Program, + IDL as PerformancePackageV2IDL, +} from "./types/performance_package_v2.js"; +import type { + PerformancePackageV2Account, + PerformancePackageV2ChangeRequestAccount, + PerformancePackageV2OracleReader, + PerformancePackageV2RewardFunction, +} from "./types/index.js"; + +export type CreatePerformancePackageV2ClientParams = { + provider: AnchorProvider; + programId?: PublicKey; +}; + +export class PerformancePackageV2Client { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly programId: PublicKey; + + constructor(provider: AnchorProvider, programId: PublicKey) { + this.provider = provider; + this.programId = programId; + this.program = new Program( + PerformancePackageV2IDL, + programId, + provider, + ); + } + + public static createClient( + params: CreatePerformancePackageV2ClientParams, + ): PerformancePackageV2Client { + const { provider, programId } = params; + return new PerformancePackageV2Client( + provider, + programId || PERFORMANCE_PACKAGE_V2_PROGRAM_ID, + ); + } + + getPerformancePackageAddr(createKey: PublicKey): [PublicKey, number] { + return getPerformancePackageV2Addr({ + programId: this.programId, + createKey, + }); + } + + getChangeRequestAddr( + performancePackage: PublicKey, + proposer: PublicKey, + pdaNonce: number, + ): [PublicKey, number] { + return getChangeRequestV2Addr({ + programId: this.programId, + performancePackage, + proposer, + pdaNonce, + }); + } + + async fetchPerformancePackage( + performancePackage: PublicKey, + ): Promise { + return this.program.account.performancePackage.fetchNullable( + performancePackage, + ); + } + + async deserializePerformancePackage( + accountInfo: AccountInfo, + ): Promise { + return this.program.coder.accounts.decode( + "performancePackage", + accountInfo.data, + ); + } + + async fetchChangeRequest( + changeRequest: PublicKey, + ): Promise { + return this.program.account.changeRequest.fetchNullable(changeRequest); + } + + async deserializeChangeRequest( + accountInfo: AccountInfo, + ): Promise { + return this.program.coder.accounts.decode( + "changeRequest", + accountInfo.data, + ); + } + + initializePerformancePackageIx({ + createKey, + mint, + mintGovernor, + mintAuthority, + authority, + recipient, + payer = this.provider.publicKey, + oracleReader, + rewardFunction, + minUnlockTimestamp, + }: { + createKey: PublicKey; + mint: PublicKey; + mintGovernor: PublicKey; + mintAuthority: PublicKey; + authority: PublicKey; + recipient: PublicKey; + payer?: PublicKey; + oracleReader: PerformancePackageV2OracleReader; + rewardFunction: PerformancePackageV2RewardFunction; + minUnlockTimestamp: BN; + }) { + const [performancePackage] = this.getPerformancePackageAddr(createKey); + + return this.program.methods + .initializePerformancePackage({ + oracleReader, + rewardFunction, + minUnlockTimestamp, + }) + .accounts({ + performancePackage, + mint, + mintGovernor, + mintAuthority, + createKey, + authority, + recipient, + payer, + systemProgram: SystemProgram.programId, + }); + } + + startUnlockIx({ + performancePackage, + signer = this.provider.publicKey, + dao, + }: { + performancePackage: PublicKey; + signer?: PublicKey; + dao?: PublicKey; + }) { + const builder = this.program.methods.startUnlock().accounts({ + performancePackage, + signer, + }); + + if (dao) { + return builder.remainingAccounts([ + { pubkey: dao, isSigner: false, isWritable: false }, + ]); + } + + return builder; + } + + completeUnlockIx({ + performancePackage, + mintGovernor, + mintAuthority, + mint, + recipient, + signer = this.provider.publicKey, + dao, + }: { + performancePackage: PublicKey; + mintGovernor: PublicKey; + mintAuthority: PublicKey; + mint: PublicKey; + recipient: PublicKey; + signer?: PublicKey; + dao?: PublicKey; + }) { + const recipientAta = getAssociatedTokenAddressSync(mint, recipient, true); + + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + MINT_GOVERNOR_V0_7_PROGRAM_ID, + ); + + const builder = this.program.methods.completeUnlock().accounts({ + performancePackage, + mintGovernor, + mintAuthority, + mint, + recipientAta, + signer, + tokenProgram: TOKEN_PROGRAM_ID, + mintGovernorProgram: MINT_GOVERNOR_V0_7_PROGRAM_ID, + mintGovernorEventAuthority, + }); + + if (dao) { + return builder.remainingAccounts([ + { pubkey: dao, isSigner: false, isWritable: false }, + ]); + } + + return builder; + } + + changeAuthorityIx({ + performancePackage, + authority = this.provider.publicKey, + newAuthority, + }: { + performancePackage: PublicKey; + authority?: PublicKey; + newAuthority: PublicKey; + }) { + return this.program.methods.changeAuthority().accounts({ + performancePackage, + authority, + newAuthority, + }); + } + + proposeChangeIx({ + performancePackage, + proposer = this.provider.publicKey, + payer = this.provider.publicKey, + pdaNonce, + newRecipient = null, + newOracleReader = null, + newRewardFunction = null, + }: { + performancePackage: PublicKey; + proposer?: PublicKey; + payer?: PublicKey; + pdaNonce: number; + newRecipient?: PublicKey | null; + newOracleReader?: PerformancePackageV2OracleReader | null; + newRewardFunction?: PerformancePackageV2RewardFunction | null; + }) { + const [changeRequest] = this.getChangeRequestAddr( + performancePackage, + proposer, + pdaNonce, + ); + + return this.program.methods + .proposeChange({ + pdaNonce, + newRecipient, + newOracleReader, + newRewardFunction, + }) + .accounts({ + performancePackage, + changeRequest, + proposer, + payer, + systemProgram: SystemProgram.programId, + }); + } + + executeChangeIx({ + performancePackage, + changeRequest, + executor = this.provider.publicKey, + rentDestination = this.provider.publicKey, + }: { + performancePackage: PublicKey; + changeRequest: PublicKey; + executor?: PublicKey; + rentDestination?: PublicKey; + }) { + return this.program.methods.executeChange().accounts({ + performancePackage, + changeRequest, + executor, + rentDestination, + }); + } + + closePerformancePackageIx({ + performancePackage, + admin = this.provider.publicKey, + rentDestination = this.provider.publicKey, + }: { + performancePackage: PublicKey; + admin?: PublicKey; + rentDestination?: PublicKey; + }) { + return this.program.methods.closePerformancePackage().accounts({ + performancePackage, + admin, + rentDestination, + }); + } +} diff --git a/sdk2/src/performance_package_v2/v0.7/index.ts b/sdk2/src/performance_package_v2/v0.7/index.ts new file mode 100644 index 000000000..b1540d6ca --- /dev/null +++ b/sdk2/src/performance_package_v2/v0.7/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./PerformancePackageV2Client.js"; diff --git a/sdk2/src/performance_package_v2/v0.7/pda.ts b/sdk2/src/performance_package_v2/v0.7/pda.ts new file mode 100644 index 000000000..b5caa64ce --- /dev/null +++ b/sdk2/src/performance_package_v2/v0.7/pda.ts @@ -0,0 +1,37 @@ +import { PublicKey } from "@solana/web3.js"; +import { PERFORMANCE_PACKAGE_V2_PROGRAM_ID } from "../../constants.js"; + +export const getPerformancePackageV2Addr = ({ + programId = PERFORMANCE_PACKAGE_V2_PROGRAM_ID, + createKey, +}: { + programId?: PublicKey; + createKey: PublicKey; +}) => { + return PublicKey.findProgramAddressSync( + [Buffer.from("performance_package"), createKey.toBuffer()], + programId, + ); +}; + +export const getChangeRequestV2Addr = ({ + programId = PERFORMANCE_PACKAGE_V2_PROGRAM_ID, + performancePackage, + proposer, + pdaNonce, +}: { + programId?: PublicKey; + performancePackage: PublicKey; + proposer: PublicKey; + pdaNonce: number; +}) => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("change_request"), + performancePackage.toBuffer(), + proposer.toBuffer(), + Buffer.from(new Uint8Array(new Uint32Array([pdaNonce]).buffer)), + ], + programId, + ); +}; diff --git a/sdk2/src/performance_package_v2/v0.7/types/index.ts b/sdk2/src/performance_package_v2/v0.7/types/index.ts new file mode 100644 index 000000000..e6c7d5bd6 --- /dev/null +++ b/sdk2/src/performance_package_v2/v0.7/types/index.ts @@ -0,0 +1,19 @@ +import { IdlAccounts, IdlTypes } from "@coral-xyz/anchor"; +import { + PerformancePackageV2 as PerformancePackageV2Program, + IDL as PerformancePackageV2IDL, +} from "./performance_package_v2.js"; +export { PerformancePackageV2Program, PerformancePackageV2IDL }; + +export type PerformancePackageV2Account = + IdlAccounts["performancePackage"]; +export type PerformancePackageV2ChangeRequestAccount = + IdlAccounts["changeRequest"]; +export type PerformancePackageV2OracleReader = + IdlTypes["OracleReader"]; +export type PerformancePackageV2RewardFunction = + IdlTypes["RewardFunction"]; +export type PerformancePackageV2PackageStatus = + IdlTypes["PackageStatus"]; +export type PerformancePackageV2ThresholdTranche = + IdlTypes["ThresholdTranche"]; diff --git a/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts b/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts new file mode 100644 index 000000000..0956ed645 --- /dev/null +++ b/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts @@ -0,0 +1,2139 @@ +export type PerformancePackageV2 = { + version: "0.7.0"; + name: "performance_package_v2"; + constants: [ + { + name: "MAX_TRANCHES"; + type: { + defined: "usize"; + }; + value: "10"; + }, + { + name: "MAX_MIN_DURATION"; + type: "u32"; + value: "60 * 60 * 24 * 365"; + }, + ]; + instructions: [ + { + name: "initializePerformancePackage"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "mint"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernor"; + isMut: false; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "createKey"; + isMut: false; + isSigner: true; + }, + { + name: "authority"; + isMut: false; + isSigner: false; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializePerformancePackageArgs"; + }; + }, + ]; + }, + { + name: "startUnlock"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "signer"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "completeUnlock"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "mint"; + isMut: true; + isSigner: false; + }, + { + name: "recipientAta"; + isMut: true; + isSigner: false; + }, + { + name: "signer"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "changeAuthority"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + docs: ["Must be the current authority of the performance package"]; + }, + { + name: "newAuthority"; + isMut: false; + isSigner: false; + docs: ["The new authority address"]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "proposeChange"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "changeRequest"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ProposeChangeArgs"; + }; + }, + ]; + }, + { + name: "executeChange"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "changeRequest"; + isMut: true; + isSigner: false; + }, + { + name: "executor"; + isMut: false; + isSigner: true; + }, + { + name: "rentDestination"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "closePerformancePackage"; + accounts: [ + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "rentDestination"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "changeRequest"; + docs: [ + "Temporary account for two-party approval flow.", + 'Seeds: `["change_request", performance_package, proposer, pda_nonce.to_le_bytes()]`', + ]; + type: { + kind: "struct"; + fields: [ + { + name: "performancePackage"; + docs: ["The performance package this change applies to"]; + type: "publicKey"; + }, + { + name: "proposer"; + docs: ["The proposer's pubkey at proposal time"]; + type: "publicKey"; + }, + { + name: "ppCreatedAtTimestamp"; + docs: [ + "PP's created_at_timestamp at proposal time; used to detect stale CRs after close/recreate", + ]; + type: "i64"; + }, + { + name: "proposedAt"; + docs: ["When the change was proposed"]; + type: "i64"; + }, + { + name: "pdaNonce"; + docs: [ + "For unique PDA derivation (allows multiple concurrent proposals)", + ]; + type: "u32"; + }, + { + name: "bump"; + type: "u8"; + }, + { + name: "newRecipient"; + docs: ["New recipient address (if changing)"]; + type: { + option: "publicKey"; + }; + }, + { + name: "newOracleReader"; + docs: ["New oracle configuration (if changing)"]; + type: { + option: { + defined: "OracleReader"; + }; + }; + }, + { + name: "newRewardFunction"; + docs: ["New reward function (if changing)"]; + type: { + option: { + defined: "RewardFunction"; + }; + }; + }, + ]; + }; + }, + { + name: "performancePackage"; + docs: [ + "The main account representing a performance package.", + "Acts as the `authorized_minter` in mint_governor.", + 'Seeds: `["performance_package", create_key]`', + ]; + type: { + kind: "struct"; + fields: [ + { + name: "mint"; + docs: ["Token mint controlled by mint_governor"]; + type: "publicKey"; + }, + { + name: "mintGovernor"; + docs: ["MintGovernor account"]; + type: "publicKey"; + }, + { + name: "mintAuthority"; + docs: ["MintAuthority PDA for this PP"]; + type: "publicKey"; + }, + { + name: "authority"; + docs: ["Usually the DAO multisig vault - can modify PP"]; + type: "publicKey"; + }, + { + name: "recipient"; + docs: ["Usually the team multisig - receives minted tokens"]; + type: "publicKey"; + }, + { + name: "oracleReader"; + docs: ["Stores start/end snapshots for oracle calculations"]; + type: { + defined: "OracleReader"; + }; + }, + { + name: "rewardFunction"; + docs: ["How to calculate rewards"]; + type: { + defined: "RewardFunction"; + }; + }, + { + name: "status"; + docs: ["Locked or Unlocking state"]; + type: { + defined: "PackageStatus"; + }; + }, + { + name: "minUnlockTimestamp"; + docs: ["Can't start unlock before this time"]; + type: "i64"; + }, + { + name: "createdAtTimestamp"; + docs: [ + "Timestamp when this PP was created; used to invalidate stale ChangeRequests", + ]; + type: "i64"; + }, + { + name: "totalRewardsPaidOut"; + docs: ["Cumulative tokens minted to the recipient"]; + type: "u64"; + }, + { + name: "seqNum"; + docs: ["Event sequence number"]; + type: "u64"; + }, + { + name: "createKey"; + docs: ["Used for PDA derivation"]; + type: "publicKey"; + }, + { + name: "bump"; + docs: ["PDA bump"]; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + docs: ["Common fields included in all events for consistent metadata."]; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "performancePackageSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializePerformancePackageArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "oracleReader"; + type: { + defined: "OracleReader"; + }; + }, + { + name: "rewardFunction"; + type: { + defined: "RewardFunction"; + }; + }, + { + name: "minUnlockTimestamp"; + type: "i64"; + }, + ]; + }; + }, + { + name: "ProposeChangeArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaNonce"; + type: "u32"; + }, + { + name: "newRecipient"; + type: { + option: "publicKey"; + }; + }, + { + name: "newOracleReader"; + type: { + option: { + defined: "OracleReader"; + }; + }; + }, + { + name: "newRewardFunction"; + type: { + option: { + defined: "RewardFunction"; + }; + }; + }, + ]; + }; + }, + { + name: "ThresholdTranche"; + docs: ["A threshold tranche for step-based rewards."]; + type: { + kind: "struct"; + fields: [ + { + name: "threshold"; + docs: ["Oracle value threshold"]; + type: "u128"; + }, + { + name: "cumulativeAmount"; + docs: [ + "Total tokens at this tranche (cumulative, not incremental)", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "PackageStatus"; + docs: ["Lifecycle state for the performance package."]; + type: { + kind: "enum"; + variants: [ + { + name: "Locked"; + }, + { + name: "Unlocking"; + }, + ]; + }; + }, + { + name: "OracleReader"; + docs: [ + "Oracle reader that knows how to read from an external oracle account.", + "Extracts a `value: u128` for reward calculations.", + ]; + type: { + kind: "enum"; + variants: [ + { + name: "Time"; + }, + { + name: "FutarchyTwap"; + fields: [ + { + name: "amm"; + docs: [ + "The Futarchy DAO account to read (contains embedded AMM)", + ]; + type: "publicKey"; + }, + { + name: "minDuration"; + docs: ["Minimum seconds between start and end"]; + type: "u32"; + }, + { + name: "startValue"; + docs: ["Start snapshot (recorded on start_unlock)"]; + type: "u128"; + }, + { + name: "startTime"; + type: "i64"; + }, + { + name: "endValue"; + docs: ["End snapshot (recorded on complete_unlock)"]; + type: "u128"; + }, + { + name: "endTime"; + type: "i64"; + }, + ]; + }, + ]; + }; + }, + { + name: "RewardFunction"; + docs: [ + "Reward function that calculates cumulative rewards from oracle values.", + "Returns total tokens deserved so far (not incremental).", + ]; + type: { + kind: "enum"; + variants: [ + { + name: "CliffLinear"; + fields: [ + { + name: "cliffValue"; + type: "u128"; + }, + { + name: "endValue"; + type: "u128"; + }, + { + name: "cliffAmount"; + type: "u64"; + }, + { + name: "totalAmount"; + docs: ["Total amount including cliff"]; + type: "u64"; + }, + ]; + }, + { + name: "Threshold"; + fields: [ + { + name: "tranches"; + docs: ["Must be sorted by threshold ascending"]; + type: { + vec: { + defined: "ThresholdTranche"; + }; + }; + }, + ]; + }, + ]; + }; + }, + ]; + events: [ + { + name: "PerformancePackageCreatedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "mint"; + type: "publicKey"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "authority"; + type: "publicKey"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "createKey"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + ]; + }, + { + name: "UnlockStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "startTime"; + type: "i64"; + index: false; + }, + ]; + }, + { + name: "UnlockCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "oracleValue"; + type: "u128"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "amountMinted"; + type: "u64"; + index: false; + }, + { + name: "totalRewardsPaidOut"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "AuthorityChangedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "oldAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "newAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "ChangeProposedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "changeRequest"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "pdaNonce"; + type: "u32"; + index: false; + }, + { + name: "newRecipient"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "newOracleReader"; + type: { + option: { + defined: "OracleReader"; + }; + }; + index: false; + }, + { + name: "newRewardFunction"; + type: { + option: { + defined: "RewardFunction"; + }; + }; + index: false; + }, + ]; + }, + { + name: "ChangeExecutedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "executedBy"; + type: "publicKey"; + index: false; + }, + { + name: "newRecipient"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "newOracleReader"; + type: { + option: { + defined: "OracleReader"; + }; + }; + index: false; + }, + { + name: "newRewardFunction"; + type: { + option: { + defined: "RewardFunction"; + }; + }; + index: false; + }, + ]; + }, + { + name: "PerformancePackageClosedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "totalRewardsPaidOut"; + type: "u64"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "Unauthorized"; + msg: "Signer is neither authority nor recipient"; + }, + { + code: 6001; + name: "InvalidExecutor"; + msg: "Executor is not the opposite party from proposer"; + }, + { + code: 6002; + name: "InvalidAuthority"; + msg: "Signer is not the current authority"; + }, + { + code: 6003; + name: "InvalidAdmin"; + msg: "Signer is not the admin"; + }, + { + code: 6004; + name: "InvalidMintGovernor"; + msg: "Mint governor does not match the provided mint"; + }, + { + code: 6005; + name: "InvalidMintAuthority"; + msg: "Mint authority does not match expected configuration"; + }, + { + code: 6006; + name: "NotLocked"; + msg: "Expected Locked status"; + }, + { + code: 6007; + name: "NotUnlocking"; + msg: "Expected Unlocking status"; + }, + { + code: 6008; + name: "OracleMissingAccount"; + msg: "Expected remaining_accounts not provided"; + }, + { + code: 6009; + name: "OracleInvalidAccount"; + msg: "Account pubkey doesn't match expected"; + }, + { + code: 6010; + name: "OracleParseError"; + msg: "Failed to parse account data"; + }, + { + code: 6011; + name: "OracleInvalidState"; + msg: "Oracle state invalid"; + }, + { + code: 6012; + name: "OracleMinDurationNotReached"; + msg: "Minimum duration hasn't passed yet"; + }, + { + code: 6013; + name: "UnlockTimestampNotReached"; + msg: "Minimum unlock timestamp not yet reached"; + }, + { + code: 6014; + name: "RewardCalculationOverflow"; + msg: "Math overflow in reward function"; + }, + { + code: 6015; + name: "InvalidTranches"; + msg: "Tranches should be sorted and non-empty"; + }, + { + code: 6016; + name: "InvalidVestingSchedule"; + msg: "Invalid vesting schedule configuration"; + }, + { + code: 6017; + name: "ChangeRequestNotFound"; + msg: "Missing proposal for execute"; + }, + { + code: 6018; + name: "NoChangesProposed"; + msg: "All optional change fields are None"; + }, + { + code: 6019; + name: "MinDurationTooLarge"; + msg: "min_duration exceeds maximum allowed (365 days)"; + }, + { + code: 6020; + name: "StaleChangeRequest"; + msg: "Change request is stale: PP was recreated or the proposing party has changed"; + }, + ]; +}; + +export const IDL: PerformancePackageV2 = { + version: "0.7.0", + name: "performance_package_v2", + constants: [ + { + name: "MAX_TRANCHES", + type: { + defined: "usize", + }, + value: "10", + }, + { + name: "MAX_MIN_DURATION", + type: "u32", + value: "60 * 60 * 24 * 365", + }, + ], + instructions: [ + { + name: "initializePerformancePackage", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "mint", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernor", + isMut: false, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: false, + isSigner: false, + }, + { + name: "createKey", + isMut: false, + isSigner: true, + }, + { + name: "authority", + isMut: false, + isSigner: false, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializePerformancePackageArgs", + }, + }, + ], + }, + { + name: "startUnlock", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "signer", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "completeUnlock", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "mint", + isMut: true, + isSigner: false, + }, + { + name: "recipientAta", + isMut: true, + isSigner: false, + }, + { + name: "signer", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "changeAuthority", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + docs: ["Must be the current authority of the performance package"], + }, + { + name: "newAuthority", + isMut: false, + isSigner: false, + docs: ["The new authority address"], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "proposeChange", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "changeRequest", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ProposeChangeArgs", + }, + }, + ], + }, + { + name: "executeChange", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "changeRequest", + isMut: true, + isSigner: false, + }, + { + name: "executor", + isMut: false, + isSigner: true, + }, + { + name: "rentDestination", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "closePerformancePackage", + accounts: [ + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "rentDestination", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "changeRequest", + docs: [ + "Temporary account for two-party approval flow.", + 'Seeds: `["change_request", performance_package, proposer, pda_nonce.to_le_bytes()]`', + ], + type: { + kind: "struct", + fields: [ + { + name: "performancePackage", + docs: ["The performance package this change applies to"], + type: "publicKey", + }, + { + name: "proposer", + docs: ["The proposer's pubkey at proposal time"], + type: "publicKey", + }, + { + name: "ppCreatedAtTimestamp", + docs: [ + "PP's created_at_timestamp at proposal time; used to detect stale CRs after close/recreate", + ], + type: "i64", + }, + { + name: "proposedAt", + docs: ["When the change was proposed"], + type: "i64", + }, + { + name: "pdaNonce", + docs: [ + "For unique PDA derivation (allows multiple concurrent proposals)", + ], + type: "u32", + }, + { + name: "bump", + type: "u8", + }, + { + name: "newRecipient", + docs: ["New recipient address (if changing)"], + type: { + option: "publicKey", + }, + }, + { + name: "newOracleReader", + docs: ["New oracle configuration (if changing)"], + type: { + option: { + defined: "OracleReader", + }, + }, + }, + { + name: "newRewardFunction", + docs: ["New reward function (if changing)"], + type: { + option: { + defined: "RewardFunction", + }, + }, + }, + ], + }, + }, + { + name: "performancePackage", + docs: [ + "The main account representing a performance package.", + "Acts as the `authorized_minter` in mint_governor.", + 'Seeds: `["performance_package", create_key]`', + ], + type: { + kind: "struct", + fields: [ + { + name: "mint", + docs: ["Token mint controlled by mint_governor"], + type: "publicKey", + }, + { + name: "mintGovernor", + docs: ["MintGovernor account"], + type: "publicKey", + }, + { + name: "mintAuthority", + docs: ["MintAuthority PDA for this PP"], + type: "publicKey", + }, + { + name: "authority", + docs: ["Usually the DAO multisig vault - can modify PP"], + type: "publicKey", + }, + { + name: "recipient", + docs: ["Usually the team multisig - receives minted tokens"], + type: "publicKey", + }, + { + name: "oracleReader", + docs: ["Stores start/end snapshots for oracle calculations"], + type: { + defined: "OracleReader", + }, + }, + { + name: "rewardFunction", + docs: ["How to calculate rewards"], + type: { + defined: "RewardFunction", + }, + }, + { + name: "status", + docs: ["Locked or Unlocking state"], + type: { + defined: "PackageStatus", + }, + }, + { + name: "minUnlockTimestamp", + docs: ["Can't start unlock before this time"], + type: "i64", + }, + { + name: "createdAtTimestamp", + docs: [ + "Timestamp when this PP was created; used to invalidate stale ChangeRequests", + ], + type: "i64", + }, + { + name: "totalRewardsPaidOut", + docs: ["Cumulative tokens minted to the recipient"], + type: "u64", + }, + { + name: "seqNum", + docs: ["Event sequence number"], + type: "u64", + }, + { + name: "createKey", + docs: ["Used for PDA derivation"], + type: "publicKey", + }, + { + name: "bump", + docs: ["PDA bump"], + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + docs: ["Common fields included in all events for consistent metadata."], + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "performancePackageSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializePerformancePackageArgs", + type: { + kind: "struct", + fields: [ + { + name: "oracleReader", + type: { + defined: "OracleReader", + }, + }, + { + name: "rewardFunction", + type: { + defined: "RewardFunction", + }, + }, + { + name: "minUnlockTimestamp", + type: "i64", + }, + ], + }, + }, + { + name: "ProposeChangeArgs", + type: { + kind: "struct", + fields: [ + { + name: "pdaNonce", + type: "u32", + }, + { + name: "newRecipient", + type: { + option: "publicKey", + }, + }, + { + name: "newOracleReader", + type: { + option: { + defined: "OracleReader", + }, + }, + }, + { + name: "newRewardFunction", + type: { + option: { + defined: "RewardFunction", + }, + }, + }, + ], + }, + }, + { + name: "ThresholdTranche", + docs: ["A threshold tranche for step-based rewards."], + type: { + kind: "struct", + fields: [ + { + name: "threshold", + docs: ["Oracle value threshold"], + type: "u128", + }, + { + name: "cumulativeAmount", + docs: [ + "Total tokens at this tranche (cumulative, not incremental)", + ], + type: "u64", + }, + ], + }, + }, + { + name: "PackageStatus", + docs: ["Lifecycle state for the performance package."], + type: { + kind: "enum", + variants: [ + { + name: "Locked", + }, + { + name: "Unlocking", + }, + ], + }, + }, + { + name: "OracleReader", + docs: [ + "Oracle reader that knows how to read from an external oracle account.", + "Extracts a `value: u128` for reward calculations.", + ], + type: { + kind: "enum", + variants: [ + { + name: "Time", + }, + { + name: "FutarchyTwap", + fields: [ + { + name: "amm", + docs: [ + "The Futarchy DAO account to read (contains embedded AMM)", + ], + type: "publicKey", + }, + { + name: "minDuration", + docs: ["Minimum seconds between start and end"], + type: "u32", + }, + { + name: "startValue", + docs: ["Start snapshot (recorded on start_unlock)"], + type: "u128", + }, + { + name: "startTime", + type: "i64", + }, + { + name: "endValue", + docs: ["End snapshot (recorded on complete_unlock)"], + type: "u128", + }, + { + name: "endTime", + type: "i64", + }, + ], + }, + ], + }, + }, + { + name: "RewardFunction", + docs: [ + "Reward function that calculates cumulative rewards from oracle values.", + "Returns total tokens deserved so far (not incremental).", + ], + type: { + kind: "enum", + variants: [ + { + name: "CliffLinear", + fields: [ + { + name: "cliffValue", + type: "u128", + }, + { + name: "endValue", + type: "u128", + }, + { + name: "cliffAmount", + type: "u64", + }, + { + name: "totalAmount", + docs: ["Total amount including cliff"], + type: "u64", + }, + ], + }, + { + name: "Threshold", + fields: [ + { + name: "tranches", + docs: ["Must be sorted by threshold ascending"], + type: { + vec: { + defined: "ThresholdTranche", + }, + }, + }, + ], + }, + ], + }, + }, + ], + events: [ + { + name: "PerformancePackageCreatedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "mint", + type: "publicKey", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "authority", + type: "publicKey", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "createKey", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + ], + }, + { + name: "UnlockStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "startTime", + type: "i64", + index: false, + }, + ], + }, + { + name: "UnlockCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "oracleValue", + type: "u128", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "amountMinted", + type: "u64", + index: false, + }, + { + name: "totalRewardsPaidOut", + type: "u64", + index: false, + }, + ], + }, + { + name: "AuthorityChangedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "oldAuthority", + type: "publicKey", + index: false, + }, + { + name: "newAuthority", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "ChangeProposedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "changeRequest", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "pdaNonce", + type: "u32", + index: false, + }, + { + name: "newRecipient", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "newOracleReader", + type: { + option: { + defined: "OracleReader", + }, + }, + index: false, + }, + { + name: "newRewardFunction", + type: { + option: { + defined: "RewardFunction", + }, + }, + index: false, + }, + ], + }, + { + name: "ChangeExecutedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "executedBy", + type: "publicKey", + index: false, + }, + { + name: "newRecipient", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "newOracleReader", + type: { + option: { + defined: "OracleReader", + }, + }, + index: false, + }, + { + name: "newRewardFunction", + type: { + option: { + defined: "RewardFunction", + }, + }, + index: false, + }, + ], + }, + { + name: "PerformancePackageClosedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "totalRewardsPaidOut", + type: "u64", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "Unauthorized", + msg: "Signer is neither authority nor recipient", + }, + { + code: 6001, + name: "InvalidExecutor", + msg: "Executor is not the opposite party from proposer", + }, + { + code: 6002, + name: "InvalidAuthority", + msg: "Signer is not the current authority", + }, + { + code: 6003, + name: "InvalidAdmin", + msg: "Signer is not the admin", + }, + { + code: 6004, + name: "InvalidMintGovernor", + msg: "Mint governor does not match the provided mint", + }, + { + code: 6005, + name: "InvalidMintAuthority", + msg: "Mint authority does not match expected configuration", + }, + { + code: 6006, + name: "NotLocked", + msg: "Expected Locked status", + }, + { + code: 6007, + name: "NotUnlocking", + msg: "Expected Unlocking status", + }, + { + code: 6008, + name: "OracleMissingAccount", + msg: "Expected remaining_accounts not provided", + }, + { + code: 6009, + name: "OracleInvalidAccount", + msg: "Account pubkey doesn't match expected", + }, + { + code: 6010, + name: "OracleParseError", + msg: "Failed to parse account data", + }, + { + code: 6011, + name: "OracleInvalidState", + msg: "Oracle state invalid", + }, + { + code: 6012, + name: "OracleMinDurationNotReached", + msg: "Minimum duration hasn't passed yet", + }, + { + code: 6013, + name: "UnlockTimestampNotReached", + msg: "Minimum unlock timestamp not yet reached", + }, + { + code: 6014, + name: "RewardCalculationOverflow", + msg: "Math overflow in reward function", + }, + { + code: 6015, + name: "InvalidTranches", + msg: "Tranches should be sorted and non-empty", + }, + { + code: 6016, + name: "InvalidVestingSchedule", + msg: "Invalid vesting schedule configuration", + }, + { + code: 6017, + name: "ChangeRequestNotFound", + msg: "Missing proposal for execute", + }, + { + code: 6018, + name: "NoChangesProposed", + msg: "All optional change fields are None", + }, + { + code: 6019, + name: "MinDurationTooLarge", + msg: "min_duration exceeds maximum allowed (365 days)", + }, + { + code: 6020, + name: "StaleChangeRequest", + msg: "Change request is stale: PP was recreated or the proposing party has changed", + }, + ], +}; From 353eed4fa6b12a88820a070979dbeb4c59eab0e1 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 25 Mar 2026 00:49:57 +0100 Subject: [PATCH 028/100] new sdk - launchpad v6 program --- sdk2/src/constants.ts | 7 + sdk2/src/launchpad/v0.6/LaunchpadClient.ts | 575 ++++ sdk2/src/launchpad/v0.6/index.ts | 1 + sdk2/src/launchpad/v0.6/pda.ts | 33 + sdk2/src/launchpad/v0.6/types/index.ts | 30 + sdk2/src/launchpad/v0.6/types/launchpad.ts | 2813 ++++++++++++++++++++ 6 files changed, 3459 insertions(+) create mode 100644 sdk2/src/launchpad/v0.6/LaunchpadClient.ts create mode 100644 sdk2/src/launchpad/v0.6/index.ts create mode 100644 sdk2/src/launchpad/v0.6/pda.ts create mode 100644 sdk2/src/launchpad/v0.6/types/index.ts create mode 100644 sdk2/src/launchpad/v0.6/types/launchpad.ts diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index df7bbfe45..d8e1a2235 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -11,6 +11,9 @@ export const AMM_PROGRAM_ID = new PublicKey( export const CONDITIONAL_VAULT_v0_4_PROGRAM_ID = new PublicKey( "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", ); +export const LAUNCHPAD_V0_6_PROGRAM_ID = new PublicKey( + "MooNyh4CBUYEKyXVnjGYQ8mEiJDpGvJMdvrZx1iGeHV", +); export const LAUNCHPAD_V0_7_PROGRAM_ID = new PublicKey( "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM", ); @@ -117,6 +120,10 @@ export const SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET = new PublicKey( "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", ); +export const LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG = new PublicKey( + "Asv1KQqeop9e4FFvTzEBZhwtTjuWHXPq5thUGtQrzzA3", +); + export const LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG = new PublicKey( "FaA6RM9enPh1tU9Y8LiGCq715JubLc49WGcYTdNvDfsc", ); diff --git a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts new file mode 100644 index 000000000..2b2eec93d --- /dev/null +++ b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts @@ -0,0 +1,575 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { PublicKey, AccountInfo, ComputeBudgetProgram } from "@solana/web3.js"; +import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; +import { + Launchpad as v0_6_0_launchpad, + IDL as v0_6_0_launchpadIDL, +} from "./types/launchpad.js"; +import { + LAUNCHPAD_V0_6_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, + SQUADS_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + DAMM_V2_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, +} from "../../constants.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { FundingRecord, Launch } from "./types/index.js"; +import { + getFundingRecordAddr, + getLaunchAddr, + getLaunchSignerAddr, +} from "./pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; +import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; +import { + PriceBasedPerformancePackageClient, + getPerformancePackageAddr, +} from "../../price_based_performance_package/v0.6/index.js"; + +import * as multisig from "@sqds/multisig"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + futarchyProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + priceBasedUnlockProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + // useful for parsing old events + public v0_6_0_launchpad: Program; + public futarchyClient: FutarchyClient; + public priceBasedUnlock: PriceBasedPerformancePackageClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + this.launchpad = new Program( + LaunchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_6_PROGRAM_ID, + this.provider, + ); + this.v0_6_0_launchpad = new Program( + v0_6_0_launchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_6_PROGRAM_ID, + this.provider, + ); + this.futarchyClient = FutarchyClient.createClient({ + provider: this.provider, + autocratProgramId: params.futarchyProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + }); + this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ + provider: this.provider, + priceBasedTokenLockProgramId: params.priceBasedUnlockProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord( + fundingRecord: PublicKey, + ): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable( + fundingRecord, + ); + } + + async deserializeFundingRecord( + accountInfo: AccountInfo, + ): Promise { + return this.launchpad.coder.accounts.decode( + "fundingRecord", + accountInfo.data, + ); + } + + initializeLaunchIx({ + tokenName, + tokenSymbol, + tokenUri, + minimumRaiseAmount, + secondsForLaunch = 60 * 60 * 24 * 5, // 5 days + baseMint, + quoteMint = MAINNET_USDC, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + launchAuthority = this.provider.publicKey, + payer = this.provider.publicKey, + }: { + tokenName: string; + tokenSymbol: string; + tokenUri: string; + minimumRaiseAmount: BN; + secondsForLaunch?: number; + baseMint: PublicKey; + quoteMint?: PublicKey; + monthlySpendingLimitAmount: BN; + monthlySpendingLimitMembers: PublicKey[]; + performancePackageGrantee: PublicKey; + performancePackageTokenAmount: BN; + monthsUntilInsidersCanUnlock: number; + teamAddress: PublicKey; + launchAuthority?: PublicKey; + payer?: PublicKey; + }) { + const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const quoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + + const baseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + const [tokenMetadata] = getMetadataAddr(baseMint); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, + tokenSymbol, + tokenUri, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + }) + .accounts({ + launch, + launchSigner, + quoteVault, + baseVault, + launchAuthority, + quoteMint, + baseMint, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, launchSigner, true), + launchSigner, + quoteMint, + ), + ]); + // .signers([tokenMintKp]); + } + + startLaunchIx({ + launch, + launchAuthority = this.provider.publicKey, + }: { + launch: PublicKey; + launchAuthority?: PublicKey; + }) { + return this.launchpad.methods.startLaunch().accounts({ + launch, + launchAuthority, + }); + } + + fundIx({ + launch, + amount, + funder = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + amount: BN; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods.fund(amount).accounts({ + launch, + launchQuoteVault, + fundingRecord, + funder, + funderQuoteAccount, + }); + } + + closeLaunchIx({ launch }: { launch: PublicKey }) { + return this.launchpad.methods.closeLaunch().accounts({ + launch, + }); + } + + completeLaunchIx({ + launch, + quoteMint = MAINNET_USDC, + baseMint, + finalRaiseAmount, + launchAuthority, + isDevnet = false, + meteoraConfig = LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, + }: { + launch: PublicKey; + quoteMint?: PublicKey; + baseMint: PublicKey; + finalRaiseAmount: BN | null; + launchAuthority: PublicKey | null; + isDevnet?: boolean; + meteoraConfig?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const launchBaseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + + // const daoKp = Keypair.generate(); + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [autocratEventAuthority] = getEventAuthorityAddr( + this.futarchyClient.getProgramId(), + ); + + const [tokenMetadata] = getMetadataAddr(baseMint); + + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ + multisigPda, + index: 0, + }); + + const [spendingLimit] = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + }); + + const treasuryQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + multisigVault, + true, + ); + + const [ammPosition] = PublicKey.findProgramAddressSync( + [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], + this.futarchyClient.getProgramId(), + ); + + const [performancePackage] = getPerformancePackageAddr({ + createKey: launchSigner, + }); + const performancePackageTokenAccount = getAssociatedTokenAddressSync( + baseMint, + performancePackage, + true, + ); + + const [poolAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], + DAMM_V2_PROGRAM_ID, + ); + + const [positionNftMint] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_mint"), baseMint.toBuffer()], + LAUNCHPAD_V0_6_PROGRAM_ID, + ); + + const [positionNftAccount] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + function getFirstKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf1; + } + return buf2; + } + + function getSecondKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + // Buf1 > buf2 + if (Buffer.compare(buf1, buf2) === 1) { + return buf2; + } + return buf1; + } + + const [pool] = PublicKey.findProgramAddressSync( + [ + Buffer.from("pool"), + meteoraConfig.toBuffer(), + getFirstKey(baseMint, quoteMint), + getSecondKey(baseMint, quoteMint), + ], + DAMM_V2_PROGRAM_ID, + ); + + const [position] = PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenAVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenBVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + LAUNCHPAD_V0_6_PROGRAM_ID, + ); + + const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); + + return this.launchpad.methods + .completeLaunch({ finalRaiseAmount }) + .accounts({ + launch, + launchSigner, + launchQuoteVault, + launchBaseVault, + launchAuthority, + dao, + treasuryQuoteAccount, + quoteMint, + baseMint, + tokenMetadata, + daoOwnedLpPosition: ammPosition, + futarchyAmmQuoteVault: getAssociatedTokenAddressSync( + quoteMint, + dao, + true, + ), + futarchyAmmBaseVault: getAssociatedTokenAddressSync( + baseMint, + dao, + true, + ), + staticAccounts: { + futarchyProgram: this.futarchyClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + autocratEventAuthority, + squadsProgram: SQUADS_PROGRAM_ID, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury: isDevnet + ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET + : SQUADS_PROGRAM_CONFIG_TREASURY, + priceBasedPerformancePackageProgram: this.priceBasedUnlock.programId, + priceBasedPerformancePackageEventAuthority: + this.priceBasedUnlock.getEventAuthorityAddress(), + }, + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + spendingLimit, + performancePackage, + performancePackageTokenAccount, + meteoraAccounts: { + dammV2Program: DAMM_V2_PROGRAM_ID, + positionNftMint, + baseMint, + quoteMint, + config: meteoraConfig, + token2022Program: TOKEN_2022_PROGRAM_ID, + positionNftAccount, + pool, + // baseMint, + // quoteMint, + poolCreatorAuthority, + position, + tokenAVault, + tokenBVault, + poolAuthority, + dammV2EventAuthority, + }, + // poolCreatorAuthority, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 850_000 }), + ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), + ]); + } + + refundIx({ + launch, + funder = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + + return this.launchpad.methods.refund().accounts({ + launch, + launchSigner, + launchQuoteVault, + funder, + funderQuoteAccount, + fundingRecord, + }); + } + + claimIx( + launch: PublicKey, + baseMint: PublicKey, + funder: PublicKey = this.provider.publicKey, + ) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods + .claim() + .accounts({ + launch, + fundingRecord, + launchSigner, + funder, + funderTokenAccount: getAssociatedTokenAddressSync( + baseMint, + funder, + true, + ), + baseMint, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, funder, true), + funder, + baseMint, + ), + ]); + } + + getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { + return getLaunchAddr(this.launchpad.programId, baseMint)[0]; + } + + getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { + return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; + } + + getFundingRecordAddress({ + launch, + funder, + }: { + launch: PublicKey; + funder: PublicKey; + }): PublicKey { + return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; + } +} diff --git a/sdk2/src/launchpad/v0.6/index.ts b/sdk2/src/launchpad/v0.6/index.ts new file mode 100644 index 000000000..2f88e3015 --- /dev/null +++ b/sdk2/src/launchpad/v0.6/index.ts @@ -0,0 +1 @@ +export * from "./types/index.js"; diff --git a/sdk2/src/launchpad/v0.6/pda.ts b/sdk2/src/launchpad/v0.6/pda.ts new file mode 100644 index 000000000..dacf3c5f5 --- /dev/null +++ b/sdk2/src/launchpad/v0.6/pda.ts @@ -0,0 +1,33 @@ +import { PublicKey } from "@solana/web3.js"; +import { LAUNCHPAD_V0_6_PROGRAM_ID } from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_6_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_6_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_6_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/launchpad/v0.6/types/index.ts b/sdk2/src/launchpad/v0.6/types/index.ts new file mode 100644 index 000000000..40606022c --- /dev/null +++ b/sdk2/src/launchpad/v0.6/types/index.ts @@ -0,0 +1,30 @@ +import { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; +import { + Launchpad as LaunchpadProgram, + IDL as LaunchpadIDL, +} from "./launchpad.js"; +export { LaunchpadProgram, LaunchpadIDL }; + +export type Launch = IdlAccounts["launch"]; +export type FundingRecord = IdlAccounts["fundingRecord"]; + +export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; +export type LaunchCompletedEvent = + IdlEvents["LaunchCompletedEvent"]; +export type LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type LaunchCloseEvent = IdlEvents["LaunchCloseEvent"]; +export type LaunchpadEvent = + | LaunchClaimEvent + | LaunchCompletedEvent + | LaunchFundedEvent + | LaunchInitializedEvent + | LaunchRefundedEvent + | LaunchStartedEvent + | LaunchCloseEvent; diff --git a/sdk2/src/launchpad/v0.6/types/launchpad.ts b/sdk2/src/launchpad/v0.6/types/launchpad.ts new file mode 100644 index 000000000..3950f26cf --- /dev/null +++ b/sdk2/src/launchpad/v0.6/types/launchpad.ts @@ -0,0 +1,2813 @@ +export type Launchpad = { + version: "0.6.1"; + name: "launchpad"; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "completeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + isOptional: true; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "daoOwnedLpPosition"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackageTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "futarchyProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageProgram"; + isMut: false; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "meteoraAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "config"; + isMut: false; + isSigner: false; + }, + { + name: "token2022Program"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: true; + isSigner: false; + }, + { + name: "pool"; + isMut: true; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "positionNftMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolCreatorAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "CompleteLaunchArgs"; + }; + }, + ]; + }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "closeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "returnFunds"; + accounts: [ + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "recipient"; + isMut: false; + isSigner: false; + }, + { + name: "recipientQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ReturnFundsArgs"; + }; + }, + ]; + }, + ]; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "finalRaiseAmount"; + docs: ["The final raise amount."]; + type: { + option: "u64"; + }; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + { + name: "teamAddress"; + docs: ["The initial address used to sponsor team proposals."]; + type: "publicKey"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "CompleteLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "finalRaiseAmount"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "ReturnFundsArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Closed"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + index: false; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + index: false; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + index: false; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "finalRaiseAmount"; + type: { + option: "u64"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchCloseEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "newState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchFundsReturnedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "recipient"; + type: "publicKey"; + index: false; + }, + { + name: "usdcReturned"; + type: "u64"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidTokenKey"; + msg: "Token mint key must end in 'meta'"; + }, + { + code: 6005; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6006; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6007; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6008; + name: "LaunchNotRefunding"; + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; + }, + { + code: 6009; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6010; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; + }, + { + code: 6012; + name: "InvalidMonthlySpendingLimitMembers"; + msg: "There can only be at most 10 monthly spending limit members"; + }, + { + code: 6013; + name: "InvalidPriceBasedPremineAmount"; + msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; + }, + { + code: 6014; + name: "InvalidPerformancePackageMinUnlockTime"; + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; + }, + { + code: 6015; + name: "LaunchAuthorityNotSet"; + msg: "Launch authority must be set to complete the launch until 2 days after closing"; + }, + { + code: 6016; + name: "FinalRaiseAmountTooLow"; + msg: "The final amount raised must be greater than or equal to the minimum raise amount"; + }, + { + code: 6017; + name: "TokensAlreadyClaimed"; + msg: "Tokens already claimed"; + }, + { + code: 6018; + name: "MoneyAlreadyRefunded"; + msg: "Money already refunded"; + }, + { + code: 6019; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6020; + name: "LaunchNotLive"; + msg: "Launch must be live to be closed"; + }, + { + code: 6021; + name: "InvalidMinimumRaiseAmount"; + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; + }, + { + code: 6022; + name: "InvalidAdmin"; + msg: "Invalid admin"; + }, + ]; +}; + +export const IDL: Launchpad = { + version: "0.6.1", + name: "launchpad", + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "completeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + isOptional: true, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "daoOwnedLpPosition", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "performancePackageTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "futarchyProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageProgram", + isMut: false, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "meteoraAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "config", + isMut: false, + isSigner: false, + }, + { + name: "token2022Program", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: true, + isSigner: false, + }, + { + name: "pool", + isMut: true, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "positionNftMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "poolCreatorAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "CompleteLaunchArgs", + }, + }, + ], + }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "closeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "returnFunds", + accounts: [ + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "recipient", + isMut: false, + isSigner: false, + }, + { + name: "recipientQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ReturnFundsArgs", + }, + }, + ], + }, + ], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "finalRaiseAmount", + docs: ["The final raise amount."], + type: { + option: "u64", + }, + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + { + name: "teamAddress", + docs: ["The initial address used to sponsor team proposals."], + type: "publicKey", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "CompleteLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "finalRaiseAmount", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + { + name: "performancePackageGrantee", + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + }, + { + name: "teamAddress", + type: "publicKey", + }, + ], + }, + }, + { + name: "ReturnFundsArgs", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Closed", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "performancePackageGrantee", + type: "publicKey", + index: false, + }, + { + name: "performancePackageTokenAmount", + type: "u64", + index: false, + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + index: false, + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + index: false, + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "finalRaiseAmount", + type: { + option: "u64", + }, + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchCloseEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "newState", + type: { + defined: "LaunchState", + }, + index: false, + }, + ], + }, + { + name: "LaunchFundsReturnedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "recipient", + type: "publicKey", + index: false, + }, + { + name: "usdcReturned", + type: "u64", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidTokenKey", + msg: "Token mint key must end in 'meta'", + }, + { + code: 6005, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6006, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6007, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6008, + name: "LaunchNotRefunding", + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", + }, + { + code: 6009, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6010, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", + }, + { + code: 6012, + name: "InvalidMonthlySpendingLimitMembers", + msg: "There can only be at most 10 monthly spending limit members", + }, + { + code: 6013, + name: "InvalidPriceBasedPremineAmount", + msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", + }, + { + code: 6014, + name: "InvalidPerformancePackageMinUnlockTime", + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", + }, + { + code: 6015, + name: "LaunchAuthorityNotSet", + msg: "Launch authority must be set to complete the launch until 2 days after closing", + }, + { + code: 6016, + name: "FinalRaiseAmountTooLow", + msg: "The final amount raised must be greater than or equal to the minimum raise amount", + }, + { + code: 6017, + name: "TokensAlreadyClaimed", + msg: "Tokens already claimed", + }, + { + code: 6018, + name: "MoneyAlreadyRefunded", + msg: "Money already refunded", + }, + { + code: 6019, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6020, + name: "LaunchNotLive", + msg: "Launch must be live to be closed", + }, + { + code: 6021, + name: "InvalidMinimumRaiseAmount", + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", + }, + { + code: 6022, + name: "InvalidAdmin", + msg: "Invalid admin", + }, + ], +}; From 038496a3e7b51a974e2f45a19a2ca8336d39b19a Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 25 Mar 2026 18:10:33 +0100 Subject: [PATCH 029/100] proper exports for all sdk v2 types --- package.json | 1 + sdk2/package.json | 9 --------- sdk2/src/futarchy/v0.6/index.ts | 2 +- sdk2/src/index.ts | 6 ++++++ sdk2/src/launchpad/v0.6/index.ts | 2 ++ sdk2/src/launchpad/v0.7/index.ts | 2 ++ sdk2/src/liquidation/v0.7/index.ts | 1 + yarn.lock | 15 +++++++++++++++ 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 20afedfc2..585c0afe2 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@coral-xyz/anchor": "=0.29.0", "@inquirer/prompts": "^7.3.3", "@metadaoproject/futarchy": "./sdk", + "@metadaoproject/futarchy-v2": "./sdk2", "@metaplex-foundation/mpl-token-metadata": "^3.2.0", "@metaplex-foundation/umi": "^0.9.1", "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", diff --git a/sdk2/package.json b/sdk2/package.json index 102b9072f..5d513edaa 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -9,19 +9,10 @@ "files": [ "/dist" ], - "exports": { - ".": "./dist/index.js", - "./v0.3": "./dist/v0.3/index.js", - "./v0.4": "./dist/v0.4/index.js", - "./v0.5": "./dist/v0.5/index.js", - "./v0.6": "./dist/v0.6/index.js", - "./v0.7": "./dist/v0.7/index.js" - }, "scripts": { "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", "build": "tsc", - "build-local": "rm -rf ./dist && cp ../target/types/* ./src/v0.7/types && yarn tsc", "prepublishOnly": "yarn lint:fix && yarn build" }, "dependencies": { diff --git a/sdk2/src/futarchy/v0.6/index.ts b/sdk2/src/futarchy/v0.6/index.ts index 433ec210e..d4b5169bb 100644 --- a/sdk2/src/futarchy/v0.6/index.ts +++ b/sdk2/src/futarchy/v0.6/index.ts @@ -1,3 +1,3 @@ -export * from "./FutarchyClient.js"; export * from "./types/index.js"; export * from "./pda.js"; +export * from "./FutarchyClient.js"; diff --git a/sdk2/src/index.ts b/sdk2/src/index.ts index 0b6b7872a..c1f207bf0 100644 --- a/sdk2/src/index.ts +++ b/sdk2/src/index.ts @@ -1,6 +1,12 @@ // Default exports for latest versions of programs +export * from "./bid_wall/index.js"; export * from "./conditional_vault/index.js"; export * from "./futarchy/index.js"; +export * from "./launchpad/index.js"; +export * from "./liquidation/index.js"; +export * from "./mint_governor/index.js"; +export * from "./performance_package_v2/index.js"; +export * from "./price_based_performance_package/index.js"; // Shared exports export * from "./utils.js"; diff --git a/sdk2/src/launchpad/v0.6/index.ts b/sdk2/src/launchpad/v0.6/index.ts index 2f88e3015..b5b9717d0 100644 --- a/sdk2/src/launchpad/v0.6/index.ts +++ b/sdk2/src/launchpad/v0.6/index.ts @@ -1 +1,3 @@ export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./LaunchpadClient.js"; diff --git a/sdk2/src/launchpad/v0.7/index.ts b/sdk2/src/launchpad/v0.7/index.ts index 2f88e3015..b5b9717d0 100644 --- a/sdk2/src/launchpad/v0.7/index.ts +++ b/sdk2/src/launchpad/v0.7/index.ts @@ -1 +1,3 @@ export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./LaunchpadClient.js"; diff --git a/sdk2/src/liquidation/v0.7/index.ts b/sdk2/src/liquidation/v0.7/index.ts index 3a387db23..92572d404 100644 --- a/sdk2/src/liquidation/v0.7/index.ts +++ b/sdk2/src/liquidation/v0.7/index.ts @@ -1,2 +1,3 @@ export * from "./types/index.js"; export * from "./pda.js"; +export * from "./LiquidationClient.js"; diff --git a/yarn.lock b/yarn.lock index 784a21dbe..7e4be782e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -974,6 +974,21 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@metadaoproject/futarchy-v2@./sdk2": + version "0.7.3-alpha.1" + dependencies: + "@coral-xyz/anchor" "^0.29.0" + "@metaplex-foundation/umi" "^0.9.2" + "@metaplex-foundation/umi-bundle-defaults" "^0.9.2" + "@metaplex-foundation/umi-uploader-bundlr" "^0.9.2" + "@noble/hashes" "^1.4.0" + "@solana/spl-token" "^0.3.7" + "@solana/web3.js" "^1.76.0" + "@sqds/multisig" "^2.1.4" + bn.js "^5.2.1" + decimal.js "^10.4.3" + esbuild "^0.17.15" + "@metadaoproject/futarchy@./sdk": version "0.7.3-alpha.1" dependencies: From 5aeef0e3318887626a1bf133fcc45158403dc2b5 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 28 Mar 2026 01:00:02 +0100 Subject: [PATCH 030/100] proper re-exports --- sdk2/package.json | 12 ++++++++++++ sdk2/src/index.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/sdk2/package.json b/sdk2/package.json index 5d513edaa..aa7c88f3b 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -5,6 +5,18 @@ "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", + "exports": { + ".": "./dist/index.js", + "./bid_wall/v0.7": "./dist/bid_wall/v0.7/index.js", + "./conditional_vault/v0.4": "./dist/conditional_vault/v0.4/index.js", + "./futarchy/v0.6": "./dist/futarchy/v0.6/index.js", + "./launchpad/v0.6": "./dist/launchpad/v0.6/index.js", + "./launchpad/v0.7": "./dist/launchpad/v0.7/index.js", + "./liquidation/v0.7": "./dist/liquidation/v0.7/index.js", + "./mint_governor/v0.7": "./dist/mint_governor/v0.7/index.js", + "./performance_package_v2/v0.7": "./dist/performance_package_v2/v0.7/index.js", + "./price_based_performance_package/v0.6": "./dist/price_based_performance_package/v0.6/index.js" + }, "license": "BSL-1.0", "files": [ "/dist" diff --git a/sdk2/src/index.ts b/sdk2/src/index.ts index c1f207bf0..c782b7b18 100644 --- a/sdk2/src/index.ts +++ b/sdk2/src/index.ts @@ -12,3 +12,5 @@ export * from "./price_based_performance_package/index.js"; export * from "./utils.js"; export * from "./constants.js"; export * from "./pda.js"; + +export { sha256 } from "@noble/hashes/sha256"; From 1f41716716d0f00b806dd9a67cebe42ba08a4912 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 28 Mar 2026 01:36:07 +0100 Subject: [PATCH 031/100] add pricemath --- sdk2/src/index.ts | 1 + sdk2/src/priceMath.ts | 214 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 sdk2/src/priceMath.ts diff --git a/sdk2/src/index.ts b/sdk2/src/index.ts index c782b7b18..bd08c833a 100644 --- a/sdk2/src/index.ts +++ b/sdk2/src/index.ts @@ -12,5 +12,6 @@ export * from "./price_based_performance_package/index.js"; export * from "./utils.js"; export * from "./constants.js"; export * from "./pda.js"; +export * from "./priceMath.js"; export { sha256 } from "@noble/hashes/sha256"; diff --git a/sdk2/src/priceMath.ts b/sdk2/src/priceMath.ts new file mode 100644 index 000000000..6a39b6969 --- /dev/null +++ b/sdk2/src/priceMath.ts @@ -0,0 +1,214 @@ +import BN from "bn.js"; + +const BN_TEN = new BN(10); +const PRICE_SCALE = BN_TEN.pow(new BN(12)); +const PRICE_SCALE_NUMBER = 1e12; + +export type AddLiquiditySimulation = { + baseAmount: BN; + quoteAmount: BN; + expectedLpTokens: BN; + minLpTokens?: BN; + maxBaseAmount?: BN; +}; + +export type SwapSimulation = { + expectedOut: BN; + newBaseReserves: BN; + newQuoteReserves: BN; + minExpectedOut?: BN; +}; + +export type RemoveLiquiditySimulation = { + expectedBaseOut: BN; + expectedQuoteOut: BN; + minBaseOut?: BN; + minQuoteOut?: BN; +}; + +export class AmmMath { + public static getHumanPriceFromReserves( + baseReserves: BN, + quoteReserves: BN, + baseDecimals: number, + quoteDecimals: number, + ): number { + return this.getHumanPrice( + this.getAmmPriceFromReserves(baseReserves, quoteReserves), + baseDecimals, + quoteDecimals, + ); + } + + public static getAmmPriceFromReserves( + baseReserves: BN, + quoteReserves: BN, + ): BN { + return quoteReserves.mul(PRICE_SCALE).div(baseReserves); + } + + public static getChainAmount(humanAmount: number, decimals: number): BN { + // you have to do it this weird way because BN can't be constructed with + // numbers larger than 2**50 + const [integerPart, fractionalPart = ""] = humanAmount + .toString() + .split("."); + return new BN(integerPart + fractionalPart) + .mul(new BN(10).pow(new BN(decimals))) + .div(new BN(10).pow(new BN(fractionalPart.length))); + } + + public static getHumanAmount(chainAmount: BN, decimals: number): number { + return chainAmount.toNumber() / 10 ** decimals; + } + + public static getHumanPrice( + ammPrice: BN, + baseDecimals: number, + quoteDecimals: number, + ): number { + const decimalScalar = BN_TEN.pow( + new BN(quoteDecimals - baseDecimals).abs(), + ); + const price1e12 = + quoteDecimals > baseDecimals + ? ammPrice.div(decimalScalar) + : ammPrice.mul(decimalScalar); + + // in case the BN is too large to cast to number, we try + try { + return price1e12.toNumber() / 1e12; + } catch (e) { + // BN tried to cast into number larger than 53 bits so we do division via BN methods first, then cast to number + return price1e12.div(new BN(1e12)).toNumber(); + } + } + + public static getAmmPrice( + humanPrice: number, + baseDecimals: number, + quoteDecimals: number, + ): BN { + let price1e12 = new BN(humanPrice * PRICE_SCALE_NUMBER); + + let decimalScalar = BN_TEN.pow(new BN(quoteDecimals - baseDecimals).abs()); + + let scaledPrice = + quoteDecimals > baseDecimals + ? price1e12.mul(decimalScalar) + : price1e12.div(decimalScalar); + + return scaledPrice; + } + + public static getAmmPrices( + baseDecimals: number, + quoteDecimals: number, + ...prices: number[] + ): BN[] { + return prices.map((price) => + this.getAmmPrice(price, baseDecimals, quoteDecimals), + ); + } + + public static scale(number: number, decimals: number): BN { + return new BN(number * 10 ** decimals); + } + + public static addSlippage(chainAmount: BN, slippageBps: BN): BN { + return chainAmount.mul(slippageBps.addn(10_000)).divn(10_000); + } + + public static subtractSlippage(chainAmount: BN, slippageBps: BN): BN { + return chainAmount.mul(new BN(10_000).sub(slippageBps)).divn(10_000); + } + + public static simulateSwapInner( + inputAmount: BN, + inputReserves: BN, + outputReserves: BN, + ): BN { + if (inputReserves.eqn(0) || outputReserves.eqn(0)) { + throw new Error("reserves must be non-zero"); + } + + let inputAmountWithFee: BN = inputAmount.muln(990); + + let numerator: BN = inputAmountWithFee.mul(outputReserves); + let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); + + return numerator.div(denominator); + } + + public static simulateAddLiquidity( + baseReserves: BN, + quoteReserves: BN, + lpMintSupply: number, + baseAmount?: BN, + quoteAmount?: BN, + slippageBps?: BN, + ): AddLiquiditySimulation { + if (lpMintSupply == 0) { + throw new Error( + "This AMM doesn't have existing liquidity so we can't fill in the blanks", + ); + } + + if (baseAmount == undefined && quoteAmount == undefined) { + throw new Error("Must specify either a base amount or a quote amount"); + } + + let expectedLpTokens: BN; + + if (quoteAmount == undefined) { + quoteAmount = baseAmount?.mul(quoteReserves).div(baseReserves); + } + baseAmount = quoteAmount?.mul(baseReserves).div(quoteReserves).addn(1); + + expectedLpTokens = quoteAmount + ?.mul(new BN(lpMintSupply)) + .div(quoteReserves) as BN; + + let minLpTokens, maxBaseAmount; + if (slippageBps) { + minLpTokens = AmmMath.subtractSlippage(expectedLpTokens, slippageBps); + maxBaseAmount = AmmMath.addSlippage(baseAmount as BN, slippageBps); + } + + return { + quoteAmount: quoteAmount as BN, + baseAmount: baseAmount as BN, + expectedLpTokens, + minLpTokens, + maxBaseAmount, + }; + } + + public static simulateRemoveLiquidity( + lpTokensToBurn: BN, + baseReserves: BN, + quoteReserves: BN, + lpTotalSupply: BN, + slippageBps?: BN, + ): RemoveLiquiditySimulation { + const expectedBaseOut = lpTokensToBurn.mul(baseReserves).div(lpTotalSupply); + const expectedQuoteOut = lpTokensToBurn + .mul(quoteReserves) + .div(lpTotalSupply); + + let minBaseOut, minQuoteOut; + if (slippageBps) { + minBaseOut = AmmMath.subtractSlippage(expectedBaseOut, slippageBps); + minQuoteOut = AmmMath.subtractSlippage(expectedQuoteOut, slippageBps); + } + + return { + expectedBaseOut, + expectedQuoteOut, + minBaseOut, + minQuoteOut, + }; + } +} + +export { AmmMath as PriceMath }; From be9e06e9a10a49aae5a9846be76f914f93afd9bd Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 28 Mar 2026 18:31:11 +0100 Subject: [PATCH 032/100] move tests to v2 sdk --- sdk2/src/launchpad/v0.6/pda.ts | 29 ++++++++++++++++++- tests/bidWall/main.test.ts | 13 +++++---- tests/bidWall/unit/cancelBidWall.test.ts | 2 +- tests/bidWall/unit/closeBidWall.test.ts | 2 +- tests/bidWall/unit/collectFees.test.ts | 2 +- tests/bidWall/unit/initializeBidWall.test.ts | 2 +- tests/bidWall/unit/sellTokens.test.ts | 2 +- tests/bidWall/utils.ts | 4 +-- .../binaryPredictionMarket.test.ts | 3 +- .../multiOptionPredictionMarket.test.ts | 2 +- .../integration/scalarGrantMarket.test.ts | 2 +- tests/conditionalVault/unit.ts | 6 ++-- .../addMetadataToConditionalTokens.test.ts | 4 +-- .../unit/initializeConditionalVault.test.ts | 4 +-- .../unit/initializeQuestion.test.ts | 10 +++---- .../conditionalVault/unit/mergeTokens.test.ts | 3 +- .../unit/redeemTokens.test.ts | 3 +- .../unit/resolveQuestion.test.ts | 3 +- .../conditionalVault/unit/splitTokens.test.ts | 3 +- .../futarchy/integration/fullProposal.test.ts | 6 ++-- .../futarchy/integration/futarchyAmm.test.ts | 5 +--- .../integration/proposalBatchTx.test.ts | 6 ++-- tests/futarchy/main.test.ts | 13 +++++---- .../unit/adminApproveMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminCancelProposal.test.ts | 14 ++++----- .../unit/adminExecuteMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminRemoveProposal.test.ts | 5 +--- tests/futarchy/unit/collectFees.test.ts | 2 +- .../unit/collectMeteoraDammFees.test.ts | 8 ++--- tests/futarchy/unit/conditionalSwap.test.ts | 2 +- .../unit/executeSpendingLimitChange.test.ts | 5 +--- .../unit/finalizeOptimisticProposal.test.ts | 5 ++-- tests/futarchy/unit/finalizeProposal.test.ts | 5 +--- tests/futarchy/unit/initializeDao.test.ts | 2 +- .../futarchy/unit/initializeProposal.test.ts | 2 +- ...itiateVaultSpendOptimisticProposal.test.ts | 5 ++-- tests/futarchy/unit/launchProposal.test.ts | 2 +- tests/futarchy/unit/provideLiquidity.test.ts | 12 ++++---- tests/futarchy/unit/updateDao.test.ts | 4 +-- tests/integration/fullLaunch.test.ts | 13 +++++---- tests/integration/fullLaunch_v7.test.ts | 13 +++++---- tests/integration/mintAndSwap.test.ts | 2 +- tests/launchpad/main.test.ts | 15 ++++++---- tests/launchpad/unit/claim.test.ts | 5 ++-- tests/launchpad/unit/closeLaunch.test.ts | 3 +- tests/launchpad/unit/completeLaunch.test.ts | 12 ++++---- tests/launchpad/unit/fund.test.ts | 5 ++-- tests/launchpad/unit/initializeLaunch.test.ts | 8 ++--- tests/launchpad/unit/refund.test.ts | 7 ++--- tests/launchpad/unit/returnFunds.test.ts | 5 ++-- tests/launchpad/unit/startLaunch.test.ts | 4 +-- tests/launchpad/utils.ts | 4 +-- tests/launchpad_v7/main.test.ts | 13 +++++---- tests/launchpad_v7/unit/claim.test.ts | 2 +- .../claimAdditionalTokenAllocation.test.ts | 2 +- tests/launchpad_v7/unit/closeLaunch.test.ts | 2 +- .../launchpad_v7/unit/completeLaunch.test.ts | 2 +- tests/launchpad_v7/unit/fund.test.ts | 2 +- .../unit/initializeLaunch.test.ts | 4 +-- .../unit/initializePerformancePackage.test.ts | 2 +- tests/launchpad_v7/unit/refund.test.ts | 2 +- .../unit/setFundingRecordApproval.test.ts | 2 +- tests/launchpad_v7/unit/startLaunch.test.ts | 4 +-- tests/launchpad_v7/utils.ts | 4 +-- tests/liquidation/main.test.ts | 2 +- .../unit/activateLiquidation.test.ts | 2 +- .../unit/initializeLiquidation.test.ts | 2 +- tests/liquidation/unit/refund.test.ts | 2 +- .../liquidation/unit/setRefundRecord.test.ts | 2 +- .../unit/withdrawRemainingQuote.test.ts | 2 +- tests/liquidation/utils.ts | 2 +- tests/main.test.ts | 12 ++++---- tests/mintGovernor/main.test.ts | 2 +- .../unit/addMintAuthority.test.ts | 2 +- .../unit/initializeMintGovernor.test.ts | 2 +- tests/mintGovernor/unit/mintTokens.test.ts | 2 +- .../unit/reclaimAuthority.test.ts | 2 +- .../unit/removeMintAuthority.test.ts | 2 +- .../unit/transferAuthorityToGovernor.test.ts | 2 +- .../unit/updateMintAuthority.test.ts | 2 +- .../unit/updateMintGovernorAdmin.test.ts | 2 +- tests/mintGovernor/utils.ts | 2 +- tests/performancePackageV2/main.test.ts | 2 +- .../unit/changeAuthority.test.ts | 2 +- .../unit/closePerformancePackage.test.ts | 2 +- .../unit/completeUnlock.test.ts | 4 +-- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 2 +- .../unit/proposeChange.test.ts | 2 +- .../unit/startUnlock.test.ts | 4 +-- tests/performancePackageV2/utils.ts | 4 +-- .../unit/burnPerformancePackage.test.ts | 2 +- .../unit/completeUnlock.test.ts | 2 +- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 2 +- .../unit/startUnlock.test.ts | 2 +- tests/utils.ts | 2 +- 97 files changed, 226 insertions(+), 199 deletions(-) diff --git a/sdk2/src/launchpad/v0.6/pda.ts b/sdk2/src/launchpad/v0.6/pda.ts index dacf3c5f5..8c1f6bce9 100644 --- a/sdk2/src/launchpad/v0.6/pda.ts +++ b/sdk2/src/launchpad/v0.6/pda.ts @@ -1,5 +1,9 @@ import { PublicKey } from "@solana/web3.js"; -import { LAUNCHPAD_V0_6_PROGRAM_ID } from "../../constants.js"; +import { + LAUNCHPAD_V0_6_PROGRAM_ID, + RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +} from "../../constants.js"; export function getLaunchAddr( programId: PublicKey = LAUNCHPAD_V0_6_PROGRAM_ID, @@ -31,3 +35,26 @@ export const getFundingRecordAddr = ( programId, ); }; + +export const getLiquidityPoolAddr = ( + programId: PublicKey = LAUNCHPAD_V0_6_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_state"), dao.toBuffer()], + programId, + ); +}; + +export const getRaydiumCpmmLpMintAddr = ( + poolState: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_lp_mint"), poolState.toBuffer()], + programId, + ); +}; diff --git a/tests/bidWall/main.test.ts b/tests/bidWall/main.test.ts index 2c5a5e985..0fd2919a7 100644 --- a/tests/bidWall/main.test.ts +++ b/tests/bidWall/main.test.ts @@ -5,9 +5,9 @@ import closeBidWall from "./unit/closeBidWall.test.js"; import cancelBidWall from "./unit/cancelBidWall.test.js"; import { PublicKey } from "@solana/web3.js"; import { - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy/v0.7"; + LAUNCHPAD_V0_7_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/futarchy-v2"; export default function suite() { before(async function () { @@ -22,7 +22,7 @@ export default function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_7_PROGRAM_ID, ); dynamicConfig.data.set( @@ -31,7 +31,10 @@ export default function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); }); describe("#initialize_bid_wall", initializeBidWall); describe("#sell_tokens", sellTokens); diff --git a/tests/bidWall/unit/cancelBidWall.test.ts b/tests/bidWall/unit/cancelBidWall.test.ts index 099c9abde..f040f8252 100644 --- a/tests/bidWall/unit/cancelBidWall.test.ts +++ b/tests/bidWall/unit/cancelBidWall.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/bidWall/unit/closeBidWall.test.ts b/tests/bidWall/unit/closeBidWall.test.ts index d424aba58..c806245cd 100644 --- a/tests/bidWall/unit/closeBidWall.test.ts +++ b/tests/bidWall/unit/closeBidWall.test.ts @@ -14,7 +14,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/collectFees.test.ts b/tests/bidWall/unit/collectFees.test.ts index 1e554a03e..7c11b0162 100644 --- a/tests/bidWall/unit/collectFees.test.ts +++ b/tests/bidWall/unit/collectFees.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync, diff --git a/tests/bidWall/unit/initializeBidWall.test.ts b/tests/bidWall/unit/initializeBidWall.test.ts index 336e58399..04be71d47 100644 --- a/tests/bidWall/unit/initializeBidWall.test.ts +++ b/tests/bidWall/unit/initializeBidWall.test.ts @@ -12,7 +12,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/sellTokens.test.ts b/tests/bidWall/unit/sellTokens.test.ts index ed3148bb7..c9a1a9886 100644 --- a/tests/bidWall/unit/sellTokens.test.ts +++ b/tests/bidWall/unit/sellTokens.test.ts @@ -12,7 +12,7 @@ import { BidWallClient, MAINNET_USDC, getBidWallAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/utils.ts b/tests/bidWall/utils.ts index 45fef8cb8..4b7a3b4c1 100644 --- a/tests/bidWall/utils.ts +++ b/tests/bidWall/utils.ts @@ -1,11 +1,11 @@ import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { BanksClient } from "solana-bankrun"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; import { + LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts index 51c24da35..db458344d 100644 --- a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts @@ -1,5 +1,4 @@ -import { ConditionalVaultClient } from "@metadaoproject/futarchy/v0.6"; -import { sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts index eba8424cf..74933fe06 100644 --- a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/scalarGrantMarket.test.ts b/tests/conditionalVault/integration/scalarGrantMarket.test.ts index 373d0055b..8446e65b0 100644 --- a/tests/conditionalVault/integration/scalarGrantMarket.test.ts +++ b/tests/conditionalVault/integration/scalarGrantMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/unit.ts b/tests/conditionalVault/unit.ts index dc732c775..351e40a80 100644 --- a/tests/conditionalVault/unit.ts +++ b/tests/conditionalVault/unit.ts @@ -27,13 +27,13 @@ import { IDL as ConditionalVaultIDL, } from "../../target/types/conditional_vault"; import { - CONDITIONAL_VAULT_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, ConditionalVaultClient, getConditionalTokenMintAddr, getQuestionAddr, getVaultAddr, sha256, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/futarchy-v2"; export type VaultProgram = anchor.Program; export type PublicKey = anchor.web3.PublicKey; @@ -97,7 +97,7 @@ describe("conditional_vault", async function () { vaultProgram = new Program( ConditionalVaultIDL, - CONDITIONAL_VAULT_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, provider, ); diff --git a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts index d14112fb9..29d08e38b 100644 --- a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts +++ b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts @@ -1,9 +1,9 @@ -import { sha256 } from "@metadaoproject/futarchy"; import { + sha256, ConditionalVaultClient, getConditionalTokenMintAddr, getMetadataAddr, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeConditionalVault.test.ts b/tests/conditionalVault/unit/initializeConditionalVault.test.ts index 98cc0c9f8..0844835a6 100644 --- a/tests/conditionalVault/unit/initializeConditionalVault.test.ts +++ b/tests/conditionalVault/unit/initializeConditionalVault.test.ts @@ -2,8 +2,8 @@ import { ConditionalVaultClient, getVaultAddr, getConditionalTokenMintAddr, -} from "@metadaoproject/futarchy/v0.5"; -import { sha256 } from "@metadaoproject/futarchy"; + sha256, +} from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint, getMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeQuestion.test.ts b/tests/conditionalVault/unit/initializeQuestion.test.ts index d46585c50..1cafb91de 100644 --- a/tests/conditionalVault/unit/initializeQuestion.test.ts +++ b/tests/conditionalVault/unit/initializeQuestion.test.ts @@ -1,12 +1,12 @@ -import { sha256 } from "@metadaoproject/futarchy"; +import { + sha256, + ConditionalVaultClient, + getQuestionAddr, +} from "@metadaoproject/futarchy-v2"; // const { ConditionalVaultClient, getQuestionAddr } = futarchy; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils"; -import { - ConditionalVaultClient, - getQuestionAddr, -} from "@metadaoproject/futarchy/v0.5"; // import { getQuestionAddr } from "@metadaoproject/futarchy/dist/v0.4"; export default function suite() { diff --git a/tests/conditionalVault/unit/mergeTokens.test.ts b/tests/conditionalVault/unit/mergeTokens.test.ts index 9e609b763..238c7a678 100644 --- a/tests/conditionalVault/unit/mergeTokens.test.ts +++ b/tests/conditionalVault/unit/mergeTokens.test.ts @@ -1,5 +1,4 @@ -import { sha256 } from "@metadaoproject/futarchy"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/v0.5"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/redeemTokens.test.ts b/tests/conditionalVault/unit/redeemTokens.test.ts index 52850abd5..d4c0894f1 100644 --- a/tests/conditionalVault/unit/redeemTokens.test.ts +++ b/tests/conditionalVault/unit/redeemTokens.test.ts @@ -1,5 +1,4 @@ -import { sha256 } from "@metadaoproject/futarchy"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/v0.5"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/resolveQuestion.test.ts b/tests/conditionalVault/unit/resolveQuestion.test.ts index 3fa0fba42..4e65f32f1 100644 --- a/tests/conditionalVault/unit/resolveQuestion.test.ts +++ b/tests/conditionalVault/unit/resolveQuestion.test.ts @@ -1,5 +1,4 @@ -import { sha256 } from "@metadaoproject/futarchy"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/v0.5"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/conditionalVault/unit/splitTokens.test.ts b/tests/conditionalVault/unit/splitTokens.test.ts index 65ab5e9f3..fd1e44931 100644 --- a/tests/conditionalVault/unit/splitTokens.test.ts +++ b/tests/conditionalVault/unit/splitTokens.test.ts @@ -1,5 +1,4 @@ -import { sha256 } from "@metadaoproject/futarchy"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/v0.5"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { getMint } from "spl-token-bankrun"; diff --git a/tests/futarchy/integration/fullProposal.test.ts b/tests/futarchy/integration/fullProposal.test.ts index 01ba873dd..c6143b571 100644 --- a/tests/futarchy/integration/fullProposal.test.ts +++ b/tests/futarchy/integration/fullProposal.test.ts @@ -1,4 +1,7 @@ -import { getDaoAddr } from "@metadaoproject/futarchy/v0.5"; +import { + getDaoAddr, + PERMISSIONLESS_ACCOUNT, +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, SystemProgram, @@ -7,7 +10,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; import { ONE_MINUTE_IN_SLOTS } from "../../utils.js"; export default function suite() { diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index 2325f8469..756db5511 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -1,7 +1,4 @@ -import { - PERMISSIONLESS_ACCOUNT, - PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/integration/proposalBatchTx.test.ts b/tests/futarchy/integration/proposalBatchTx.test.ts index 91b2889ee..3cf431ea5 100644 --- a/tests/futarchy/integration/proposalBatchTx.test.ts +++ b/tests/futarchy/integration/proposalBatchTx.test.ts @@ -1,4 +1,7 @@ -import { getDaoAddr } from "@metadaoproject/futarchy/v0.5"; +import { + getDaoAddr, + PERMISSIONLESS_ACCOUNT, +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, SystemProgram, @@ -7,7 +10,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; import { ONE_MINUTE_IN_SLOTS } from "../../utils.js"; export default function suite() { diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index 422a16dbf..aca66e648 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -23,9 +23,9 @@ import adminRemoveProposal from "./unit/adminRemoveProposal.test.js"; import { PublicKey } from "@solana/web3.js"; import { - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy/v0.7"; + LAUNCHPAD_V0_7_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/futarchy-v2"; export default function suite() { before(async function () { @@ -40,7 +40,7 @@ export default function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_7_PROGRAM_ID, ); dynamicConfig.data.set( @@ -49,7 +49,10 @@ export default function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); }); describe("#initialize_dao", initializeDao); describe("#initialize_proposal", initializeProposal); diff --git a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts index bbc4b756d..ccf868563 100644 --- a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index 2b0febe20..7ee98d275 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -1,9 +1,9 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; import { - CONDITIONAL_VAULT_PROGRAM_ID, + PERMISSIONLESS_ACCOUNT, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, SQUADS_PROGRAM_ID, getEventAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, @@ -151,7 +151,7 @@ export default function suite() { const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const [vaultEventAuthority] = getEventAuthorityAddr( - CONDITIONAL_VAULT_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, ); await this.futarchy.autocrat.methods @@ -194,7 +194,7 @@ export default function suite() { dao, true, ), - vaultProgram: CONDITIONAL_VAULT_PROGRAM_ID, + vaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, vaultEventAuthority, quoteVault, quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( @@ -249,7 +249,7 @@ export default function suite() { const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const [vaultEventAuthority] = getEventAuthorityAddr( - CONDITIONAL_VAULT_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, ); const accounts = { @@ -282,7 +282,7 @@ export default function suite() { dao, true, ), - vaultProgram: CONDITIONAL_VAULT_PROGRAM_ID, + vaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, vaultEventAuthority, quoteVault, quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( diff --git a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts index 3c0fae540..0d6dd1f09 100644 --- a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/adminRemoveProposal.test.ts b/tests/futarchy/unit/adminRemoveProposal.test.ts index aab9ef045..ccde4c023 100644 --- a/tests/futarchy/unit/adminRemoveProposal.test.ts +++ b/tests/futarchy/unit/adminRemoveProposal.test.ts @@ -1,7 +1,4 @@ -import { - PERMISSIONLESS_ACCOUNT, - PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/collectFees.test.ts b/tests/futarchy/unit/collectFees.test.ts index d00549749..643709798 100644 --- a/tests/futarchy/unit/collectFees.test.ts +++ b/tests/futarchy/unit/collectFees.test.ts @@ -12,7 +12,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import BN from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import { METADAO_MULTISIG_VAULT } from "../../../sdk/src/v0.6/constants.js"; diff --git a/tests/futarchy/unit/collectMeteoraDammFees.test.ts b/tests/futarchy/unit/collectMeteoraDammFees.test.ts index 5ecef4506..ea7e81b75 100644 --- a/tests/futarchy/unit/collectMeteoraDammFees.test.ts +++ b/tests/futarchy/unit/collectMeteoraDammFees.test.ts @@ -10,10 +10,10 @@ import { DAMM_V2_PROGRAM_ID, FutarchyClient, LaunchpadClient, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../../launchpad_v7/utils.js"; import { createLookupTableForTransaction } from "../../utils.js"; @@ -169,7 +169,7 @@ export default function suite() { const [pool] = PublicKey.findProgramAddressSync( [ Buffer.from("pool"), - MAINNET_METEORA_CONFIG.toBuffer(), + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG.toBuffer(), sortedMint1, sortedMint2, ], @@ -303,7 +303,7 @@ export default function suite() { quoteMint: MAINNET_USDC, transactionIndex: BigInt(squadsMultisigAccount.transactionIndex.toString()) + 1n, - meteoraConfig: MAINNET_METEORA_CONFIG, + meteoraConfig: LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, admin: this.payer.publicKey, }) .preInstructions([ diff --git a/tests/futarchy/unit/conditionalSwap.test.ts b/tests/futarchy/unit/conditionalSwap.test.ts index 05c6eb8df..ee1dba4b1 100644 --- a/tests/futarchy/unit/conditionalSwap.test.ts +++ b/tests/futarchy/unit/conditionalSwap.test.ts @@ -7,7 +7,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import { BN } from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import { ComputeBudget } from "litesvm"; diff --git a/tests/futarchy/unit/executeSpendingLimitChange.test.ts b/tests/futarchy/unit/executeSpendingLimitChange.test.ts index 4e7d4e2b1..8180287dc 100644 --- a/tests/futarchy/unit/executeSpendingLimitChange.test.ts +++ b/tests/futarchy/unit/executeSpendingLimitChange.test.ts @@ -1,7 +1,4 @@ -import { - PERMISSIONLESS_ACCOUNT, - PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index a25481887..f710567d6 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -1,7 +1,9 @@ import { PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy/v0.7"; + getDaoAddr, + MAINNET_USDC, +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, @@ -10,7 +12,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; -import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; import { createTransferInstruction, getAssociatedTokenAddressSync, diff --git a/tests/futarchy/unit/finalizeProposal.test.ts b/tests/futarchy/unit/finalizeProposal.test.ts index a93fec1cd..b3f7a427d 100644 --- a/tests/futarchy/unit/finalizeProposal.test.ts +++ b/tests/futarchy/unit/finalizeProposal.test.ts @@ -1,7 +1,4 @@ -import { - PERMISSIONLESS_ACCOUNT, - PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 8eced9a5d..1d0075024 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 6f4525658..21d2239cc 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index af1fc3eee..f1c2ddc1e 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -2,7 +2,9 @@ import { PERMISSIONLESS_ACCOUNT, PriceMath, SQUADS_PROGRAM_ID, -} from "@metadaoproject/futarchy/v0.7"; + getDaoAddr, + MAINNET_USDC, +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, @@ -14,7 +16,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; -import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; import { createAssociatedTokenAccountIdempotentInstruction, createTransferInstruction, diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index a536e0c00..bc97ffc92 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -3,7 +3,7 @@ import { PriceMath, getDaoAddr, getProposalAddrV2, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/provideLiquidity.test.ts b/tests/futarchy/unit/provideLiquidity.test.ts index 3464a10c2..ffd588e12 100644 --- a/tests/futarchy/unit/provideLiquidity.test.ts +++ b/tests/futarchy/unit/provideLiquidity.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { FUTARCHY_PROGRAM_ID } from "@metadaoproject/futarchy/v0.7"; +import { FUTARCHY_V0_6_PROGRAM_ID } from "@metadaoproject/futarchy-v2"; import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, @@ -32,7 +32,7 @@ export default function suite() { dao.toBuffer(), this.payer.publicKey.toBuffer(), ], - FUTARCHY_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, ); // Fetch position before @@ -83,7 +83,7 @@ export default function suite() { dao.toBuffer(), this.payer.publicKey.toBuffer(), ], - FUTARCHY_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, ); // Fetch position before attack @@ -132,7 +132,7 @@ export default function suite() { dao.toBuffer(), this.payer.publicKey.toBuffer(), ], - FUTARCHY_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, ); // Attacker calls provideLiquidityIx attempting hijack @@ -167,7 +167,7 @@ export default function suite() { // Derive event authority const [eventAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("__event_authority")], - FUTARCHY_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, ); // Victim withdraws all liquidity @@ -195,7 +195,7 @@ export default function suite() { ammPosition: ammPositionPda, tokenProgram: TOKEN_PROGRAM_ID, eventAuthority, - program: FUTARCHY_PROGRAM_ID, + program: FUTARCHY_V0_6_PROGRAM_ID, }) .rpc(); diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 879fa17c6..85e5767a4 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -14,8 +14,8 @@ import { getDaoAddr, PriceMath, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; -import { sha256 } from "@metadaoproject/futarchy"; + sha256, +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); diff --git a/tests/integration/fullLaunch.test.ts b/tests/integration/fullLaunch.test.ts index 8d9c18a4b..f2777e956 100644 --- a/tests/integration/fullLaunch.test.ts +++ b/tests/integration/fullLaunch.test.ts @@ -8,11 +8,11 @@ import { import { assert } from "chai"; import { getPerformancePackageAddr, - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_6_PROGRAM_ID, + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad/utils.js"; import { createLookupTableForTransaction } from "../utils.js"; @@ -34,7 +34,7 @@ export default async function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_6_PROGRAM_ID, ); dynamicConfig.data.set( @@ -43,7 +43,10 @@ export default async function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); }); it("launch a DAO, have a multi-ix proposal pass, execute it, and have insiders vest their first 2 tranches", async function () { diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index 74dbed827..e99a532a9 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -8,11 +8,11 @@ import { import { assert } from "chai"; import { getPerformancePackageAddr, - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_7_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad_v7/utils.js"; import { createLookupTableForTransaction } from "../utils.js"; @@ -34,7 +34,7 @@ export default async function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_7_PROGRAM_ID, ); dynamicConfig.data.set( @@ -43,7 +43,10 @@ export default async function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); }); it("launch a DAO, have a multi-ix proposal pass, execute it, and have insiders vest their first 2 tranches", async function () { diff --git a/tests/integration/mintAndSwap.test.ts b/tests/integration/mintAndSwap.test.ts index cd1780760..3022543fc 100644 --- a/tests/integration/mintAndSwap.test.ts +++ b/tests/integration/mintAndSwap.test.ts @@ -2,7 +2,7 @@ import { ConditionalVaultClient, FutarchyClient, InstructionUtils, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { PublicKey, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; diff --git a/tests/launchpad/main.test.ts b/tests/launchpad/main.test.ts index a8f77d349..6d7d3b719 100644 --- a/tests/launchpad/main.test.ts +++ b/tests/launchpad/main.test.ts @@ -7,12 +7,12 @@ import refund from "./unit/refund.test.js"; import closeLaunch from "./unit/closeLaunch.test.js"; import returnFunds from "./unit/returnFunds.test.js"; import { PublicKey } from "@solana/web3.js"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { - LAUNCHPAD_PROGRAM_ID, - LaunchpadClient, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_6_PROGRAM_ID, + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; import { BankrunProvider } from "anchor-bankrun"; @@ -30,7 +30,7 @@ export default function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_6_PROGRAM_ID, ); dynamicConfig.data.set( @@ -39,7 +39,10 @@ export default function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); this.setupBasicLaunch = async ({ baseMint, diff --git a/tests/launchpad/unit/claim.test.ts b/tests/launchpad/unit/claim.test.ts index bdaec5d10..0d3678b9e 100644 --- a/tests/launchpad/unit/claim.test.ts +++ b/tests/launchpad/unit/claim.test.ts @@ -6,11 +6,10 @@ import { } from "@solana/web3.js"; import { assert } from "chai"; import { - FutarchyClient, getFundingRecordAddr, LaunchpadClient, - MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/closeLaunch.test.ts b/tests/launchpad/unit/closeLaunch.test.ts index 259104ce9..d583e6a5f 100644 --- a/tests/launchpad/unit/closeLaunch.test.ts +++ b/tests/launchpad/unit/closeLaunch.test.ts @@ -1,6 +1,7 @@ import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/completeLaunch.test.ts b/tests/launchpad/unit/completeLaunch.test.ts index 26c8bf46d..206b72281 100644 --- a/tests/launchpad/unit/completeLaunch.test.ts +++ b/tests/launchpad/unit/completeLaunch.test.ts @@ -5,16 +5,16 @@ import { VersionedTransaction, } from "@solana/web3.js"; import { assert } from "chai"; -import { - getLiquidityPoolAddr, - getRaydiumCpmmLpMintAddr, -} from "@metadaoproject/futarchy/v0.5"; import { FutarchyClient, getMetadataAddr, - LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; +import { + getLiquidityPoolAddr, + getRaydiumCpmmLpMintAddr, + LaunchpadClient, +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad/unit/fund.test.ts b/tests/launchpad/unit/fund.test.ts index 908573c1a..fdbf9d461 100644 --- a/tests/launchpad/unit/fund.test.ts +++ b/tests/launchpad/unit/fund.test.ts @@ -1,11 +1,10 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { - FutarchyClient, getFundingRecordAddr, LaunchpadClient, - MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad/unit/initializeLaunch.test.ts b/tests/launchpad/unit/initializeLaunch.test.ts index e0f40213b..6d868b611 100644 --- a/tests/launchpad/unit/initializeLaunch.test.ts +++ b/tests/launchpad/unit/initializeLaunch.test.ts @@ -6,19 +6,19 @@ import { } from "@solana/web3.js"; import { assert } from "chai"; import { - FutarchyClient, getLaunchAddr, getLaunchSignerAddr, - getMetadataAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; import { + FutarchyClient, + getMetadataAddr, MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad/unit/refund.test.ts b/tests/launchpad/unit/refund.test.ts index cbec64bd6..678c20aa8 100644 --- a/tests/launchpad/unit/refund.test.ts +++ b/tests/launchpad/unit/refund.test.ts @@ -5,11 +5,8 @@ import { VersionedTransaction, } from "@solana/web3.js"; import { assert } from "chai"; -import { - FutarchyClient, - LaunchpadClient, - MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/returnFunds.test.ts b/tests/launchpad/unit/returnFunds.test.ts index e98782d36..97291f514 100644 --- a/tests/launchpad/unit/returnFunds.test.ts +++ b/tests/launchpad/unit/returnFunds.test.ts @@ -1,11 +1,10 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { - FutarchyClient, getLaunchSignerAddr, LaunchpadClient, - MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/launchpad/unit/startLaunch.test.ts b/tests/launchpad/unit/startLaunch.test.ts index 731353e9e..b1e37f46e 100644 --- a/tests/launchpad/unit/startLaunch.test.ts +++ b/tests/launchpad/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { MAINNET_USDC } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad/utils.ts b/tests/launchpad/utils.ts index 46f37b8ea..d294494f3 100644 --- a/tests/launchpad/utils.ts +++ b/tests/launchpad/utils.ts @@ -1,11 +1,11 @@ import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { BanksClient } from "solana-bankrun"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.6"; import { + LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/launchpad_v7/main.test.ts b/tests/launchpad_v7/main.test.ts index 53bbf1d00..91b58bb5b 100644 --- a/tests/launchpad_v7/main.test.ts +++ b/tests/launchpad_v7/main.test.ts @@ -10,10 +10,10 @@ import claimAdditionalTokenAllocation from "./unit/claimAdditionalTokenAllocatio import initializePerformancePackage from "./unit/initializePerformancePackage.test.js"; import { PublicKey } from "@solana/web3.js"; import { - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_7_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; // TODO add a many-outcome integration test @@ -30,7 +30,7 @@ export default function suite() { const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, + LAUNCHPAD_V0_7_PROGRAM_ID, ); dynamicConfig.data.set( @@ -39,7 +39,10 @@ export default function suite() { ); dynamicConfig.data.set([1], configTypeOffset); - this.context.setAccount(MAINNET_METEORA_CONFIG, dynamicConfig); + this.context.setAccount( + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); this.setupBasicLaunch = async ({ baseMint, diff --git a/tests/launchpad_v7/unit/claim.test.ts b/tests/launchpad_v7/unit/claim.test.ts index 012fe7cb0..56fcfb372 100644 --- a/tests/launchpad_v7/unit/claim.test.ts +++ b/tests/launchpad_v7/unit/claim.test.ts @@ -11,7 +11,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts index 1dd24b536..3b2e0792d 100644 --- a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts +++ b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts @@ -11,7 +11,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/closeLaunch.test.ts b/tests/launchpad_v7/unit/closeLaunch.test.ts index 33ff9ff01..b99efb61c 100644 --- a/tests/launchpad_v7/unit/closeLaunch.test.ts +++ b/tests/launchpad_v7/unit/closeLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/completeLaunch.test.ts b/tests/launchpad_v7/unit/completeLaunch.test.ts index 1f8f6dbf5..f30f591a3 100644 --- a/tests/launchpad_v7/unit/completeLaunch.test.ts +++ b/tests/launchpad_v7/unit/completeLaunch.test.ts @@ -11,7 +11,7 @@ import { getMetadataAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/fund.test.ts b/tests/launchpad_v7/unit/fund.test.ts index b683ae17b..9c3983ea6 100644 --- a/tests/launchpad_v7/unit/fund.test.ts +++ b/tests/launchpad_v7/unit/fund.test.ts @@ -10,7 +10,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad_v7/unit/initializeLaunch.test.ts b/tests/launchpad_v7/unit/initializeLaunch.test.ts index a4834db08..6f9dca305 100644 --- a/tests/launchpad_v7/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v7/unit/initializeLaunch.test.ts @@ -12,14 +12,14 @@ import { getLaunchSignerAddr, getMetadataAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; import { MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts index 98ffb081d..242c5d5a3 100644 --- a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts +++ b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts @@ -13,7 +13,7 @@ import { LaunchpadClient, MAINNET_USDC, PriceBasedPerformancePackageClient, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/refund.test.ts b/tests/launchpad_v7/unit/refund.test.ts index fa20453f7..31fece2ef 100644 --- a/tests/launchpad_v7/unit/refund.test.ts +++ b/tests/launchpad_v7/unit/refund.test.ts @@ -10,7 +10,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts index 0c50475ad..b5e8ef7d6 100644 --- a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts +++ b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts @@ -9,7 +9,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/startLaunch.test.ts b/tests/launchpad_v7/unit/startLaunch.test.ts index ea9f8bb8f..a1bd0da9b 100644 --- a/tests/launchpad_v7/unit/startLaunch.test.ts +++ b/tests/launchpad_v7/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey, Signer } from "@solana/web3.js"; import { assert } from "chai"; -import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad_v7/utils.ts b/tests/launchpad_v7/utils.ts index 45fef8cb8..8af05d043 100644 --- a/tests/launchpad_v7/utils.ts +++ b/tests/launchpad_v7/utils.ts @@ -1,11 +1,11 @@ import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { BanksClient } from "solana-bankrun"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2"; import { getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/liquidation/main.test.ts b/tests/liquidation/main.test.ts index a0dabe85a..3ac0c3379 100644 --- a/tests/liquidation/main.test.ts +++ b/tests/liquidation/main.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { BankrunProvider } from "anchor-bankrun"; import initializeLiquidation from "./unit/initializeLiquidation.test.js"; import setRefundRecord from "./unit/setRefundRecord.test.js"; diff --git a/tests/liquidation/unit/activateLiquidation.test.ts b/tests/liquidation/unit/activateLiquidation.test.ts index 2f8071ac5..61189b341 100644 --- a/tests/liquidation/unit/activateLiquidation.test.ts +++ b/tests/liquidation/unit/activateLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/initializeLiquidation.test.ts b/tests/liquidation/unit/initializeLiquidation.test.ts index 5872f809b..43564bc7a 100644 --- a/tests/liquidation/unit/initializeLiquidation.test.ts +++ b/tests/liquidation/unit/initializeLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import * as token from "@solana/spl-token"; diff --git a/tests/liquidation/unit/refund.test.ts b/tests/liquidation/unit/refund.test.ts index 0efc3f238..16bddeb7d 100644 --- a/tests/liquidation/unit/refund.test.ts +++ b/tests/liquidation/unit/refund.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey, diff --git a/tests/liquidation/unit/setRefundRecord.test.ts b/tests/liquidation/unit/setRefundRecord.test.ts index 6d364c7c8..fb89f6d95 100644 --- a/tests/liquidation/unit/setRefundRecord.test.ts +++ b/tests/liquidation/unit/setRefundRecord.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/withdrawRemainingQuote.test.ts b/tests/liquidation/unit/withdrawRemainingQuote.test.ts index a0a68d79f..ed1797120 100644 --- a/tests/liquidation/unit/withdrawRemainingQuote.test.ts +++ b/tests/liquidation/unit/withdrawRemainingQuote.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/utils.ts b/tests/liquidation/utils.ts index 7921ddfa8..0c4e37d8c 100644 --- a/tests/liquidation/utils.ts +++ b/tests/liquidation/utils.ts @@ -4,7 +4,7 @@ import { ComputeBudgetProgram, SystemProgram, } from "@solana/web3.js"; -import { LiquidationClient } from "@metadaoproject/futarchy/v0.7"; +import { LiquidationClient } from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; export async function setupLiquidation(ctx: Mocha.Context): Promise<{ diff --git a/tests/main.test.ts b/tests/main.test.ts index 75212cde4..783954674 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -26,7 +26,6 @@ import { SQUADS_PROGRAM_CONFIG, SQUADS_PROGRAM_ID, PERMISSIONLESS_ACCOUNT, - FUTARCHY_PROGRAM_ID, getDaoAddr, PriceMath, getProposalAddr, @@ -34,13 +33,14 @@ import { InstructionUtils, getPerformancePackageAddr, DAMM_V2_PROGRAM_ID, - LAUNCHPAD_PROGRAM_ID, - MAINNET_METEORA_CONFIG, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, BidWallClient, MintGovernorClient, LiquidationClient, -} from "@metadaoproject/futarchy/v0.7"; -import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy/v0.6"; + LOW_FEE_RAYDIUM_CONFIG, + sha256, +} from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { PublicKey, @@ -66,7 +66,6 @@ import { assert } from "chai"; import { MPL_TOKEN_METADATA_PROGRAM_ID as UMI_MPL_TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters"; import * as fs from "fs"; -import { LOW_FEE_RAYDIUM_CONFIG } from "@metadaoproject/futarchy/v0.4"; import { AccountInfo } from "@solana/web3.js"; const MPL_TOKEN_METADATA_PROGRAM_ID = toWeb3JsPublicKey( @@ -80,7 +79,6 @@ import mintAndSwap from "./integration/mintAndSwap.test.js"; import fullLaunch from "./integration/fullLaunch.test.js"; import fullLaunch_v7 from "./integration/fullLaunch_v7.test.js"; import { BN } from "bn.js"; -import { sha256 } from "@metadaoproject/futarchy"; const ONE_BUCK_PRICE = PriceMath.getAmmPrice(1, 6, 6); diff --git a/tests/mintGovernor/main.test.ts b/tests/mintGovernor/main.test.ts index 8c13c97b1..8b8297b50 100644 --- a/tests/mintGovernor/main.test.ts +++ b/tests/mintGovernor/main.test.ts @@ -6,7 +6,7 @@ import removeMintAuthority from "./unit/removeMintAuthority.test.js"; import mintTokens from "./unit/mintTokens.test.js"; import updateMintGovernorAdmin from "./unit/updateMintGovernorAdmin.test.js"; import reclaimAuthority from "./unit/reclaimAuthority.test.js"; -import { MintGovernorClient } from "@metadaoproject/futarchy/v0.7"; +import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/mintGovernor/unit/addMintAuthority.test.ts b/tests/mintGovernor/unit/addMintAuthority.test.ts index 5f77a04e6..1a739d7c0 100644 --- a/tests/mintGovernor/unit/addMintAuthority.test.ts +++ b/tests/mintGovernor/unit/addMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/initializeMintGovernor.test.ts b/tests/mintGovernor/unit/initializeMintGovernor.test.ts index a80ecb52f..657684cbe 100644 --- a/tests/mintGovernor/unit/initializeMintGovernor.test.ts +++ b/tests/mintGovernor/unit/initializeMintGovernor.test.ts @@ -3,7 +3,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { createMintWithAuthority } from "../utils.js"; export default function suite() { diff --git a/tests/mintGovernor/unit/mintTokens.test.ts b/tests/mintGovernor/unit/mintTokens.test.ts index 399147a8a..0b1f65703 100644 --- a/tests/mintGovernor/unit/mintTokens.test.ts +++ b/tests/mintGovernor/unit/mintTokens.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor, createMintAndGovernor, diff --git a/tests/mintGovernor/unit/reclaimAuthority.test.ts b/tests/mintGovernor/unit/reclaimAuthority.test.ts index c0b247b12..d56815ebc 100644 --- a/tests/mintGovernor/unit/reclaimAuthority.test.ts +++ b/tests/mintGovernor/unit/reclaimAuthority.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/removeMintAuthority.test.ts b/tests/mintGovernor/unit/removeMintAuthority.test.ts index c060ccfcd..80c105b6d 100644 --- a/tests/mintGovernor/unit/removeMintAuthority.test.ts +++ b/tests/mintGovernor/unit/removeMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts index d34823c2e..ccd0bd72e 100644 --- a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts +++ b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy/v0.7"; +import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; import { createMintWithAuthority, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintAuthority.test.ts b/tests/mintGovernor/unit/updateMintAuthority.test.ts index 9aff2b6a8..f94ca83eb 100644 --- a/tests/mintGovernor/unit/updateMintAuthority.test.ts +++ b/tests/mintGovernor/unit/updateMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts index f30481c69..9f7e83fbc 100644 --- a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts +++ b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy/v0.7"; +import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/utils.ts b/tests/mintGovernor/utils.ts index e9193a8f6..07f7ac585 100644 --- a/tests/mintGovernor/utils.ts +++ b/tests/mintGovernor/utils.ts @@ -9,7 +9,7 @@ import { BanksClient } from "solana-bankrun"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; /** * Creates a mint with the payer as the mint authority diff --git a/tests/performancePackageV2/main.test.ts b/tests/performancePackageV2/main.test.ts index a8b7cf515..acfcbdde1 100644 --- a/tests/performancePackageV2/main.test.ts +++ b/tests/performancePackageV2/main.test.ts @@ -8,7 +8,7 @@ import closePerformancePackage from "./unit/closePerformancePackage.test.js"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/performancePackageV2/unit/changeAuthority.test.ts b/tests/performancePackageV2/unit/changeAuthority.test.ts index 10b8b9344..d2521edeb 100644 --- a/tests/performancePackageV2/unit/changeAuthority.test.ts +++ b/tests/performancePackageV2/unit/changeAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/closePerformancePackage.test.ts b/tests/performancePackageV2/unit/closePerformancePackage.test.ts index d27ae1d08..a8f264ecf 100644 --- a/tests/performancePackageV2/unit/closePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/closePerformancePackage.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/completeUnlock.test.ts b/tests/performancePackageV2/unit/completeUnlock.test.ts index 1ca99b662..f20dcc005 100644 --- a/tests/performancePackageV2/unit/completeUnlock.test.ts +++ b/tests/performancePackageV2/unit/completeUnlock.test.ts @@ -10,7 +10,8 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; + getPerformancePackageV2Addr, +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, setupMintGovernorWithAuthority, @@ -20,7 +21,6 @@ import { setupDaoForTwapTests, } from "../utils.js"; import { expectError } from "../../utils.js"; -import { getPerformancePackageV2Addr } from "@metadaoproject/futarchy/v0.7"; export default function suite() { let mintGovernorClient: MintGovernorClient; diff --git a/tests/performancePackageV2/unit/executeChange.test.ts b/tests/performancePackageV2/unit/executeChange.test.ts index 1450ff583..3391ad01d 100644 --- a/tests/performancePackageV2/unit/executeChange.test.ts +++ b/tests/performancePackageV2/unit/executeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts index 1416ce079..324ed07dd 100644 --- a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts @@ -5,7 +5,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupMintGovernorWithAuthority, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/proposeChange.test.ts b/tests/performancePackageV2/unit/proposeChange.test.ts index 44108989b..b3aa0f624 100644 --- a/tests/performancePackageV2/unit/proposeChange.test.ts +++ b/tests/performancePackageV2/unit/proposeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/startUnlock.test.ts b/tests/performancePackageV2/unit/startUnlock.test.ts index 753ad53bd..b6e2ef634 100644 --- a/tests/performancePackageV2/unit/startUnlock.test.ts +++ b/tests/performancePackageV2/unit/startUnlock.test.ts @@ -4,7 +4,8 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy/v0.7"; + getPerformancePackageV2Addr, +} from "@metadaoproject/futarchy-v2"; import { setupPerformancePackageV2, createCliffLinearReward, @@ -13,7 +14,6 @@ import { setupDaoForTwapTests, } from "../utils.js"; import { expectError } from "../../utils.js"; -import { getPerformancePackageV2Addr } from "@metadaoproject/futarchy/v0.7"; export default function suite() { let mintGovernorClient: MintGovernorClient; diff --git a/tests/performancePackageV2/utils.ts b/tests/performancePackageV2/utils.ts index dea04a66c..1b2dcd1d6 100644 --- a/tests/performancePackageV2/utils.ts +++ b/tests/performancePackageV2/utils.ts @@ -16,11 +16,11 @@ import { getPerformancePackageV2Addr, PriceMath, getDaoAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; import type { PerformancePackageV2OracleReader, PerformancePackageV2RewardFunction, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy-v2"; /** * Creates a mint with the specified authority diff --git a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts index 795512fb8..3370f9893 100644 --- a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts @@ -10,7 +10,7 @@ import BN from "bn.js"; import { getPerformancePackageAddr, Tranche, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { expectError } from "../../utils.js"; import { getAssociatedTokenAddress } from "@solana/spl-token"; diff --git a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts index 7dc2be49c..b1fa9c12b 100644 --- a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts @@ -8,7 +8,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy/v0.6"; +import { getPerformancePackageAddr } from "@metadaoproject/futarchy-v2"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts index 42d8f0f03..52d43e1cc 100644 --- a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts +++ b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts @@ -7,7 +7,7 @@ import { import { assert } from "chai"; import BN from "bn.js"; import { expectError } from "../../utils.js"; -import { getChangeRequestAddr } from "@metadaoproject/futarchy/v0.6"; +import { getChangeRequestAddr } from "@metadaoproject/futarchy-v2"; export default function () { let createKey: Keypair; diff --git a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts index 6cc8a6831..2d91da2ee 100644 --- a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts @@ -10,7 +10,7 @@ import BN from "bn.js"; import { getPerformancePackageAddr, Tranche, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts index b17d10528..0a2ca4533 100644 --- a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts @@ -10,7 +10,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy/v0.6"; +import { getPerformancePackageAddr } from "@metadaoproject/futarchy-v2"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/utils.ts b/tests/utils.ts index a8a6ca3cd..938662f3a 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -10,7 +10,7 @@ import { Transaction, } from "@solana/web3.js"; import { TestContext } from "./main.test.js"; -import { getDaoAddr, PriceMath } from "@metadaoproject/futarchy/v0.6"; +import { getDaoAddr, PriceMath } from "@metadaoproject/futarchy-v2"; export const TEN_SECONDS_IN_SLOTS = 25n; export const ONE_MINUTE_IN_SLOTS = TEN_SECONDS_IN_SLOTS * 6n; From 8be31d081e02e78c19342d28d0a963e11ea3c156 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 28 Mar 2026 19:38:17 +0100 Subject: [PATCH 033/100] fix minor ts issues --- rebuild.sh | 3 + sdk2/package.json | 1 + .../v0.4/types/conditional_vault.ts | 62 +++++++------------ sdk2/sync-types.sh | 14 +++++ tests/bidWall/unit/cancelBidWall.test.ts | 2 +- tests/bidWall/unit/closeBidWall.test.ts | 2 +- tests/launchpad_v7/unit/fund.test.ts | 17 ----- 7 files changed, 44 insertions(+), 57 deletions(-) create mode 100755 sdk2/sync-types.sh diff --git a/rebuild.sh b/rebuild.sh index 8fe5fdcbd..d718528a0 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -5,6 +5,9 @@ anchor build cd sdk yarn build-local cd .. +cd sdk2 yarn install --force +yarn build-local +cd .. yarn lint:fix echo "✅ SDK types synced successfully" \ No newline at end of file diff --git a/sdk2/package.json b/sdk2/package.json index aa7c88f3b..b0abc4215 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -25,6 +25,7 @@ "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", "build": "tsc", + "build-local": "rm -rf ./dist && ./sync-types.sh && yarn tsc", "prepublishOnly": "yarn lint:fix && yarn build" }, "dependencies": { diff --git a/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts b/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts index 27c245b79..aae14616a 100644 --- a/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts +++ b/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts @@ -93,7 +93,7 @@ export type ConditionalVault = { }, { name: "vaultUnderlyingTokenAccount"; - isMut: false; + isMut: true; isSigner: false; }, { @@ -292,7 +292,7 @@ export type ConditionalVault = { }, { name: "conditionalTokenMint"; - isMut: true; + isMut: false; isSigner: false; }, { @@ -499,23 +499,6 @@ export type ConditionalVault = { ]; }; }, - { - name: "VaultStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Active"; - }, - { - name: "Finalized"; - }, - { - name: "Reverted"; - }, - ]; - }; - }, ]; events: [ { @@ -920,6 +903,16 @@ export type ConditionalVault = { name: "UnauthorizedConditionalTokenAccount"; msg: "Conditional token account is not owned by the authority"; }, + { + code: 6017; + name: "InvalidPayoutNumerators"; + msg: "Payout numerators are too large, causing an overflow"; + }, + { + code: 6018; + name: "TooManyOutcomes"; + msg: "Questions can only have up to 10 outcomes"; + }, ]; }; @@ -1018,7 +1011,7 @@ export const IDL: ConditionalVault = { }, { name: "vaultUnderlyingTokenAccount", - isMut: false, + isMut: true, isSigner: false, }, { @@ -1217,7 +1210,7 @@ export const IDL: ConditionalVault = { }, { name: "conditionalTokenMint", - isMut: true, + isMut: false, isSigner: false, }, { @@ -1424,23 +1417,6 @@ export const IDL: ConditionalVault = { ], }, }, - { - name: "VaultStatus", - type: { - kind: "enum", - variants: [ - { - name: "Active", - }, - { - name: "Finalized", - }, - { - name: "Reverted", - }, - ], - }, - }, ], events: [ { @@ -1845,5 +1821,15 @@ export const IDL: ConditionalVault = { name: "UnauthorizedConditionalTokenAccount", msg: "Conditional token account is not owned by the authority", }, + { + code: 6017, + name: "InvalidPayoutNumerators", + msg: "Payout numerators are too large, causing an overflow", + }, + { + code: 6018, + name: "TooManyOutcomes", + msg: "Questions can only have up to 10 outcomes", + }, ], }; diff --git a/sdk2/sync-types.sh b/sdk2/sync-types.sh new file mode 100755 index 000000000..7e99ab46f --- /dev/null +++ b/sdk2/sync-types.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Copies IDL type files from anchor build output into sdk2 program type directories. + +TYPES_DIR="../target/types" + +cp "$TYPES_DIR/bid_wall.ts" ./src/bid_wall/v0.7/types/ +cp "$TYPES_DIR/conditional_vault.ts" ./src/conditional_vault/v0.4/types/ +cp "$TYPES_DIR/futarchy.ts" ./src/futarchy/v0.6/types/ +cp "$TYPES_DIR/launchpad.ts" ./src/launchpad/v0.6/types/ +cp "$TYPES_DIR/launchpad_v7.ts" ./src/launchpad/v0.7/types/ +cp "$TYPES_DIR/liquidation.ts" ./src/liquidation/v0.7/types/ +cp "$TYPES_DIR/mint_governor.ts" ./src/mint_governor/v0.7/types/ +cp "$TYPES_DIR/performance_package_v2.ts" ./src/performance_package_v2/v0.7/types/ +cp "$TYPES_DIR/price_based_performance_package.ts" ./src/price_based_performance_package/v0.6/types/ diff --git a/tests/bidWall/unit/cancelBidWall.test.ts b/tests/bidWall/unit/cancelBidWall.test.ts index f040f8252..5b27df9c8 100644 --- a/tests/bidWall/unit/cancelBidWall.test.ts +++ b/tests/bidWall/unit/cancelBidWall.test.ts @@ -83,6 +83,7 @@ export default function suite() { performancePackageTokenAmount: new BN(10), // Effectively no premine monthsUntilInsidersCanUnlock: 24, // 2 years teamAddress: PublicKey.default, + hasBidWall: true, }) .rpc(); @@ -137,7 +138,6 @@ export default function suite() { dao = launchAccount.dao; daoTreasury = launchAccount.daoVault; - let ammBaseVaultReserves = new BN(await this.getTokenBalance(META, dao)); let ammQuoteVaultReserves = new BN( await this.getTokenBalance(MAINNET_USDC, dao), ); diff --git a/tests/bidWall/unit/closeBidWall.test.ts b/tests/bidWall/unit/closeBidWall.test.ts index c806245cd..4b2e02a44 100644 --- a/tests/bidWall/unit/closeBidWall.test.ts +++ b/tests/bidWall/unit/closeBidWall.test.ts @@ -82,6 +82,7 @@ export default function suite() { performancePackageTokenAmount: new BN(10), // Effectively no premine monthsUntilInsidersCanUnlock: 24, // 2 years teamAddress: PublicKey.default, + hasBidWall: true, }) .rpc(); @@ -136,7 +137,6 @@ export default function suite() { dao = launchAccount.dao; daoTreasury = launchAccount.daoVault; - let ammBaseVaultReserves = new BN(await this.getTokenBalance(META, dao)); let ammQuoteVaultReserves = new BN( await this.getTokenBalance(MAINNET_USDC, dao), ); diff --git a/tests/launchpad_v7/unit/fund.test.ts b/tests/launchpad_v7/unit/fund.test.ts index 9c3983ea6..70a852e27 100644 --- a/tests/launchpad_v7/unit/fund.test.ts +++ b/tests/launchpad_v7/unit/fund.test.ts @@ -6,7 +6,6 @@ import { } from "@solana/web3.js"; import { assert } from "chai"; import { - FutarchyClient, getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, @@ -17,15 +16,11 @@ import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { - let autocratClient: FutarchyClient; let launchpadClient: LaunchpadClient; let META: PublicKey; let launch: PublicKey; let launchSigner: PublicKey; - let baseVault: PublicKey; let quoteVault: PublicKey; - let funderBaseAccount: PublicKey; - let funderQuoteAccount: PublicKey; let launchAuthority: Signer; const minRaise = new BN(1000_000000); // 1000 USDC @@ -33,10 +28,7 @@ export default function suite() { const monthlySpend = new BN(100_000000); const recipientAddress = Keypair.generate().publicKey; const premineAmount = new BN(500_000_000); - const unlockThreshold = new BN(2000_000000); - before(async function () { - autocratClient = this.futarchy; launchpadClient = this.launchpad_v7; }); @@ -52,20 +44,11 @@ export default function suite() { launchSigner = result.launchSigner; launchAuthority = new Keypair(); - baseVault = getAssociatedTokenAddressSync(META, launchSigner, true); quoteVault = getAssociatedTokenAddressSync( MAINNET_USDC, launchSigner, true, ); - funderBaseAccount = getAssociatedTokenAddressSync( - META, - this.payer.publicKey, - ); - funderQuoteAccount = getAssociatedTokenAddressSync( - MAINNET_USDC, - this.payer.publicKey, - ); // TODO: put this in main test // Initialize launch From 3ceac1ebb007136a36ba4e17f8fbf55f6f6ee57d Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 28 Mar 2026 23:13:34 +0100 Subject: [PATCH 034/100] add relevant 0.5 clients to sdk v2 --- sdk2/package.json | 6 +- sdk2/src/amm/index.ts | 1 + sdk2/src/amm/v0.5/AmmClient.ts | 381 +++ sdk2/src/amm/v0.5/index.ts | 3 + sdk2/src/amm/v0.5/pda.ts | 28 + sdk2/src/amm/v0.5/types/amm.ts | 1663 +++++++++++++ sdk2/src/amm/v0.5/types/index.ts | 19 + sdk2/src/autocrat/index.ts | 1 + sdk2/src/autocrat/v0.5/AutocratClient.ts | 666 ++++++ sdk2/src/autocrat/v0.5/index.ts | 3 + sdk2/src/autocrat/v0.5/pda.ts | 40 + sdk2/src/autocrat/v0.5/types/autocrat.ts | 2121 ++++++++++++++++ sdk2/src/autocrat/v0.5/types/index.ts | 27 + sdk2/src/constants.ts | 7 + sdk2/src/launchpad/v0.5/LaunchpadClient.ts | 449 ++++ sdk2/src/launchpad/v0.5/index.ts | 3 + sdk2/src/launchpad/v0.5/pda.ts | 61 + sdk2/src/launchpad/v0.5/types/index.ts | 29 + sdk2/src/launchpad/v0.5/types/launchpad.ts | 2123 +++++++++++++++++ sdk2/src/shared_liquidity_manager/index.ts | 1 + .../v0.5/SharedLiquidityManagerClient.ts | 865 +++++++ .../shared_liquidity_manager/v0.5/index.ts | 3 + sdk2/src/shared_liquidity_manager/v0.5/pda.ts | 126 + .../v0.5/types/index.ts | 5 + .../v0.5/types/shared_liquidity_manager.ts | 177 ++ 25 files changed, 8807 insertions(+), 1 deletion(-) create mode 100644 sdk2/src/amm/index.ts create mode 100644 sdk2/src/amm/v0.5/AmmClient.ts create mode 100644 sdk2/src/amm/v0.5/index.ts create mode 100644 sdk2/src/amm/v0.5/pda.ts create mode 100644 sdk2/src/amm/v0.5/types/amm.ts create mode 100644 sdk2/src/amm/v0.5/types/index.ts create mode 100644 sdk2/src/autocrat/index.ts create mode 100644 sdk2/src/autocrat/v0.5/AutocratClient.ts create mode 100644 sdk2/src/autocrat/v0.5/index.ts create mode 100644 sdk2/src/autocrat/v0.5/pda.ts create mode 100644 sdk2/src/autocrat/v0.5/types/autocrat.ts create mode 100644 sdk2/src/autocrat/v0.5/types/index.ts create mode 100644 sdk2/src/launchpad/v0.5/LaunchpadClient.ts create mode 100644 sdk2/src/launchpad/v0.5/index.ts create mode 100644 sdk2/src/launchpad/v0.5/pda.ts create mode 100644 sdk2/src/launchpad/v0.5/types/index.ts create mode 100644 sdk2/src/launchpad/v0.5/types/launchpad.ts create mode 100644 sdk2/src/shared_liquidity_manager/index.ts create mode 100644 sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts create mode 100644 sdk2/src/shared_liquidity_manager/v0.5/index.ts create mode 100644 sdk2/src/shared_liquidity_manager/v0.5/pda.ts create mode 100644 sdk2/src/shared_liquidity_manager/v0.5/types/index.ts create mode 100644 sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts diff --git a/sdk2/package.json b/sdk2/package.json index b0abc4215..4f9d5db03 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -15,7 +15,11 @@ "./liquidation/v0.7": "./dist/liquidation/v0.7/index.js", "./mint_governor/v0.7": "./dist/mint_governor/v0.7/index.js", "./performance_package_v2/v0.7": "./dist/performance_package_v2/v0.7/index.js", - "./price_based_performance_package/v0.6": "./dist/price_based_performance_package/v0.6/index.js" + "./price_based_performance_package/v0.6": "./dist/price_based_performance_package/v0.6/index.js", + "./autocrat/v0.5": "./dist/autocrat/v0.5/index.js", + "./amm/v0.5": "./dist/amm/v0.5/index.js", + "./launchpad/v0.5": "./dist/launchpad/v0.5/index.js", + "./shared_liquidity_manager/v0.5": "./dist/shared_liquidity_manager/v0.5/index.js" }, "license": "BSL-1.0", "files": [ diff --git a/sdk2/src/amm/index.ts b/sdk2/src/amm/index.ts new file mode 100644 index 000000000..6ef9c15e5 --- /dev/null +++ b/sdk2/src/amm/index.ts @@ -0,0 +1 @@ +export * from "./v0.5/index.js"; diff --git a/sdk2/src/amm/v0.5/AmmClient.ts b/sdk2/src/amm/v0.5/AmmClient.ts new file mode 100644 index 000000000..57e090246 --- /dev/null +++ b/sdk2/src/amm/v0.5/AmmClient.ts @@ -0,0 +1,381 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AddressLookupTableAccount, + Keypair, + PublicKey, +} from "@solana/web3.js"; + +import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; + +import BN from "bn.js"; +import { AMM_PROGRAM_ID } from "../../constants.js"; +import { Amm } from "./types/index.js"; +import { LowercaseKeys } from "../../utils.js"; +import { getAmmLpMintAddr, getAmmAddr } from "./pda.js"; +import { + MintLayout, + unpackMint, + getAssociatedTokenAddressSync, + createAssociatedTokenAccountIdempotentInstruction, +} from "@solana/spl-token"; +import { AmmMath, PriceMath } from "../../priceMath.js"; + +export type SwapType = LowercaseKeys["SwapType"]>; + +export type CreateAmmClientParams = { + provider: AnchorProvider; + ammProgramId?: PublicKey; +}; + +export class AmmClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.program = new Program(AmmIDL, ammProgramId, provider); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateAmmClientParams, + ): AmmClient { + let { provider, ammProgramId: programId } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AmmClient(provider, programId || AMM_PROGRAM_ID, luts); + } + + getProgramId(): PublicKey { + return this.program.programId; + } + + async getAmm(amm: PublicKey): Promise { + return await this.program.account.amm.fetch(amm); + } + + async fetchAmm(amm: PublicKey): Promise { + return await this.program.account.amm.fetchNullable(amm); + } + + async deserializeAmm(accountInfo: AccountInfo): Promise { + return this.program.coder.accounts.decode("amm", accountInfo.data); + } + + async createAmm( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + twapStartDelaySlots: BN, + twapInitialObservation: number, + twapMaxObservationChangePerUpdate?: number, + ): Promise { + if (!twapMaxObservationChangePerUpdate) { + twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; + } + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + + let baseDecimals = unpackMint( + baseMint, + await this.provider.connection.getAccountInfo(baseMint), + ).decimals; + let quoteDecimals = unpackMint( + quoteMint, + await this.provider.connection.getAccountInfo(quoteMint), + ).decimals; + + let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = + PriceMath.getAmmPrices( + baseDecimals, + quoteDecimals, + twapInitialObservation, + twapMaxObservationChangePerUpdate, + ); + + await this.initializeAmmIx( + baseMint, + quoteMint, + twapStartDelaySlots, + twapFirstObservationScaled, + twapMaxObservationChangePerUpdateScaled, + ).rpc(); + + return amm; + } + + // both twap values need to be scaled beforehand + initializeAmmIx( + baseMint: PublicKey, + quoteMint: PublicKey, + twapStartDelaySlots: BN, + twapInitialObservation: BN, + twapMaxObservationChangePerUpdate: BN, + ) { + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); + + let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); + let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); + + return this.program.methods + .createAmm({ + twapInitialObservation, + twapMaxObservationChangePerUpdate, + twapStartDelaySlots, + }) + .accounts({ + user: this.provider.publicKey, + amm, + lpMint, + baseMint, + quoteMint, + vaultAtaBase, + vaultAtaQuote, + }); + } + + async addLiquidity( + amm: PublicKey, + quoteAmount?: number, + baseAmount?: number, + ) { + let storedAmm = await this.getAmm(amm); + + let lpMintSupply = unpackMint( + storedAmm.lpMint, + await this.provider.connection.getAccountInfo(storedAmm.lpMint), + ).supply; + + let quoteAmountCasted: BN | undefined; + let baseAmountCasted: BN | undefined; + + if (quoteAmount != undefined) { + let quoteDecimals = unpackMint( + storedAmm.quoteMint, + await this.provider.connection.getAccountInfo(storedAmm.quoteMint), + ).decimals; + quoteAmountCasted = new BN(quoteAmount).mul( + new BN(10).pow(new BN(quoteDecimals)), + ); + } + + if (baseAmount != undefined) { + let baseDecimals = unpackMint( + storedAmm.baseMint, + await this.provider.connection.getAccountInfo(storedAmm.baseMint), + ).decimals; + baseAmountCasted = new BN(baseAmount).mul( + new BN(10).pow(new BN(baseDecimals)), + ); + } + + if (lpMintSupply == 0n) { + if (quoteAmount == undefined || baseAmount == undefined) { + throw new Error( + "No pool created yet, you need to specify both base and quote", + ); + } + + // console.log(quoteAmountCasted?.toString()); + // console.log(baseAmountCasted?.toString()) + + return await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + quoteAmountCasted as BN, + baseAmountCasted as BN, + new BN(0), + ).rpc(); + } + + // quoteAmount == undefined ? undefined : new BN(quoteAmount); + // let baseAmountCasted: BN | undefined = + // baseAmount == undefined ? undefined : new BN(baseAmount); + + let sim = AmmMath.simulateAddLiquidity( + storedAmm.baseAmount, + storedAmm.quoteAmount, + Number(lpMintSupply), + baseAmountCasted, + quoteAmountCasted, + ); + + await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + sim.quoteAmount, + sim.baseAmount, + sim.expectedLpTokens, + ).rpc(); + } + + addLiquidityIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + quoteAmount: BN, + maxBaseAmount: BN, + minLpTokens: BN, + user: PublicKey = this.provider.publicKey, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); + + const userLpAccount = getAssociatedTokenAddressSync(lpMint, user, true); + + return this.program.methods + .addLiquidity({ + quoteAmount, + maxBaseAmount, + minLpTokens, + }) + .accounts({ + user, + amm, + lpMint, + userLpAccount, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + user, + userLpAccount, + user, + lpMint, + ), + ]); + } + + removeLiquidityIx( + ammAddr: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + lpTokensToBurn: BN, + minBaseAmount: BN, + minQuoteAmount: BN, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); + + return this.program.methods + .removeLiquidity({ + lpTokensToBurn, + minBaseAmount, + minQuoteAmount, + }) + .accounts({ + user: this.provider.publicKey, + amm: ammAddr, + lpMint, + userLpAccount: getAssociatedTokenAddressSync( + lpMint, + this.provider.publicKey, + true, + ), + userBaseAccount: getAssociatedTokenAddressSync( + baseMint, + this.provider.publicKey, + true, + ), + userQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + this.provider.publicKey, + true, + ), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), + }); + } + + async swap( + amm: PublicKey, + swapType: SwapType, + inputAmount: number, + outputAmountMin: number, + ) { + const storedAmm = await this.getAmm(amm); + + let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); + let baseDecimals = await this.getDecimals(storedAmm.baseMint); + + let inputAmountScaled: BN; + let outputAmountMinScaled: BN; + if (swapType.buy) { + inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); + } else { + inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); + } + + return await this.swapIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + swapType, + inputAmountScaled, + outputAmountMinScaled, + ).rpc(); + } + + swapIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + swapType: SwapType, + inputAmount: BN, + outputAmountMin: BN, + user: PublicKey = this.provider.publicKey, + ) { + const receivingToken = swapType.buy ? baseMint : quoteMint; + + return this.program.methods + .swap({ + swapType, + inputAmount, + outputAmountMin, + }) + .accounts({ + user, + amm, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + // create the receiving token account if it doesn't exist + createAssociatedTokenAccountIdempotentInstruction( + user, + getAssociatedTokenAddressSync(receivingToken, user, true), + user, + receivingToken, + ), + ]); + } + + async crankThatTwap(amm: PublicKey) { + return this.crankThatTwapIx(amm).rpc(); + } + + crankThatTwapIx(amm: PublicKey) { + return this.program.methods.crankThatTwap().accounts({ + amm, + }); + } + + async getDecimals(mint: PublicKey): Promise { + return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) + .decimals; + } +} diff --git a/sdk2/src/amm/v0.5/index.ts b/sdk2/src/amm/v0.5/index.ts new file mode 100644 index 000000000..cf8af7f89 --- /dev/null +++ b/sdk2/src/amm/v0.5/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./AmmClient.js"; diff --git a/sdk2/src/amm/v0.5/pda.ts b/sdk2/src/amm/v0.5/pda.ts new file mode 100644 index 000000000..d8adea698 --- /dev/null +++ b/sdk2/src/amm/v0.5/pda.ts @@ -0,0 +1,28 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { AMM_PROGRAM_ID } from "../../constants.js"; + +export const getAmmAddr = ( + programId: PublicKey = AMM_PROGRAM_ID, + baseMint: PublicKey, + quoteMint: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("amm__"), + baseMint.toBuffer(), + quoteMint.toBuffer(), + ], + programId, + ); +}; + +export const getAmmLpMintAddr = ( + programId: PublicKey = AMM_PROGRAM_ID, + amm: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/amm/v0.5/types/amm.ts b/sdk2/src/amm/v0.5/types/amm.ts new file mode 100644 index 000000000..6d36be8d8 --- /dev/null +++ b/sdk2/src/amm/v0.5/types/amm.ts @@ -0,0 +1,1663 @@ +export type Amm = { + version: "0.5.0"; + name: "amm"; + instructions: [ + { + name: "createAmm"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "CreateAmmArgs"; + }; + }, + ]; + }, + { + name: "addLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddLiquidityArgs"; + }; + }, + ]; + }, + { + name: "removeLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "RemoveLiquidityArgs"; + }; + }, + ]; + }, + { + name: "swap"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "SwapArgs"; + }; + }, + ]; + }, + { + name: "crankThatTwap"; + accounts: [ + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "amm"; + type: { + kind: "struct"; + fields: [ + { + name: "bump"; + type: "u8"; + }, + { + name: "createdAtSlot"; + type: "u64"; + }, + { + name: "lpMint"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "baseMintDecimals"; + type: "u8"; + }, + { + name: "quoteMintDecimals"; + type: "u8"; + }, + { + name: "baseAmount"; + type: "u64"; + }, + { + name: "quoteAmount"; + type: "u64"; + }, + { + name: "oracle"; + type: { + defined: "TwapOracle"; + }; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "vaultAtaBase"; + type: "publicKey"; + }, + { + name: "vaultAtaQuote"; + type: "publicKey"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "user"; + type: "publicKey"; + }, + { + name: "amm"; + type: "publicKey"; + }, + { + name: "postBaseReserves"; + type: "u64"; + }, + { + name: "postQuoteReserves"; + type: "u64"; + }, + { + name: "oracleLastPrice"; + type: "u128"; + }, + { + name: "oracleLastObservation"; + type: "u128"; + }, + { + name: "oracleAggregator"; + type: "u128"; + }, + { + name: "seqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "AddLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "quoteAmount"; + docs: ["How much quote token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "maxBaseAmount"; + docs: ["The maximum base token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "minLpTokens"; + docs: ["The minimum LP token you will get back"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "CreateAmmArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + type: "u64"; + }, + ]; + }; + }, + { + name: "RemoveLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "lpTokensToBurn"; + type: "u64"; + }, + { + name: "minQuoteAmount"; + type: "u64"; + }, + { + name: "minBaseAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "SwapArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "outputAmountMin"; + type: "u64"; + }, + ]; + }; + }, + { + name: "TwapOracle"; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdatedSlot"; + type: "u64"; + }, + { + name: "lastPrice"; + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ]; + type: "u128"; + }, + { + name: "lastObservation"; + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ]; + type: "u128"; + }, + { + name: "aggregator"; + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ]; + type: "u128"; + }, + { + name: "maxObservationChangePerUpdate"; + docs: ["The most that an observation can change per update."]; + type: "u128"; + }, + { + name: "initialObservation"; + docs: ["What the initial `latest_observation` is set to."]; + type: "u128"; + }, + { + name: "startDelaySlots"; + docs: [ + "Number of slots after amm.created_at_slot to start recording TWAP", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "SwapType"; + type: { + kind: "enum"; + variants: [ + { + name: "Buy"; + }, + { + name: "Sell"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "SwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + ]; + }, + { + name: "AddLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "maxBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "minLpTokens"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "lpTokensMinted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "RemoveLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "lpTokensBurned"; + type: "u64"; + index: false; + }, + { + name: "minQuoteAmount"; + type: "u64"; + index: false; + }, + { + name: "minBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "CreateAmmEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "lpMint"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "vaultAtaBase"; + type: "publicKey"; + index: false; + }, + { + name: "vaultAtaQuote"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "CrankThatTwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AssertFailed"; + msg: "An assertion failed"; + }, + { + code: 6001; + name: "NoSlotsPassed"; + msg: "Can't get a TWAP before some observations have been stored"; + }, + { + code: 6002; + name: "NoReserves"; + msg: "Can't swap through a pool without token reserves on either side"; + }, + { + code: 6003; + name: "InputAmountOverflow"; + msg: "Input token amount is too large for a swap, causes overflow"; + }, + { + code: 6004; + name: "AddLiquidityCalculationError"; + msg: "Add liquidity calculation error"; + }, + { + code: 6005; + name: "DecimalScaleError"; + msg: "Error in decimal scale conversion"; + }, + { + code: 6006; + name: "SameTokenMints"; + msg: "You can't create an AMM pool where the token mints are the same"; + }, + { + code: 6007; + name: "SwapSlippageExceeded"; + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; + }, + { + code: 6008; + name: "InsufficientBalance"; + msg: "The user had insufficient balance to do this"; + }, + { + code: 6009; + name: "ZeroLiquidityRemove"; + msg: "Must remove a non-zero amount of liquidity"; + }, + { + code: 6010; + name: "ZeroLiquidityToAdd"; + msg: "Cannot add liquidity with 0 tokens on either side"; + }, + { + code: 6011; + name: "ZeroMinLpTokens"; + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; + }, + { + code: 6012; + name: "AddLiquiditySlippageExceeded"; + msg: "LP wouldn't have gotten back `lp_token_min`"; + }, + { + code: 6013; + name: "AddLiquidityMaxBaseExceeded"; + msg: "LP would have spent more than `max_base_amount`"; + }, + { + code: 6014; + name: "InsufficientQuoteAmount"; + msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; + }, + { + code: 6015; + name: "ZeroSwapAmount"; + msg: "Users must swap a non-zero amount"; + }, + { + code: 6016; + name: "ConstantProductInvariantFailed"; + msg: "K should always be increasing"; + }, + { + code: 6017; + name: "CastingOverflow"; + msg: "Casting has caused an overflow"; + }, + ]; +}; + +export const IDL: Amm = { + version: "0.5.0", + name: "amm", + instructions: [ + { + name: "createAmm", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "CreateAmmArgs", + }, + }, + ], + }, + { + name: "addLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddLiquidityArgs", + }, + }, + ], + }, + { + name: "removeLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "RemoveLiquidityArgs", + }, + }, + ], + }, + { + name: "swap", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "SwapArgs", + }, + }, + ], + }, + { + name: "crankThatTwap", + accounts: [ + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "amm", + type: { + kind: "struct", + fields: [ + { + name: "bump", + type: "u8", + }, + { + name: "createdAtSlot", + type: "u64", + }, + { + name: "lpMint", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "baseMintDecimals", + type: "u8", + }, + { + name: "quoteMintDecimals", + type: "u8", + }, + { + name: "baseAmount", + type: "u64", + }, + { + name: "quoteAmount", + type: "u64", + }, + { + name: "oracle", + type: { + defined: "TwapOracle", + }, + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "vaultAtaBase", + type: "publicKey", + }, + { + name: "vaultAtaQuote", + type: "publicKey", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "user", + type: "publicKey", + }, + { + name: "amm", + type: "publicKey", + }, + { + name: "postBaseReserves", + type: "u64", + }, + { + name: "postQuoteReserves", + type: "u64", + }, + { + name: "oracleLastPrice", + type: "u128", + }, + { + name: "oracleLastObservation", + type: "u128", + }, + { + name: "oracleAggregator", + type: "u128", + }, + { + name: "seqNum", + type: "u64", + }, + ], + }, + }, + { + name: "AddLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "quoteAmount", + docs: ["How much quote token you will deposit to the pool"], + type: "u64", + }, + { + name: "maxBaseAmount", + docs: ["The maximum base token you will deposit to the pool"], + type: "u64", + }, + { + name: "minLpTokens", + docs: ["The minimum LP token you will get back"], + type: "u64", + }, + ], + }, + }, + { + name: "CreateAmmArgs", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + type: "u64", + }, + ], + }, + }, + { + name: "RemoveLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "lpTokensToBurn", + type: "u64", + }, + { + name: "minQuoteAmount", + type: "u64", + }, + { + name: "minBaseAmount", + type: "u64", + }, + ], + }, + }, + { + name: "SwapArgs", + type: { + kind: "struct", + fields: [ + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "inputAmount", + type: "u64", + }, + { + name: "outputAmountMin", + type: "u64", + }, + ], + }, + }, + { + name: "TwapOracle", + type: { + kind: "struct", + fields: [ + { + name: "lastUpdatedSlot", + type: "u64", + }, + { + name: "lastPrice", + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ], + type: "u128", + }, + { + name: "lastObservation", + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ], + type: "u128", + }, + { + name: "aggregator", + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ], + type: "u128", + }, + { + name: "maxObservationChangePerUpdate", + docs: ["The most that an observation can change per update."], + type: "u128", + }, + { + name: "initialObservation", + docs: ["What the initial `latest_observation` is set to."], + type: "u128", + }, + { + name: "startDelaySlots", + docs: [ + "Number of slots after amm.created_at_slot to start recording TWAP", + ], + type: "u64", + }, + ], + }, + }, + { + name: "SwapType", + type: { + kind: "enum", + variants: [ + { + name: "Buy", + }, + { + name: "Sell", + }, + ], + }, + }, + ], + events: [ + { + name: "SwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + ], + }, + { + name: "AddLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "maxBaseAmount", + type: "u64", + index: false, + }, + { + name: "minLpTokens", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "lpTokensMinted", + type: "u64", + index: false, + }, + ], + }, + { + name: "RemoveLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "lpTokensBurned", + type: "u64", + index: false, + }, + { + name: "minQuoteAmount", + type: "u64", + index: false, + }, + { + name: "minBaseAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + ], + }, + { + name: "CreateAmmEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "lpMint", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "vaultAtaBase", + type: "publicKey", + index: false, + }, + { + name: "vaultAtaQuote", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "CrankThatTwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AssertFailed", + msg: "An assertion failed", + }, + { + code: 6001, + name: "NoSlotsPassed", + msg: "Can't get a TWAP before some observations have been stored", + }, + { + code: 6002, + name: "NoReserves", + msg: "Can't swap through a pool without token reserves on either side", + }, + { + code: 6003, + name: "InputAmountOverflow", + msg: "Input token amount is too large for a swap, causes overflow", + }, + { + code: 6004, + name: "AddLiquidityCalculationError", + msg: "Add liquidity calculation error", + }, + { + code: 6005, + name: "DecimalScaleError", + msg: "Error in decimal scale conversion", + }, + { + code: 6006, + name: "SameTokenMints", + msg: "You can't create an AMM pool where the token mints are the same", + }, + { + code: 6007, + name: "SwapSlippageExceeded", + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", + }, + { + code: 6008, + name: "InsufficientBalance", + msg: "The user had insufficient balance to do this", + }, + { + code: 6009, + name: "ZeroLiquidityRemove", + msg: "Must remove a non-zero amount of liquidity", + }, + { + code: 6010, + name: "ZeroLiquidityToAdd", + msg: "Cannot add liquidity with 0 tokens on either side", + }, + { + code: 6011, + name: "ZeroMinLpTokens", + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", + }, + { + code: 6012, + name: "AddLiquiditySlippageExceeded", + msg: "LP wouldn't have gotten back `lp_token_min`", + }, + { + code: 6013, + name: "AddLiquidityMaxBaseExceeded", + msg: "LP would have spent more than `max_base_amount`", + }, + { + code: 6014, + name: "InsufficientQuoteAmount", + msg: "`quote_amount` must be greater than 100000000 when initializing a pool", + }, + { + code: 6015, + name: "ZeroSwapAmount", + msg: "Users must swap a non-zero amount", + }, + { + code: 6016, + name: "ConstantProductInvariantFailed", + msg: "K should always be increasing", + }, + { + code: 6017, + name: "CastingOverflow", + msg: "Casting has caused an overflow", + }, + ], +}; diff --git a/sdk2/src/amm/v0.5/types/index.ts b/sdk2/src/amm/v0.5/types/index.ts new file mode 100644 index 000000000..5313bb6dd --- /dev/null +++ b/sdk2/src/amm/v0.5/types/index.ts @@ -0,0 +1,19 @@ +import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; +export { AmmProgram, AmmIDL }; + +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +export type Amm = IdlAccounts["amm"]; + +export type SwapEvent = IdlEvents["SwapEvent"]; +export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; +export type RemoveLiquidityEvent = + IdlEvents["RemoveLiquidityEvent"]; +export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; +export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; +export type AmmEvent = + | SwapEvent + | AddLiquidityEvent + | RemoveLiquidityEvent + | CreateAmmEvent + | CrankThatTwapEvent; diff --git a/sdk2/src/autocrat/index.ts b/sdk2/src/autocrat/index.ts new file mode 100644 index 000000000..6ef9c15e5 --- /dev/null +++ b/sdk2/src/autocrat/index.ts @@ -0,0 +1 @@ +export * from "./v0.5/index.js"; diff --git a/sdk2/src/autocrat/v0.5/AutocratClient.ts b/sdk2/src/autocrat/v0.5/AutocratClient.ts new file mode 100644 index 000000000..31d7bae4a --- /dev/null +++ b/sdk2/src/autocrat/v0.5/AutocratClient.ts @@ -0,0 +1,666 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AccountMeta, + AddressLookupTableAccount, + ComputeBudgetProgram, + Connection, + Keypair, + PublicKey, + Transaction, + TransactionInstruction, +} from "@solana/web3.js"; +import { InitializeDaoParams, UpdateDaoParams } from "./types/index.js"; + +import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; + +import BN from "bn.js"; +import { + AMM_PROGRAM_ID, + AUTOCRAT_V0_5_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + MAINNET_USDC, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + SQUADS_PROGRAM_ID, + USDC_DECIMALS, +} from "../../constants.js"; +import { InstructionUtils } from "../../utils.js"; +import { getAmmAddr, getAmmLpMintAddr } from "../../amm/v0.5/pda.js"; +import { + getConditionalTokenMintAddr, + getQuestionAddr, + getVaultAddr, +} from "../../conditional_vault/v0.4/pda.js"; +import { getDaoAddr, getDaoTreasuryAddr, getProposalAddr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { ConditionalVaultClient } from "../../conditional_vault/v0.4/ConditionalVaultClient.js"; +import { AmmClient } from "../../amm/v0.5/AmmClient.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + unpackMint, +} from "@solana/spl-token"; +import { sha256 } from "@noble/hashes/sha256"; +import { Dao, Proposal } from "./types/index.js"; + +import * as multisig from "@sqds/multisig"; + +export type CreateClientParams = { + provider: AnchorProvider; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export type ProposalVaults = { + baseVault: PublicKey; + quoteVault: PublicKey; +}; + +export class AutocratClient { + public readonly provider: AnchorProvider; + public readonly autocrat: Program; + public readonly vaultClient: ConditionalVaultClient; + public readonly ammClient: AmmClient; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + autocratProgramId: PublicKey, + conditionalVaultProgramId: PublicKey, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.autocrat = new Program( + AutocratIDL, + autocratProgramId, + provider, + ); + this.vaultClient = ConditionalVaultClient.createClient({ + provider, + conditionalVaultProgramId, + }); + this.ammClient = AmmClient.createClient({ provider, ammProgramId }); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateClientParams, + ): AutocratClient { + let { + provider, + autocratProgramId, + conditionalVaultProgramId, + ammProgramId, + } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AutocratClient( + provider, + autocratProgramId || AUTOCRAT_V0_5_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + ammProgramId || AMM_PROGRAM_ID, + luts, + ); + } + + getProgramId(): PublicKey { + return this.autocrat.programId; + } + + async getProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetch(proposal); + } + + async getDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetch(dao); + } + + async fetchProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetchNullable(proposal); + } + + async fetchDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetchNullable(dao); + } + + async deserializeProposal( + accountInfo: AccountInfo, + ): Promise { + return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); + } + + async deserializeDao(accountInfo: AccountInfo): Promise { + return this.autocrat.coder.accounts.decode("dao", accountInfo.data); + } + + getProposalPdas( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + dao: PublicKey, + ): { + question: PublicKey; + baseVault: PublicKey; + quoteVault: PublicKey; + passBaseMint: PublicKey; + passQuoteMint: PublicKey; + failBaseMint: PublicKey; + failQuoteMint: PublicKey; + passAmm: PublicKey; + failAmm: PublicKey; + passLp: PublicKey; + failLp: PublicKey; + } { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const [question] = getQuestionAddr( + vaultProgramId, + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const [baseVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + baseMint, + ); + const [quoteVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + quoteMint, + ); + + const [failBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 0, + ); + const [failQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 0, + ); + + const [passBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 1, + ); + const [passQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 1, + ); + + const [passAmm] = getAmmAddr( + this.ammClient.program.programId, + passBaseMint, + passQuoteMint, + ); + const [failAmm] = getAmmAddr( + this.ammClient.program.programId, + failBaseMint, + failQuoteMint, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + return { + question, + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + passAmm, + failAmm, + passLp, + failLp, + }; + } + + // async initializeDao( + // tokenMint: PublicKey, + // tokenPriceUiAmount: number, + // minBaseFutarchicLiquidity: number, + // minQuoteFutarchicLiquidity: number, + // usdcMint: PublicKey = MAINNET_USDC, + // daoKeypair: Keypair = Keypair.generate(), + // twapStartDelaySlots: BN + // ): Promise { + // let tokenDecimals = unpackMint( + // tokenMint, + // await this.provider.connection.getAccountInfo(tokenMint) + // ).decimals; + + // let scaledPrice = PriceMath.getAmmPrice( + // tokenPriceUiAmount, + // tokenDecimals, + // USDC_DECIMALS + // ); + + // // console.log( + // // PriceMath.getHumanPrice(scaledPrice, tokenDecimals, USDC_DECIMALS) + // // ); + + // await this.initializeDaoIx({ + // daoKeypair, + // baseMint: tokenMint, + // params: { + // twapStartDelaySlots, + // twapInitialObservation: scaledPrice, + // twapMaxObservationChangePerUpdate: scaledPrice.divn(50), + // minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( + // new BN(10).pow(new BN(USDC_DECIMALS)) + // ), + // minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( + // new BN(10).pow(new BN(tokenDecimals)) + // ), + // passThresholdBps: null, + // slotsPerProposal: null, + // }, + // quoteMint: usdcMint, + // }) + // .postInstructions([ + // ComputeBudgetProgram.setComputeUnitLimit({ + // units: MaxCUs.initializeDao, + // }), + // ComputeBudgetProgram.setComputeUnitPrice({ + // microLamports: DEFAULT_CU_PRICE, + // }), + // ]) + // .rpc({ maxRetries: 5 }); + + // return daoKeypair.publicKey; + // } + + initializeDaoIx({ + baseMint, + params, + quoteMint = MAINNET_USDC, + squadsProgramConfigTreasury = SQUADS_PROGRAM_CONFIG_TREASURY, + }: { + baseMint: PublicKey; + params: InitializeDaoParams; + quoteMint?: PublicKey; + squadsProgramConfigTreasury?: PublicKey; + }) { + const [dao] = getDaoAddr({ + nonce: params.nonce, + daoCreator: this.provider.publicKey, + }); + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + + const spendingLimit = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + })[0]; + + return this.autocrat.methods.initializeDao(params).accounts({ + dao, + baseMint, + quoteMint, + squadsMultisig: multisigPda, + squadsMultisigVault, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury, + squadsProgram: SQUADS_PROGRAM_ID, + spendingLimit, + }); + } + + async initializeProposal( + dao: PublicKey, + descriptionUrl: string, + squadsProposal: PublicKey, + baseTokensToLP: BN, + quoteTokensToLP: BN, + ): Promise { + const storedDao = await this.getDao(dao); + + let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + + await this.vaultClient.initializeQuestion( + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + + const { + baseVault, + quoteVault, + passAmm, + failAmm, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + question, + } = this.getProposalPdas( + proposal, + storedDao.baseMint, + storedDao.quoteMint, + dao, + ); + + // it's important that these happen in a single atomic transaction + await this.vaultClient + .initializeVaultIx(question, storedDao.baseMint, 2) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.initializeVaultIx(question, storedDao.quoteMint, 2), + this.ammClient.initializeAmmIx( + passBaseMint, + passQuoteMint, + storedDao.twapStartDelaySlots, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + this.ammClient.initializeAmmIx( + failBaseMint, + failQuoteMint, + storedDao.twapStartDelaySlots, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + ), + ) + .rpc(); + + console.log(baseTokensToLP.toString()); + await this.vaultClient + .splitTokensIx(question, baseVault, storedDao.baseMint, baseTokensToLP, 2) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.splitTokensIx( + question, + quoteVault, + storedDao.quoteMint, + quoteTokensToLP, + 2, + ), + ), + ) + .rpc(); + + await this.ammClient + .addLiquidityIx( + passAmm, + passBaseMint, + passQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ) + .postInstructions( + await InstructionUtils.getInstructions( + this.ammClient.addLiquidityIx( + failAmm, + failBaseMint, + failQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ), + ), + ) + .rpc(); + + // this is how many original tokens are created + const lpTokens = quoteTokensToLP; + + await this.initializeProposalIx( + descriptionUrl, + squadsProposal, + dao, + storedDao.baseMint, + storedDao.quoteMint, + lpTokens, + lpTokens, + question, + ).rpc(); + + return proposal; + } + + initializeProposalIx( + descriptionUrl: string, + squadsProposal: PublicKey, + dao: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + passLpTokensToLock: BN, + failLpTokensToLock: BN, + question: PublicKey, + proposer: PublicKey = this.provider.publicKey, + ) { + let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( + proposal, + baseMint, + quoteMint, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + const passLpVaultAccount = getAssociatedTokenAddressSync( + passLp, + proposal, + true, + ); + const failLpVaultAccount = getAssociatedTokenAddressSync( + failLp, + proposal, + true, + ); + + return this.autocrat.methods + .initializeProposal({ + descriptionUrl, + passLpTokensToLock, + failLpTokensToLock, + }) + .accounts({ + question, + proposal, + squadsProposal, + dao, + baseVault, + quoteVault, + passAmm, + failAmm, + passLpMint: passLp, + failLpMint: failLp, + passLpUserAccount: getAssociatedTokenAddressSync( + passLp, + proposer, + true, + ), + failLpUserAccount: getAssociatedTokenAddressSync( + failLp, + proposer, + true, + ), + passLpVaultAccount, + failLpVaultAccount, + proposer, + }); + } + + async finalizeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + let storedDao = await this.getDao(storedProposal.dao); + + return this.finalizeProposalIx( + proposal, + storedProposal.squadsProposal, + storedProposal.dao, + storedDao.baseMint, + storedDao.quoteMint, + storedProposal.proposer, + ).rpc(); + } + + finalizeProposalIx( + proposal: PublicKey, + squadsProposal: PublicKey, + dao: PublicKey, + daoToken: PublicKey, + usdc: PublicKey, + proposer: PublicKey, + ) { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const { question, passAmm, failAmm } = this.getProposalPdas( + proposal, + daoToken, + usdc, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); + + return this.autocrat.methods.finalizeProposal().accounts({ + proposal, + passAmm, + failAmm, + dao, + squadsProposal, + squadsMultisig: multisigPda, + squadsMultisigProgram: SQUADS_PROGRAM_ID, + question, + // baseVault, + // quoteVault, + passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer, true), + failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer, true), + passLpVaultAccount: getAssociatedTokenAddressSync(passLp, proposal, true), + failLpVaultAccount: getAssociatedTokenAddressSync(failLp, proposal, true), + vaultProgram: this.vaultClient.vaultProgram.programId, + vaultEventAuthority, + }); + } + + // async executeProposal(proposal: PublicKey) { + // let storedProposal = await this.getProposal(proposal); + + // return this.executeProposalIx( + // proposal, + // storedProposal.dao, + // storedProposal.instruction + // ).rpc(); + // } + + // executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { + // const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + // return this.autocrat.methods + // .executeProposal() + // .accounts({ + // proposal, + // dao, + // // daoTreasury, + // }) + // .remainingAccounts( + // instruction.accounts + // .concat({ + // pubkey: instruction.programId, + // isWritable: false, + // isSigner: false, + // }) + // .map((meta: AccountMeta) => + // meta.pubkey.equals(daoTreasury) + // ? { ...meta, isSigner: false } + // : meta + // ) + // ); + // } + + updateDaoIx({ dao, params }: { dao: PublicKey; params: UpdateDaoParams }) { + const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; + const squadsMultisigVault = multisig.getVaultPda({ + multisigPda, + index: 0, + })[0]; + + return this.autocrat.methods.updateDao(params).accounts({ + dao, + squadsMultisigVault, + }); + } + + // cranks the TWAPs of multiple proposals' markets. there's a limit on the + // number of proposals you can pass in, which I can't determine rn because + // there aren't enough proposals on devnet + async crankProposalMarkets( + proposals: PublicKey[], + priorityFeeMicroLamports: number, + ) { + const amms: PublicKey[] = []; + + for (const proposal of proposals) { + const storedProposal = await this.getProposal(proposal); + amms.push(storedProposal.passAmm); + amms.push(storedProposal.failAmm); + } + + while (true) { + let ixs: TransactionInstruction[] = []; + + for (const amm of amms) { + ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); + } + + let tx = new Transaction(); + tx.add( + ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), + ); + tx.add( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: priorityFeeMicroLamports, + }), + ); + tx.add(...ixs); + try { + await this.provider.sendAndConfirm(tx); + } catch (err) { + console.log("err", err); + } + + await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds + } + } +} diff --git a/sdk2/src/autocrat/v0.5/index.ts b/sdk2/src/autocrat/v0.5/index.ts new file mode 100644 index 000000000..6e8fd3617 --- /dev/null +++ b/sdk2/src/autocrat/v0.5/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./AutocratClient.js"; diff --git a/sdk2/src/autocrat/v0.5/pda.ts b/sdk2/src/autocrat/v0.5/pda.ts new file mode 100644 index 000000000..3ad8c896f --- /dev/null +++ b/sdk2/src/autocrat/v0.5/pda.ts @@ -0,0 +1,40 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import BN from "bn.js"; +import { AUTOCRAT_V0_5_PROGRAM_ID } from "../../constants.js"; + +export const getDaoAddr = ({ + nonce, + daoCreator, + programId = AUTOCRAT_V0_5_PROGRAM_ID, +}: { + nonce: BN; + daoCreator: PublicKey; + programId?: PublicKey; +}): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("dao"), + daoCreator.toBuffer(), + nonce.toArrayLike(Buffer, "le", 8), + ], + programId, + ); +}; + +export const getDaoTreasuryAddr = ( + programId: PublicKey = AUTOCRAT_V0_5_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); +}; + +export const getProposalAddr = ( + programId: PublicKey = AUTOCRAT_V0_5_PROGRAM_ID, + squadsProposal: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("proposal"), squadsProposal.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/autocrat/v0.5/types/autocrat.ts b/sdk2/src/autocrat/v0.5/types/autocrat.ts new file mode 100644 index 000000000..48334f703 --- /dev/null +++ b/sdk2/src/autocrat/v0.5/types/autocrat.ts @@ -0,0 +1,2121 @@ +export type Autocrat = { + version: "0.5.0"; + name: "autocrat"; + instructions: [ + { + name: "initializeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoCreator"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeDaoParams"; + }; + }, + ]; + }, + { + name: "initializeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeProposalParams"; + }; + }, + ]; + }, + { + name: "finalizeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "daoParams"; + type: { + defined: "UpdateDaoParams"; + }; + }, + ]; + }, + ]; + accounts: [ + { + name: "dao"; + type: { + kind: "struct"; + fields: [ + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "slotsPerProposal"; + type: "u64"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + docs: [ + "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", + ]; + type: "u64"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + ]; + }; + }, + { + name: "proposal"; + type: { + kind: "struct"; + fields: [ + { + name: "number"; + type: "u32"; + }, + { + name: "proposer"; + type: "publicKey"; + }, + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "slotEnqueued"; + type: "u64"; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + }, + { + name: "passAmm"; + type: "publicKey"; + }, + { + name: "failAmm"; + type: "publicKey"; + }, + { + name: "baseVault"; + type: "publicKey"; + }, + { + name: "quoteVault"; + type: "publicKey"; + }, + { + name: "dao"; + type: "publicKey"; + }, + { + name: "passLpTokensLocked"; + type: "u64"; + }, + { + name: "failLpTokensLocked"; + type: "u64"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "question"; + type: "publicKey"; + }, + { + name: "durationInSlots"; + type: "u64"; + }, + { + name: "squadsProposal"; + type: "publicKey"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + ]; + }; + }, + { + name: "InitializeDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + type: "u64"; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "slotsPerProposal"; + type: "u64"; + }, + { + name: "nonce"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + ]; + }; + }, + { + name: "InitializeProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "passLpTokensToLock"; + type: "u64"; + }, + { + name: "failLpTokensToLock"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "slotsPerProposal"; + type: { + option: "u64"; + }; + }, + { + name: "twapInitialObservation"; + type: { + option: "u128"; + }; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: { + option: "u128"; + }; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "minBaseFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "InitialSpendingLimit"; + type: { + kind: "struct"; + fields: [ + { + name: "amountPerMonth"; + type: "u64"; + }, + { + name: "members"; + type: { + vec: "publicKey"; + }; + }, + ]; + }; + }, + { + name: "ProposalState"; + type: { + kind: "enum"; + variants: [ + { + name: "Pending"; + }, + { + name: "Passed"; + }, + { + name: "Failed"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "InitializeDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "slotsPerProposal"; + type: "u64"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "UpdateDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "slotsPerProposal"; + type: "u64"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "InitializeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "quoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseVault"; + type: "publicKey"; + index: false; + }, + { + name: "passAmm"; + type: "publicKey"; + index: false; + }, + { + name: "failAmm"; + type: "publicKey"; + index: false; + }, + { + name: "passLpMint"; + type: "publicKey"; + index: false; + }, + { + name: "failLpMint"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "number"; + type: "u32"; + index: false; + }, + { + name: "passLpTokensLocked"; + type: "u64"; + index: false; + }, + { + name: "failLpTokensLocked"; + type: "u64"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "durationInSlots"; + type: "u64"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "FinalizeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "failMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "threshold"; + type: "u128"; + index: false; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "ExecuteProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AmmTooOld"; + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; + }, + { + code: 6001; + name: "InvalidInitialObservation"; + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; + }, + { + code: 6002; + name: "InvalidMaxObservationChange"; + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; + }, + { + code: 6003; + name: "InvalidStartDelaySlots"; + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; + }, + { + code: 6004; + name: "InvalidSettlementAuthority"; + msg: "One of the vaults has an invalid `settlement_authority`"; + }, + { + code: 6005; + name: "ProposalTooYoung"; + msg: "Proposal is too young to be executed or rejected"; + }, + { + code: 6006; + name: "MarketsTooYoung"; + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; + }, + { + code: 6007; + name: "ProposalAlreadyFinalized"; + msg: "This proposal has already been finalized"; + }, + { + code: 6008; + name: "InvalidVaultNonce"; + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; + }, + { + code: 6009; + name: "ProposalNotPassed"; + msg: "This proposal can't be executed because it isn't in the passed state"; + }, + { + code: 6010; + name: "InsufficientLpTokenBalance"; + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; + }, + { + code: 6011; + name: "InsufficientLpTokenLock"; + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; + }, + { + code: 6012; + name: "ProposalDurationTooShort"; + msg: "Proposal duration must be longer than TWAP start delay"; + }, + { + code: 6013; + name: "QuestionMustBeBinary"; + msg: "Question must have exactly 2 outcomes for binary futarchy"; + }, + { + code: 6014; + name: "InvalidSquadsProposalStatus"; + msg: "Squads proposal must be in Draft status"; + }, + ]; +}; + +export const IDL: Autocrat = { + version: "0.5.0", + name: "autocrat", + instructions: [ + { + name: "initializeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoCreator", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeDaoParams", + }, + }, + ], + }, + { + name: "initializeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeProposalParams", + }, + }, + ], + }, + { + name: "finalizeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "daoParams", + type: { + defined: "UpdateDaoParams", + }, + }, + ], + }, + ], + accounts: [ + { + name: "dao", + type: { + kind: "struct", + fields: [ + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "slotsPerProposal", + type: "u64", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + docs: [ + "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", + ], + type: "u64", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + ], + }, + }, + { + name: "proposal", + type: { + kind: "struct", + fields: [ + { + name: "number", + type: "u32", + }, + { + name: "proposer", + type: "publicKey", + }, + { + name: "descriptionUrl", + type: "string", + }, + { + name: "slotEnqueued", + type: "u64", + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + }, + { + name: "passAmm", + type: "publicKey", + }, + { + name: "failAmm", + type: "publicKey", + }, + { + name: "baseVault", + type: "publicKey", + }, + { + name: "quoteVault", + type: "publicKey", + }, + { + name: "dao", + type: "publicKey", + }, + { + name: "passLpTokensLocked", + type: "u64", + }, + { + name: "failLpTokensLocked", + type: "u64", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "question", + type: "publicKey", + }, + { + name: "durationInSlots", + type: "u64", + }, + { + name: "squadsProposal", + type: "publicKey", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + ], + }, + }, + { + name: "InitializeDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + type: "u64", + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "slotsPerProposal", + type: "u64", + }, + { + name: "nonce", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + ], + }, + }, + { + name: "InitializeProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "descriptionUrl", + type: "string", + }, + { + name: "passLpTokensToLock", + type: "u64", + }, + { + name: "failLpTokensToLock", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "slotsPerProposal", + type: { + option: "u64", + }, + }, + { + name: "twapInitialObservation", + type: { + option: "u128", + }, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: { + option: "u128", + }, + }, + { + name: "minQuoteFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "minBaseFutarchicLiquidity", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "InitialSpendingLimit", + type: { + kind: "struct", + fields: [ + { + name: "amountPerMonth", + type: "u64", + }, + { + name: "members", + type: { + vec: "publicKey", + }, + }, + ], + }, + }, + { + name: "ProposalState", + type: { + kind: "enum", + variants: [ + { + name: "Pending", + }, + { + name: "Passed", + }, + { + name: "Failed", + }, + ], + }, + }, + ], + events: [ + { + name: "InitializeDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "slotsPerProposal", + type: "u64", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "UpdateDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "slotsPerProposal", + type: "u64", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + ], + }, + { + name: "InitializeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "quoteVault", + type: "publicKey", + index: false, + }, + { + name: "baseVault", + type: "publicKey", + index: false, + }, + { + name: "passAmm", + type: "publicKey", + index: false, + }, + { + name: "failAmm", + type: "publicKey", + index: false, + }, + { + name: "passLpMint", + type: "publicKey", + index: false, + }, + { + name: "failLpMint", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "number", + type: "u32", + index: false, + }, + { + name: "passLpTokensLocked", + type: "u64", + index: false, + }, + { + name: "failLpTokensLocked", + type: "u64", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "durationInSlots", + type: "u64", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "FinalizeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passMarketTwap", + type: "u128", + index: false, + }, + { + name: "failMarketTwap", + type: "u128", + index: false, + }, + { + name: "threshold", + type: "u128", + index: false, + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "ExecuteProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AmmTooOld", + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", + }, + { + code: 6001, + name: "InvalidInitialObservation", + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", + }, + { + code: 6002, + name: "InvalidMaxObservationChange", + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", + }, + { + code: 6003, + name: "InvalidStartDelaySlots", + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", + }, + { + code: 6004, + name: "InvalidSettlementAuthority", + msg: "One of the vaults has an invalid `settlement_authority`", + }, + { + code: 6005, + name: "ProposalTooYoung", + msg: "Proposal is too young to be executed or rejected", + }, + { + code: 6006, + name: "MarketsTooYoung", + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", + }, + { + code: 6007, + name: "ProposalAlreadyFinalized", + msg: "This proposal has already been finalized", + }, + { + code: 6008, + name: "InvalidVaultNonce", + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", + }, + { + code: 6009, + name: "ProposalNotPassed", + msg: "This proposal can't be executed because it isn't in the passed state", + }, + { + code: 6010, + name: "InsufficientLpTokenBalance", + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", + }, + { + code: 6011, + name: "InsufficientLpTokenLock", + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", + }, + { + code: 6012, + name: "ProposalDurationTooShort", + msg: "Proposal duration must be longer than TWAP start delay", + }, + { + code: 6013, + name: "QuestionMustBeBinary", + msg: "Question must have exactly 2 outcomes for binary futarchy", + }, + { + code: 6014, + name: "InvalidSquadsProposalStatus", + msg: "Squads proposal must be in Draft status", + }, + ], +}; diff --git a/sdk2/src/autocrat/v0.5/types/index.ts b/sdk2/src/autocrat/v0.5/types/index.ts new file mode 100644 index 000000000..68306d748 --- /dev/null +++ b/sdk2/src/autocrat/v0.5/types/index.ts @@ -0,0 +1,27 @@ +import { Autocrat as AutocratProgram, IDL as AutocratIDL } from "./autocrat.js"; +export { AutocratProgram, AutocratIDL }; + +import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; + +export type InitializeDaoParams = + IdlTypes["InitializeDaoParams"]; +export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; + +export type Dao = IdlAccounts["dao"]; +export type Proposal = IdlAccounts["proposal"]; + +export type InitializeDaoEvent = + IdlEvents["InitializeDaoEvent"]; +export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; +export type InitializeProposalEvent = + IdlEvents["InitializeProposalEvent"]; +export type FinalizeProposalEvent = + IdlEvents["FinalizeProposalEvent"]; +export type ExecuteProposalEvent = + IdlEvents["ExecuteProposalEvent"]; +export type AutocratEvent = + | InitializeDaoEvent + | UpdateDaoEvent + | InitializeProposalEvent + | FinalizeProposalEvent + | ExecuteProposalEvent; diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index d8e1a2235..ae1a653d5 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -2,6 +2,13 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; import { BN } from "bn.js"; +export const AUTOCRAT_V0_5_PROGRAM_ID = new PublicKey( + "auToUr3CQza3D4qreT6Std2MTomfzvrEeCC5qh7ivW5", +); +export const LAUNCHPAD_V0_5_PROGRAM_ID = new PublicKey( + "mooNhciQJi1LqHDmse2JPic2NqG2PXCanbE3ZYzP3qA", +); + export const FUTARCHY_V0_6_PROGRAM_ID = new PublicKey( "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq", ); diff --git a/sdk2/src/launchpad/v0.5/LaunchpadClient.ts b/sdk2/src/launchpad/v0.5/LaunchpadClient.ts new file mode 100644 index 000000000..f21a25ef9 --- /dev/null +++ b/sdk2/src/launchpad/v0.5/LaunchpadClient.ts @@ -0,0 +1,449 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + PublicKey, + Keypair, + AccountInfo, + ComputeBudgetProgram, +} from "@solana/web3.js"; +import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; +import { + LAUNCHPAD_V0_5_PROGRAM_ID, + RAYDIUM_AUTHORITY, + LOW_FEE_RAYDIUM_CONFIG, + RAYDIUM_CP_SWAP_PROGRAM_ID, + RAYDIUM_CREATE_POOL_FEE_RECEIVE, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_AUTHORITY, + DEVNET_LOW_FEE_RAYDIUM_CONFIG, + DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, + DEVNET_USDC, + SQUADS_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, +} from "../../constants.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { FundingRecord, Launch } from "./types/index.js"; +import { + getFundingRecordAddr, + getLaunchAddr, + getLaunchSignerAddr, + getLiquidityPoolAddr, + getRaydiumCpmmLpMintAddr, +} from "./pda.js"; +import { getDaoAddr, getDaoTreasuryAddr } from "../../autocrat/v0.5/pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; +import { AutocratClient } from "../../autocrat/v0.5/AutocratClient.js"; +import * as anchor from "@coral-xyz/anchor"; +import * as multisig from "@sqds/multisig"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + public autocratClient: AutocratClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + this.launchpad = new Program( + LaunchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_5_PROGRAM_ID, + this.provider, + ); + this.autocratClient = AutocratClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + ammProgramId: params.ammProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord( + fundingRecord: PublicKey, + ): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable( + fundingRecord, + ); + } + + async deserializeFundingRecord( + accountInfo: AccountInfo, + ): Promise { + return this.launchpad.coder.accounts.decode( + "fundingRecord", + accountInfo.data, + ); + } + + initializeLaunchIx( + tokenName: string, + tokenSymbol: string, + tokenUri: string, + minimumRaiseAmount: BN, + secondsForLaunch: number, + baseMint: PublicKey, + quoteMint: PublicKey, + monthlySpendingLimitAmount: BN, + monthlySpendingLimitMembers: PublicKey[], + launchAuthority: PublicKey = this.provider.publicKey, + isDevnet: boolean = false, + payer: PublicKey = this.provider.publicKey, + ) { + const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const quoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + + const baseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + const [tokenMetadata] = getMetadataAddr(baseMint); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, + tokenSymbol, + tokenUri, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + }) + .accounts({ + launch, + launchSigner, + quoteVault, + baseVault, + launchAuthority, + quoteMint, + baseMint, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, launchSigner, true), + launchSigner, + quoteMint, + ), + ]); + // .signers([tokenMintKp]); + } + + startLaunchIx( + launch: PublicKey, + launchAuthority: PublicKey = this.provider.publicKey, + ) { + return this.launchpad.methods.startLaunch().accounts({ + launch, + launchAuthority, + }); + } + + fundIx( + launch: PublicKey, + amount: BN, + funder: PublicKey = this.provider.publicKey, + quoteMint: PublicKey, + isDevnet: boolean = false, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods.fund(amount).accounts({ + launch, + launchQuoteVault, + fundingRecord, + funder, + funderQuoteAccount, + launchSigner, + }); + } + + completeLaunchIx( + launch: PublicKey, + quoteMint: PublicKey, + baseMint: PublicKey, + isDevnet: boolean = false, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + const _SQUADS_PROGRAM_CONFIG_TREASURY = isDevnet + ? DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY + : SQUADS_PROGRAM_CONFIG_TREASURY; + + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const launchBaseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + + // const daoKp = Keypair.generate(); + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [poolState] = getLiquidityPoolAddr(this.launchpad.programId, dao); + + const cpSwapProgramId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + + const [lpMint] = getRaydiumCpmmLpMintAddr(poolState, isDevnet); + + const lpVault = getAssociatedTokenAddressSync(lpMint, launchSigner, true); + + const [poolTokenVault] = PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("pool_vault"), + poolState.toBuffer(), + baseMint.toBuffer(), + ], + cpSwapProgramId, + ); + + const [poolUsdcVault] = PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("pool_vault"), + poolState.toBuffer(), + USDC.toBuffer(), + ], + cpSwapProgramId, + ); + + const [observationState] = PublicKey.findProgramAddressSync( + [anchor.utils.bytes.utf8.encode("observation"), poolState.toBuffer()], + cpSwapProgramId, + ); + + const [autocratEventAuthority] = getEventAuthorityAddr( + this.autocratClient.getProgramId(), + ); + + const [tokenMetadata] = getMetadataAddr(baseMint); + + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ + multisigPda, + index: 0, + }); + + const [spendingLimit] = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + }); + + const treasuryQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + multisigVault, + true, + ); + + return this.launchpad.methods.completeLaunch().accounts({ + launch, + launchSigner, + launchQuoteVault, + launchBaseVault, + dao, + treasuryQuoteAccount, + treasuryLpAccount: getAssociatedTokenAddressSync( + lpMint, + multisigVault, + true, + ), + quoteMint, + baseMint, + tokenMetadata, + lpMint, + lpVault, + poolTokenVault, + poolUsdcVault, + poolState, + observationState, + staticAccounts: { + cpSwapProgram: cpSwapProgramId, + authority: isDevnet ? DEVNET_RAYDIUM_AUTHORITY : RAYDIUM_AUTHORITY, + ammConfig: isDevnet + ? DEVNET_LOW_FEE_RAYDIUM_CONFIG + : LOW_FEE_RAYDIUM_CONFIG, + createPoolFee: isDevnet + ? DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE + : RAYDIUM_CREATE_POOL_FEE_RECEIVE, + autocratProgram: this.autocratClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + autocratEventAuthority, + squadsProgram: SQUADS_PROGRAM_ID, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury: _SQUADS_PROGRAM_CONFIG_TREASURY, + }, + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + spendingLimit, + }); + // .preInstructions([ + // createAssociatedTokenAccountIdempotentInstruction( + // this.provider.publicKey, + // treasuryQuoteAccount, + // daoTreasury, + // USDC + // ), + // ]); + } + + refundIx( + launch: PublicKey, + funder: PublicKey = this.provider.publicKey, + quoteMint: PublicKey, + isDevnet: boolean = false, + ) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + + return this.launchpad.methods.refund().accounts({ + launch, + launchSigner, + launchQuoteVault, + funder, + funderQuoteAccount, + fundingRecord, + }); + } + + claimIx( + launch: PublicKey, + baseMint: PublicKey, + funder: PublicKey = this.provider.publicKey, + ) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods + .claim() + .accounts({ + launch, + fundingRecord, + launchSigner, + funder, + funderTokenAccount: getAssociatedTokenAddressSync( + baseMint, + funder, + true, + ), + baseMint, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, funder, true), + funder, + baseMint, + ), + ]); + } +} diff --git a/sdk2/src/launchpad/v0.5/index.ts b/sdk2/src/launchpad/v0.5/index.ts new file mode 100644 index 000000000..b5b9717d0 --- /dev/null +++ b/sdk2/src/launchpad/v0.5/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./LaunchpadClient.js"; diff --git a/sdk2/src/launchpad/v0.5/pda.ts b/sdk2/src/launchpad/v0.5/pda.ts new file mode 100644 index 000000000..589e277c3 --- /dev/null +++ b/sdk2/src/launchpad/v0.5/pda.ts @@ -0,0 +1,61 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { + LAUNCHPAD_V0_5_PROGRAM_ID, + RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +} from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_5_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_5_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_5_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; + +export const getLiquidityPoolAddr = ( + programId: PublicKey = LAUNCHPAD_V0_5_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_state"), dao.toBuffer()], + programId, + ); +}; + +export const getRaydiumCpmmLpMintAddr = ( + poolState: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_lp_mint"), poolState.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/launchpad/v0.5/types/index.ts b/sdk2/src/launchpad/v0.5/types/index.ts new file mode 100644 index 000000000..8ee0e3354 --- /dev/null +++ b/sdk2/src/launchpad/v0.5/types/index.ts @@ -0,0 +1,29 @@ +import { + Launchpad as LaunchpadProgram, + IDL as LaunchpadIDL, +} from "./launchpad.js"; +export { LaunchpadProgram, LaunchpadIDL }; + +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +export type Launch = IdlAccounts["launch"]; +export type FundingRecord = IdlAccounts["fundingRecord"]; + +export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; +export type LaunchCompletedEvent = + IdlEvents["LaunchCompletedEvent"]; +export type LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type LaunchpadEvent = + | LaunchClaimEvent + | LaunchCompletedEvent + | LaunchFundedEvent + | LaunchInitializedEvent + | LaunchRefundedEvent + | LaunchStartedEvent; diff --git a/sdk2/src/launchpad/v0.5/types/launchpad.ts b/sdk2/src/launchpad/v0.5/types/launchpad.ts new file mode 100644 index 000000000..0af6abd3c --- /dev/null +++ b/sdk2/src/launchpad/v0.5/types/launchpad.ts @@ -0,0 +1,2123 @@ +export type Launchpad = { + version: "0.5.0"; + name: "launchpad"; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "completeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "poolState"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "lpVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolTokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolUsdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "observationState"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "authority"; + isMut: false; + isSigner: false; + }, + { + name: "ammConfig"; + isMut: true; + isSigner: false; + docs: [ + "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", + ]; + }, + { + name: "createPoolFee"; + isMut: true; + isSigner: false; + docs: ["create pool fee account"]; + }, + { + name: "cpSwapProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this funding record. Useful for sorting events.", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: "i64"; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "fundingRecordSeqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidTokenKey"; + msg: "Token mint key must end in 'meta'"; + }, + { + code: 6005; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6006; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6007; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6008; + name: "LaunchNotRefunding"; + msg: "Launch needs to be in refunding state to get a refund"; + }, + { + code: 6009; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6010; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount"; + }, + ]; +}; + +export const IDL: Launchpad = { + version: "0.5.0", + name: "launchpad", + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "completeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "treasuryLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "poolState", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "lpVault", + isMut: true, + isSigner: false, + }, + { + name: "poolTokenVault", + isMut: true, + isSigner: false, + }, + { + name: "poolUsdcVault", + isMut: true, + isSigner: false, + }, + { + name: "observationState", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "authority", + isMut: false, + isSigner: false, + }, + { + name: "ammConfig", + isMut: true, + isSigner: false, + docs: [ + "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", + ], + }, + { + name: "createPoolFee", + isMut: true, + isSigner: false, + docs: ["create pool fee account"], + }, + { + name: "cpSwapProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "seqNum", + docs: [ + "The sequence number of this funding record. Useful for sorting events.", + ], + type: "u64", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: "i64", + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "fundingRecordSeqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidTokenKey", + msg: "Token mint key must end in 'meta'", + }, + { + code: 6005, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6006, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6007, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6008, + name: "LaunchNotRefunding", + msg: "Launch needs to be in refunding state to get a refund", + }, + { + code: 6009, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6010, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount", + }, + ], +}; diff --git a/sdk2/src/shared_liquidity_manager/index.ts b/sdk2/src/shared_liquidity_manager/index.ts new file mode 100644 index 000000000..6ef9c15e5 --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/index.ts @@ -0,0 +1 @@ +export * from "./v0.5/index.js"; diff --git a/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts b/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts new file mode 100644 index 000000000..168e1599c --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts @@ -0,0 +1,865 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AddressLookupTableAccount, + ComputeBudgetProgram, + Keypair, + PublicKey, + SystemProgram, +} from "@solana/web3.js"; +import { + TOKEN_PROGRAM_ID, + TOKEN_2022_PROGRAM_ID, + createAssociatedTokenAccountIdempotentInstruction, +} from "@solana/spl-token"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import * as anchor from "@coral-xyz/anchor"; + +import { + SharedLiquidityManager as SharedLiquidityManagerIDLType, + IDL as SharedLiquidityManagerIDL, +} from "./types/shared_liquidity_manager.js"; +// import { +// SharedLiquidityPool, +// SharedLiquidityPoolPosition, +// } from "./types/index.js"; + +import BN from "bn.js"; +import { + SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + RAYDIUM_CP_SWAP_PROGRAM_ID, + RAYDIUM_AUTHORITY, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + AMM_PROGRAM_ID, + AUTOCRAT_V0_5_PROGRAM_ID, + LOW_FEE_RAYDIUM_CONFIG, + RAYDIUM_CREATE_POOL_FEE_RECEIVE, +} from "../../constants.js"; +import { + getSharedLiquidityPoolAddr, + getRaydiumCpmmPoolVaultAddr, + getRaydiumCpmmLpMintAddr, + getRaydiumCpmmObservationStateAddr, + getSharedLiquidityPoolSignerAddr, + getSpotPoolAddr, + getDraftProposalAddr, + getStakeRecordAddr, + getSlPoolPositionAddr, +} from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { + getDaoTreasuryAddr, + getProposalAddr, +} from "../../autocrat/v0.5/pda.js"; +import { AutocratClient } from "../../autocrat/v0.5/AutocratClient.js"; + +export type CreateSharedLiquidityManagerClientParams = { + provider: AnchorProvider; + sharedLiquidityManagerProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export const RAYDIUM_INIT_POOL_STATIC_ACCOUNTS = { + raydiumAuthority: RAYDIUM_AUTHORITY, + ammConfig: LOW_FEE_RAYDIUM_CONFIG, + cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + createPoolFee: RAYDIUM_CREATE_POOL_FEE_RECEIVE, +}; + +export class SharedLiquidityManagerClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public autocratClient: AutocratClient; + + constructor(params: CreateSharedLiquidityManagerClientParams) { + this.provider = params.provider; + this.program = new Program( + SharedLiquidityManagerIDL, + params.sharedLiquidityManagerProgramId || + SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + this.provider, + ); + this.autocratClient = AutocratClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + ammProgramId: params.ammProgramId, + }); + } + + public static createClient( + params: CreateSharedLiquidityManagerClientParams, + ): SharedLiquidityManagerClient { + return new SharedLiquidityManagerClient(params); + } + + getProgramId(): PublicKey { + return this.program.programId; + } + + // async getSlPool(slPool: PublicKey): Promise { + // return await this.program.account.sharedLiquidityPool.fetch(slPool); + // } + + // async getSlPoolPosition( + // position: PublicKey + // ): Promise { + // return await this.program.account.liquidityPosition.fetch(position); + // } + + // initializeSharedLiquidityPoolIx( + // dao: PublicKey, + // baseMint: PublicKey, + // quoteMint: PublicKey, + // baseAmount: BN, + // quoteAmount: BN, + // proposalStakeRateThresholdBps: number = 100, + // creator: PublicKey = this.provider.wallet.publicKey + // ) { + // let slPool = getSharedLiquidityPoolAddr( + // this.program.programId, + // dao, + // creator, + // proposalStakeRateThresholdBps + // )[0]; + + // const [creatorSlPoolPosition] = getSlPoolPositionAddr( + // this.program.programId, + // slPool, + // creator + // ); + + // let spotPool = getSpotPoolAddr(this.program.programId, slPool, 0)[0]; + + // let [slPoolSigner] = getSharedLiquidityPoolSignerAddr( + // this.program.programId, + // slPool + // ); + + // return this.program.methods + // .initializeSharedLiquidityPool({ + // baseAmount, + // quoteAmount, + // proposalStakeRateThresholdBps, + // }) + // .accounts({ + // slPool, + // baseMint, + // quoteMint, + // dao, + // spotPool, + // spotPoolLpMint: getRaydiumCpmmLpMintAddr(spotPool, false)[0], + // creator, + // creatorSlPoolPosition, + // creatorLpAccount: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(spotPool, false)[0], + // this.provider.wallet.publicKey, + // true + // ), + // creatorBaseTokenAccount: getAssociatedTokenAddressSync( + // baseMint, + // creator, + // true + // ), + // creatorQuoteTokenAccount: getAssociatedTokenAddressSync( + // quoteMint, + // this.provider.wallet.publicKey, + // true + // ), + // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // spotPool, + // baseMint, + // false + // )[0], + // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // spotPool, + // quoteMint, + // false + // )[0], + // slPoolSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(spotPool, false)[0], + // slPoolSigner, + // true + // ), + // slPoolBaseVault: getAssociatedTokenAddressSync( + // baseMint, + // slPoolSigner, + // true + // ), + // slPoolQuoteVault: getAssociatedTokenAddressSync( + // quoteMint, + // slPoolSigner, + // true + // ), + // raydiumInitPoolStatic: RAYDIUM_INIT_POOL_STATIC_ACCOUNTS, + // spotPoolObservationState: getRaydiumCpmmObservationStateAddr( + // spotPool, + // false + // )[0], + // slPoolSigner, + // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + // }) + // .preInstructions([ + // createAssociatedTokenAccountIdempotentInstruction( + // this.provider.wallet.publicKey, + // getAssociatedTokenAddressSync(baseMint, slPoolSigner, true), + // slPoolSigner, + // baseMint + // ), + // createAssociatedTokenAccountIdempotentInstruction( + // this.provider.wallet.publicKey, + // getAssociatedTokenAddressSync(quoteMint, slPoolSigner, true), + // slPoolSigner, + // quoteMint + // ), + // ]); + // } + + // depositSharedLiquidityIx( + // slPool: PublicKey, + // activeSpotPool: PublicKey, + // baseMint: PublicKey, + // quoteMint: PublicKey, + // lpTokenAmount: BN, + // maxBaseTokenAmount: BN, + // maxQuoteTokenAmount: BN, + // user: PublicKey = this.provider.wallet.publicKey + // ) { + // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( + // this.program.programId, + // slPool + // ); + + // const [userSlPoolPosition] = getSlPoolPositionAddr( + // this.program.programId, + // slPool, + // user + // ); + + // return this.program.methods + // .depositSharedLiquidity({ + // lpTokenAmount, + // maxBaseTokenAmount, + // maxQuoteTokenAmount, + // }) + // .accounts({ + // slPool, + // activeSpotPool, + // user, + // userBaseTokenAccount: getAssociatedTokenAddressSync(baseMint, user), + // userQuoteTokenAccount: getAssociatedTokenAddressSync(quoteMint, user), + // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // baseMint, + // false + // )[0], + // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // quoteMint, + // false + // )[0], + // baseMint, + // quoteMint, + // spotPoolLpMint: getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // slPoolSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // slPoolSigner, + // true + // ), + // userLpTokenAccount: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // user, + // true + // ), + // userSlPoolPosition, + // raydiumAuthority: RAYDIUM_AUTHORITY, + // tokenProgram2022: TOKEN_2022_PROGRAM_ID, + // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + // }) + // .preInstructions([ + // ComputeBudgetProgram.setComputeUnitLimit({ + // units: 300_000, + // }), + // ]); + // } + + // withdrawSharedLiquidityIx( + // slPool: PublicKey, + // activeSpotPool: PublicKey, + // baseMint: PublicKey, + // quoteMint: PublicKey, + // lpTokenAmount: BN, + // minimumToken0Amount: BN, + // minimumToken1Amount: BN, + // user: PublicKey = this.provider.wallet.publicKey + // ) { + // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( + // this.program.programId, + // slPool + // ); + + // const [userSlPoolPosition] = PublicKey.findProgramAddressSync( + // [Buffer.from("sl_pool_position"), slPool.toBuffer(), user.toBuffer()], + // this.program.programId + // ); + + // return this.program.methods + // .withdrawSharedLiquidity({ + // lpTokenAmount, + // minimumToken0Amount, + // minimumToken1Amount, + // }) + // .accounts({ + // slPool, + // slPoolSigner, + // activeSpotPool, + // slPoolSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // slPoolSigner, + // true + // ), + // userQuoteTokenAccount: getAssociatedTokenAddressSync(quoteMint, user), + // userBaseTokenAccount: getAssociatedTokenAddressSync(baseMint, user), + // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // baseMint, + // false + // )[0], + // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // quoteMint, + // false + // )[0], + // baseMint, + // quoteMint, + // spotPoolLpMint: getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // userLpTokenAccount: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // user, + // true + // ), + // userSlPoolPosition, + // user, + // feeReceiver: this.provider.wallet.publicKey, + // raydiumAuthority: RAYDIUM_AUTHORITY, + // tokenProgram: TOKEN_PROGRAM_ID, + // tokenProgram2022: TOKEN_2022_PROGRAM_ID, + // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + // memoProgram: MEMO_PROGRAM_ID, + // eventAuthority: getEventAuthorityAddr(this.program.programId)[0], + // program: this.program.programId, + // }); + // } + + // initializeProposalWithLiquidityIx( + // dao: PublicKey, + // baseMint: PublicKey, + // quoteMint: PublicKey, + // nonce: BN, + // draftProposal: PublicKey, + // spotPoolIndex: number = 0, + // proposalStakeRateThresholdBps: number = 100 + // ) { + // const [slPool] = getSharedLiquidityPoolAddr( + // this.program.programId, + // dao, + // this.provider.wallet.publicKey, + // proposalStakeRateThresholdBps + // ); + + // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( + // this.program.programId, + // slPool + // ); + + // const [spotPool] = getSpotPoolAddr( + // this.program.programId, + // slPool, + // spotPoolIndex + // ); + + // const [proposal] = getProposalAddr( + // this.autocratClient.getProgramId(), + // slPoolSigner, + // nonce + // ); + + // const { + // passAmm, + // failAmm, + // question, + // baseVault, + // quoteVault, + // passBaseMint, + // failBaseMint, + // passQuoteMint, + // failQuoteMint, + // passLp: passLpMint, + // failLp: failLpMint, + // } = this.autocratClient.getProposalPdas(proposal, baseMint, quoteMint, dao); + + // const [daoTreasury] = getDaoTreasuryAddr( + // this.autocratClient.getProgramId(), + // dao + // ); + + // return this.program.methods + // .initializeProposalWithLiquidity({ + // nonce, + // }) + // .accounts({ + // sharedLiquidityPool: slPool, + // draftProposal, + // proposalCreator: this.provider.wallet.publicKey, + // proposal, + // baseMint, + // quoteMint, + // slPoolBaseVault: getAssociatedTokenAddressSync( + // baseMint, + // slPoolSigner, + // true + // ), + // slPoolQuoteVault: getAssociatedTokenAddressSync( + // quoteMint, + // slPoolSigner, + // true + // ), + // slPoolSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(spotPool, false)[0], + // slPoolSigner, + // true + // ), + // raydium: { + // spotPool: spotPool, + // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // spotPool, + // baseMint, + // false + // )[0], + // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // spotPool, + // quoteMint, + // false + // )[0], + // lpMint: getRaydiumCpmmLpMintAddr(spotPool, false)[0], + // raydiumAuthority: RAYDIUM_AUTHORITY, + // tokenProgram: TOKEN_PROGRAM_ID, + // tokenProgram2022: TOKEN_2022_PROGRAM_ID, + // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + // memoProgram: MEMO_PROGRAM_ID, + // }, + // conditionalVault: { + // slPoolSigner, + // question, + // baseVault, + // quoteVault, + // baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + // baseMint, + // baseVault, + // true + // ), + // quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + // quoteMint, + // quoteVault, + // true + // ), + // conditionalVaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + // passBaseMint, + // failBaseMint, + // passQuoteMint, + // failQuoteMint, + // slPoolPassBaseVault: getAssociatedTokenAddressSync( + // passBaseMint, + // slPoolSigner, + // true + // ), + // slPoolFailBaseVault: getAssociatedTokenAddressSync( + // failBaseMint, + // slPoolSigner, + // true + // ), + // slPoolPassQuoteVault: getAssociatedTokenAddressSync( + // passQuoteMint, + // slPoolSigner, + // true + // ), + // slPoolFailQuoteVault: getAssociatedTokenAddressSync( + // failQuoteMint, + // slPoolSigner, + // true + // ), + // vaultEventAuthority: getEventAuthorityAddr( + // CONDITIONAL_VAULT_v0_4_PROGRAM_ID + // )[0], + // }, + // amm: { + // passAmm, + // failAmm, + // passLpMint, + // failLpMint, + // slPoolPassLpAccount: getAssociatedTokenAddressSync( + // passLpMint, + // slPoolSigner, + // true + // ), + // slPoolFailLpAccount: getAssociatedTokenAddressSync( + // failLpMint, + // slPoolSigner, + // true + // ), + // passAmmVaultAtaBase: getAssociatedTokenAddressSync( + // passBaseMint, + // passAmm, + // true + // ), + // passAmmVaultAtaQuote: getAssociatedTokenAddressSync( + // passQuoteMint, + // passAmm, + // true + // ), + // failAmmVaultAtaBase: getAssociatedTokenAddressSync( + // failBaseMint, + // failAmm, + // true + // ), + // failAmmVaultAtaQuote: getAssociatedTokenAddressSync( + // failQuoteMint, + // failAmm, + // true + // ), + // proposal, + // proposalPassLpVault: getAssociatedTokenAddressSync( + // passLpMint, + // proposal, + // true + // ), + // proposalFailLpVault: getAssociatedTokenAddressSync( + // failLpMint, + // proposal, + // true + // ), + // ammProgram: AMM_PROGRAM_ID, + // eventAuthority: getEventAuthorityAddr(AMM_PROGRAM_ID)[0], + // slPoolSigner, + // }, + // autocratEventAuthority: getEventAuthorityAddr(AUTOCRAT_V0_5_PROGRAM_ID)[0], + // dao, + // autocratProgram: AUTOCRAT_V0_5_PROGRAM_ID, + // systemProgram: SystemProgram.programId, + // }); + // } + + // initializeDraftProposalIx( + // sharedLiquidityPool: PublicKey, + // baseMint: PublicKey, + // instruction: any, + // draftProposalNonce: BN = new BN(Math.floor(Math.random() * 1000000)) + // ) { + // let [draftProposal] = getDraftProposalAddr( + // this.program.programId, + // draftProposalNonce + // ); + + // return this.program.methods + // .initializeDraftProposal({ + // instruction, + // draftProposalNonce, + // }) + // .accounts({ + // draftProposal, + // sharedLiquidityPool, + // baseMint, + // stakedTokenVault: getAssociatedTokenAddressSync( + // baseMint, + // draftProposal, + // true + // ), + // }); + // } + + // stakeToDraftProposalIx( + // draftProposal: PublicKey, + // baseMint: PublicKey, + // amount: BN, + // staker: PublicKey = this.provider.wallet.publicKey + // ) { + // const [stakeRecord] = getStakeRecordAddr( + // this.program.programId, + // draftProposal, + // staker + // ); + + // return this.program.methods + // .stakeToDraftProposal({ + // amount, + // }) + // .accounts({ + // draftProposal, + // staker, + // stakerTokenAccount: getAssociatedTokenAddressSync( + // baseMint, + // staker, + // true + // ), + // stakedTokenVault: getAssociatedTokenAddressSync( + // baseMint, + // draftProposal, + // true + // ), + // stakeRecord, + // }); + // } + + // unstakeFromDraftProposalIx( + // draftProposal: PublicKey, + // baseMint: PublicKey, + // amount: BN, + // staker: PublicKey = this.provider.wallet.publicKey + // ) { + // const [stakeRecord] = getStakeRecordAddr( + // this.program.programId, + // draftProposal, + // staker + // ); + + // return this.program.methods + // .unstakeFromDraftProposal({ + // amount, + // }) + // .accounts({ + // draftProposal, + // staker, + // stakerTokenAccount: getAssociatedTokenAddressSync( + // baseMint, + // staker, + // true + // ), + // stakedTokenVault: getAssociatedTokenAddressSync( + // baseMint, + // draftProposal, + // true + // ), + // stakeRecord, + // }); + // } + + // removeProposalLiquidityIx( + // dao: PublicKey, + // spotPool: PublicKey, + // baseMint: PublicKey, + // quoteMint: PublicKey, + // proposalNonce: BN, + // proposalStakeRateThresholdBps: number = 100, + // spotPoolIndex: number = 0 + // ) { + // const [slPool] = getSharedLiquidityPoolAddr( + // this.program.programId, + // dao, + // this.provider.wallet.publicKey, + // proposalStakeRateThresholdBps + // ); + + // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( + // this.program.programId, + // slPool + // ); + + // const [proposal] = getProposalAddr( + // this.autocratClient.getProgramId(), + // slPoolSigner, + // proposalNonce + // ); + + // const { + // passAmm, + // failAmm, + // question, + // baseVault, + // quoteVault, + // passBaseMint, + // failBaseMint, + // passQuoteMint, + // failQuoteMint, + // passLp: passLpMint, + // failLp: failLpMint, + // } = this.autocratClient.getProposalPdas(proposal, baseMint, quoteMint, dao); + + // const [daoTreasury] = getDaoTreasuryAddr( + // this.autocratClient.getProgramId(), + // dao + // ); + + // const poolStateKp = Keypair.generate(); + // const poolState = poolStateKp.publicKey; + + // const [observationState] = getRaydiumCpmmObservationStateAddr( + // poolState, + // false + // ); + + // const [activeSpotPool] = getSpotPoolAddr( + // this.program.programId, + // slPool, + // spotPoolIndex + // ); + // const [nextSpotPool] = getSpotPoolAddr( + // this.program.programId, + // slPool, + // spotPoolIndex + 1 + // ); + + // return this.program.methods.removeProposalLiquidity().accounts({ + // slPool, + // proposal, + // baseMint, + // quoteMint, + // slPoolBaseVault: getAssociatedTokenAddressSync( + // baseMint, + // slPoolSigner, + // true + // ), + // slPoolQuoteVault: getAssociatedTokenAddressSync( + // quoteMint, + // slPoolSigner, + // true + // ), + // slPoolSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], + // slPoolSigner, + // true + // ), + // raydium: { + // activeSpotPool: activeSpotPool, + // activeSpotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // baseMint, + // false + // )[0], + // activeSpotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // activeSpotPool, + // quoteMint, + // false + // )[0], + // nextSpotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( + // nextSpotPool, + // quoteMint, + // false + // )[0], + // slPoolSigner, + // nextSpotPoolLpMint: getRaydiumCpmmLpMintAddr(nextSpotPool, false)[0], + // nextSpotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( + // nextSpotPool, + // baseMint, + // false + // )[0], + // nextSpotPool, + // nextSpotPoolObservationState: getRaydiumCpmmObservationStateAddr( + // nextSpotPool, + // false + // )[0], + // slPoolNextSpotLpVault: getAssociatedTokenAddressSync( + // getRaydiumCpmmLpMintAddr(nextSpotPool, false)[0], + // slPoolSigner, + // true + // ), + // activeSpotPoolLpMint: getRaydiumCpmmLpMintAddr( + // activeSpotPool, + // false + // )[0], + // tokenProgram2022: TOKEN_2022_PROGRAM_ID, + // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, + // memoProgram: MEMO_PROGRAM_ID, + // baseMint, + // quoteMint, + // slPool, + // }, + // raydiumInitPoolStatic: RAYDIUM_INIT_POOL_STATIC_ACCOUNTS, + // conditionalVault: { + // question, + // baseVault, + // quoteVault, + // baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + // baseMint, + // baseVault, + // true + // ), + // quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + // quoteMint, + // quoteVault, + // true + // ), + // conditionalVaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + // passBaseMint, + // failBaseMint, + // passQuoteMint, + // failQuoteMint, + // slPoolPassBaseVault: getAssociatedTokenAddressSync( + // passBaseMint, + // slPoolSigner, + // true + // ), + // slPoolFailBaseVault: getAssociatedTokenAddressSync( + // failBaseMint, + // slPoolSigner, + // true + // ), + // slPoolPassQuoteVault: getAssociatedTokenAddressSync( + // passQuoteMint, + // slPoolSigner, + // true + // ), + // slPoolFailQuoteVault: getAssociatedTokenAddressSync( + // failQuoteMint, + // slPoolSigner, + // true + // ), + // vaultEventAuthority: getEventAuthorityAddr( + // CONDITIONAL_VAULT_v0_4_PROGRAM_ID + // )[0], + // tokenProgram: TOKEN_PROGRAM_ID, + // slPoolSigner, + // }, + // ammm: { + // passAmm, + // failAmm, + // passLpMint, + // failLpMint, + // slPoolPassLpAccount: getAssociatedTokenAddressSync( + // passLpMint, + // slPoolSigner, + // true + // ), + // slPoolFailLpAccount: getAssociatedTokenAddressSync( + // failLpMint, + // slPoolSigner, + // true + // ), + // passAmmVaultAtaBase: getAssociatedTokenAddressSync( + // passBaseMint, + // passAmm, + // true + // ), + // passAmmVaultAtaQuote: getAssociatedTokenAddressSync( + // passQuoteMint, + // passAmm, + // true + // ), + // failAmmVaultAtaBase: getAssociatedTokenAddressSync( + // failBaseMint, + // failAmm, + // true + // ), + // failAmmVaultAtaQuote: getAssociatedTokenAddressSync( + // failQuoteMint, + // failAmm, + // true + // ), + // slPoolSigner, + // ammProgram: AMM_PROGRAM_ID, + // eventAuthority: getEventAuthorityAddr(AMM_PROGRAM_ID)[0], + // }, + // }); + // } +} diff --git a/sdk2/src/shared_liquidity_manager/v0.5/index.ts b/sdk2/src/shared_liquidity_manager/v0.5/index.ts new file mode 100644 index 000000000..e79f94bbc --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/v0.5/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./SharedLiquidityManagerClient.js"; diff --git a/sdk2/src/shared_liquidity_manager/v0.5/pda.ts b/sdk2/src/shared_liquidity_manager/v0.5/pda.ts new file mode 100644 index 000000000..a53de20d6 --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/v0.5/pda.ts @@ -0,0 +1,126 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import BN from "bn.js"; +import { + SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +} from "../../constants.js"; + +export const getSharedLiquidityPoolAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + dao: PublicKey, + creator: PublicKey, + proposalStakeRateThresholdBps: number, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("sl_pool"), + dao.toBuffer(), + creator.toBuffer(), + new BN(proposalStakeRateThresholdBps).toArrayLike(Buffer, "le", 2), + ], + programId, + ); +}; + +export const getSlPoolPositionAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + slPool: PublicKey, + user: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("sl_pool_position"), slPool.toBuffer(), user.toBuffer()], + programId, + ); +}; + +export const getSharedLiquidityPoolSignerAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + slPool: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("sl_pool_signer"), slPool.toBuffer()], + programId, + ); +}; + +export const getSpotPoolAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + slPool: PublicKey, + index: number, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("spot_pool"), + slPool.toBuffer(), + new BN(index).toArrayLike(Buffer, "le", 4), + ], + programId, + ); +}; + +export const getDraftProposalAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + nonce: BN, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("draft_proposal"), nonce.toArrayLike(Buffer, "le", 8)], + programId, + ); +}; + +export const getStakeRecordAddr = ( + programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, + draftProposal: PublicKey, + staker: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("stake_record"), draftProposal.toBuffer(), staker.toBuffer()], + programId, + ); +}; + +export const getRaydiumCpmmPoolVaultAddr = ( + poolState: PublicKey, + token: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("pool_vault"), + poolState.toBuffer(), + token.toBuffer(), + ], + programId, + ); +}; + +export const getRaydiumCpmmObservationStateAddr = ( + poolState: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("observation"), poolState.toBuffer()], + programId, + ); +}; + +export const getRaydiumCpmmLpMintAddr = ( + poolState: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_lp_mint"), poolState.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/shared_liquidity_manager/v0.5/types/index.ts b/sdk2/src/shared_liquidity_manager/v0.5/types/index.ts new file mode 100644 index 000000000..8a508c696 --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/v0.5/types/index.ts @@ -0,0 +1,5 @@ +import { + SharedLiquidityManager as SharedLiquidityManagerProgram, + IDL as SharedLiquidityManagerIDL, +} from "./shared_liquidity_manager.js"; +export { SharedLiquidityManagerProgram, SharedLiquidityManagerIDL }; diff --git a/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts b/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts new file mode 100644 index 000000000..124942da9 --- /dev/null +++ b/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts @@ -0,0 +1,177 @@ +export type SharedLiquidityManager = { + version: "0.1.0"; + name: "shared_liquidity_manager"; + docs: ["TODO:", "- add unstake", "- add unit tests"]; + instructions: []; + errors: [ + { + code: 6000; + name: "InsufficientStake"; + msg: "Insufficient stake amount"; + }, + { + code: 6001; + name: "ProposalNotFinalized"; + msg: "Proposal is not finalized"; + }, + { + code: 6002; + name: "NoLpTokensToRemove"; + msg: "No LP tokens to remove from AMM"; + }, + { + code: 6003; + name: "NoTokensFromAmm"; + msg: "No tokens received from AMM removal"; + }, + { + code: 6004; + name: "InsufficientReservesReturned"; + msg: "Insufficient reserves returned to spot AMM (less than 99.5%)"; + }, + { + code: 6005; + name: "PoolInUse"; + msg: "Pool is currently being used by an active proposal"; + }, + { + code: 6006; + name: "InsufficientLpShares"; + msg: "User does not have enough LP shares to withdraw"; + }, + { + code: 6007; + name: "SlippageExceeded"; + msg: "Slippage exceeded minimum token amounts"; + }, + { + code: 6008; + name: "NoLpTokensInPool"; + msg: "No LP tokens in pool's LP token account"; + }, + { + code: 6009; + name: "NotEnoughLpTokens"; + msg: "Not enough LP tokens to provide liquidity to proposal"; + }, + { + code: 6010; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6011; + name: "NoActiveProposal"; + msg: "No active proposal"; + }, + { + code: 6012; + name: "ProposalNotInDraftStatus"; + msg: "Proposal is not in draft status"; + }, + { + code: 6013; + name: "ProposalAlreadyActive"; + msg: "Proposal already active"; + }, + { + code: 6014; + name: "AmmAlreadyHasLiquidity"; + msg: "AMM already has liquidity"; + }, + { + code: 6015; + name: "QuestionAlreadyResolved"; + msg: "Question already resolved"; + }, + ]; +}; + +export const IDL: SharedLiquidityManager = { + version: "0.1.0", + name: "shared_liquidity_manager", + docs: ["TODO:", "- add unstake", "- add unit tests"], + instructions: [], + errors: [ + { + code: 6000, + name: "InsufficientStake", + msg: "Insufficient stake amount", + }, + { + code: 6001, + name: "ProposalNotFinalized", + msg: "Proposal is not finalized", + }, + { + code: 6002, + name: "NoLpTokensToRemove", + msg: "No LP tokens to remove from AMM", + }, + { + code: 6003, + name: "NoTokensFromAmm", + msg: "No tokens received from AMM removal", + }, + { + code: 6004, + name: "InsufficientReservesReturned", + msg: "Insufficient reserves returned to spot AMM (less than 99.5%)", + }, + { + code: 6005, + name: "PoolInUse", + msg: "Pool is currently being used by an active proposal", + }, + { + code: 6006, + name: "InsufficientLpShares", + msg: "User does not have enough LP shares to withdraw", + }, + { + code: 6007, + name: "SlippageExceeded", + msg: "Slippage exceeded minimum token amounts", + }, + { + code: 6008, + name: "NoLpTokensInPool", + msg: "No LP tokens in pool's LP token account", + }, + { + code: 6009, + name: "NotEnoughLpTokens", + msg: "Not enough LP tokens to provide liquidity to proposal", + }, + { + code: 6010, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6011, + name: "NoActiveProposal", + msg: "No active proposal", + }, + { + code: 6012, + name: "ProposalNotInDraftStatus", + msg: "Proposal is not in draft status", + }, + { + code: 6013, + name: "ProposalAlreadyActive", + msg: "Proposal already active", + }, + { + code: 6014, + name: "AmmAlreadyHasLiquidity", + msg: "AMM already has liquidity", + }, + { + code: 6015, + name: "QuestionAlreadyResolved", + msg: "Question already resolved", + }, + ], +}; From 922da4fc18c0fd65efa7ea8d70081de80a581a03 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sun, 29 Mar 2026 00:06:10 +0100 Subject: [PATCH 035/100] add 0.4 clients to sdk v2 --- sdk2/package.json | 5 +- sdk2/src/amm/v0.4/AmmClient.ts | 381 ++++ sdk2/src/amm/v0.4/index.ts | 3 + sdk2/src/amm/v0.4/pda.ts | 28 + sdk2/src/amm/v0.4/types/amm.ts | 1647 ++++++++++++++++ sdk2/src/amm/v0.4/types/index.ts | 19 + sdk2/src/autocrat/v0.4/AutocratClient.ts | 789 ++++++++ sdk2/src/autocrat/v0.4/index.ts | 3 + sdk2/src/autocrat/v0.4/pda.ts | 26 + sdk2/src/autocrat/v0.4/types/autocrat.ts | 2013 ++++++++++++++++++++ sdk2/src/autocrat/v0.4/types/index.ts | 29 + sdk2/src/constants.ts | 10 + sdk2/src/launchpad/v0.4/LaunchpadClient.ts | 410 ++++ sdk2/src/launchpad/v0.4/index.ts | 3 + sdk2/src/launchpad/v0.4/pda.ts | 71 + sdk2/src/launchpad/v0.4/types/index.ts | 29 + sdk2/src/launchpad/v0.4/types/launchpad.ts | 1999 +++++++++++++++++++ 17 files changed, 7464 insertions(+), 1 deletion(-) create mode 100644 sdk2/src/amm/v0.4/AmmClient.ts create mode 100644 sdk2/src/amm/v0.4/index.ts create mode 100644 sdk2/src/amm/v0.4/pda.ts create mode 100644 sdk2/src/amm/v0.4/types/amm.ts create mode 100644 sdk2/src/amm/v0.4/types/index.ts create mode 100644 sdk2/src/autocrat/v0.4/AutocratClient.ts create mode 100644 sdk2/src/autocrat/v0.4/index.ts create mode 100644 sdk2/src/autocrat/v0.4/pda.ts create mode 100644 sdk2/src/autocrat/v0.4/types/autocrat.ts create mode 100644 sdk2/src/autocrat/v0.4/types/index.ts create mode 100644 sdk2/src/launchpad/v0.4/LaunchpadClient.ts create mode 100644 sdk2/src/launchpad/v0.4/index.ts create mode 100644 sdk2/src/launchpad/v0.4/pda.ts create mode 100644 sdk2/src/launchpad/v0.4/types/index.ts create mode 100644 sdk2/src/launchpad/v0.4/types/launchpad.ts diff --git a/sdk2/package.json b/sdk2/package.json index 4f9d5db03..f314c16e6 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -19,7 +19,10 @@ "./autocrat/v0.5": "./dist/autocrat/v0.5/index.js", "./amm/v0.5": "./dist/amm/v0.5/index.js", "./launchpad/v0.5": "./dist/launchpad/v0.5/index.js", - "./shared_liquidity_manager/v0.5": "./dist/shared_liquidity_manager/v0.5/index.js" + "./shared_liquidity_manager/v0.5": "./dist/shared_liquidity_manager/v0.5/index.js", + "./autocrat/v0.4": "./dist/autocrat/v0.4/index.js", + "./amm/v0.4": "./dist/amm/v0.4/index.js", + "./launchpad/v0.4": "./dist/launchpad/v0.4/index.js" }, "license": "BSL-1.0", "files": [ diff --git a/sdk2/src/amm/v0.4/AmmClient.ts b/sdk2/src/amm/v0.4/AmmClient.ts new file mode 100644 index 000000000..9fa792143 --- /dev/null +++ b/sdk2/src/amm/v0.4/AmmClient.ts @@ -0,0 +1,381 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AddressLookupTableAccount, + Keypair, + PublicKey, +} from "@solana/web3.js"; + +import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; + +import BN from "bn.js"; +import { AMM_V0_4_PROGRAM_ID } from "../../constants.js"; +import { Amm } from "./types/index.js"; +import { LowercaseKeys } from "../../utils.js"; +import { getAmmLpMintAddr, getAmmAddr } from "./pda.js"; +import { + MintLayout, + unpackMint, + getAssociatedTokenAddressSync, + createAssociatedTokenAccountIdempotentInstruction, +} from "@solana/spl-token"; +import { AmmMath, PriceMath } from "../../priceMath.js"; + +export type SwapType = LowercaseKeys["SwapType"]>; + +export type CreateAmmClientParams = { + provider: AnchorProvider; + ammProgramId?: PublicKey; +}; + +export class AmmClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.program = new Program(AmmIDL, ammProgramId, provider); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateAmmClientParams, + ): AmmClient { + let { provider, ammProgramId: programId } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AmmClient(provider, programId || AMM_V0_4_PROGRAM_ID, luts); + } + + getProgramId(): PublicKey { + return this.program.programId; + } + + async getAmm(amm: PublicKey): Promise { + return await this.program.account.amm.fetch(amm); + } + + async fetchAmm(amm: PublicKey): Promise { + return await this.program.account.amm.fetchNullable(amm); + } + + async deserializeAmm(accountInfo: AccountInfo): Promise { + return this.program.coder.accounts.decode("amm", accountInfo.data); + } + + async createAmm( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + twapStartDelaySlots: BN, + twapInitialObservation: number, + twapMaxObservationChangePerUpdate?: number, + ): Promise { + if (!twapMaxObservationChangePerUpdate) { + twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; + } + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + + let baseDecimals = unpackMint( + baseMint, + await this.provider.connection.getAccountInfo(baseMint), + ).decimals; + let quoteDecimals = unpackMint( + quoteMint, + await this.provider.connection.getAccountInfo(quoteMint), + ).decimals; + + let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = + PriceMath.getAmmPrices( + baseDecimals, + quoteDecimals, + twapInitialObservation, + twapMaxObservationChangePerUpdate, + ); + + await this.initializeAmmIx( + baseMint, + quoteMint, + twapStartDelaySlots, + twapFirstObservationScaled, + twapMaxObservationChangePerUpdateScaled, + ).rpc(); + + return amm; + } + + // both twap values need to be scaled beforehand + initializeAmmIx( + baseMint: PublicKey, + quoteMint: PublicKey, + twapStartDelaySlots: BN, + twapInitialObservation: BN, + twapMaxObservationChangePerUpdate: BN, + ) { + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); + + let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); + let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); + + return this.program.methods + .createAmm({ + twapInitialObservation, + twapMaxObservationChangePerUpdate, + twapStartDelaySlots, + }) + .accounts({ + user: this.provider.publicKey, + amm, + lpMint, + baseMint, + quoteMint, + vaultAtaBase, + vaultAtaQuote, + }); + } + + async addLiquidity( + amm: PublicKey, + quoteAmount?: number, + baseAmount?: number, + ) { + let storedAmm = await this.getAmm(amm); + + let lpMintSupply = unpackMint( + storedAmm.lpMint, + await this.provider.connection.getAccountInfo(storedAmm.lpMint), + ).supply; + + let quoteAmountCasted: BN | undefined; + let baseAmountCasted: BN | undefined; + + if (quoteAmount != undefined) { + let quoteDecimals = unpackMint( + storedAmm.quoteMint, + await this.provider.connection.getAccountInfo(storedAmm.quoteMint), + ).decimals; + quoteAmountCasted = new BN(quoteAmount).mul( + new BN(10).pow(new BN(quoteDecimals)), + ); + } + + if (baseAmount != undefined) { + let baseDecimals = unpackMint( + storedAmm.baseMint, + await this.provider.connection.getAccountInfo(storedAmm.baseMint), + ).decimals; + baseAmountCasted = new BN(baseAmount).mul( + new BN(10).pow(new BN(baseDecimals)), + ); + } + + if (lpMintSupply == 0n) { + if (quoteAmount == undefined || baseAmount == undefined) { + throw new Error( + "No pool created yet, you need to specify both base and quote", + ); + } + + // console.log(quoteAmountCasted?.toString()); + // console.log(baseAmountCasted?.toString()) + + return await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + quoteAmountCasted as BN, + baseAmountCasted as BN, + new BN(0), + ).rpc(); + } + + // quoteAmount == undefined ? undefined : new BN(quoteAmount); + // let baseAmountCasted: BN | undefined = + // baseAmount == undefined ? undefined : new BN(baseAmount); + + let sim = AmmMath.simulateAddLiquidity( + storedAmm.baseAmount, + storedAmm.quoteAmount, + Number(lpMintSupply), + baseAmountCasted, + quoteAmountCasted, + ); + + await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + sim.quoteAmount, + sim.baseAmount, + sim.expectedLpTokens, + ).rpc(); + } + + addLiquidityIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + quoteAmount: BN, + maxBaseAmount: BN, + minLpTokens: BN, + user: PublicKey = this.provider.publicKey, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); + + const userLpAccount = getAssociatedTokenAddressSync(lpMint, user, true); + + return this.program.methods + .addLiquidity({ + quoteAmount, + maxBaseAmount, + minLpTokens, + }) + .accounts({ + user, + amm, + lpMint, + userLpAccount, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + user, + userLpAccount, + user, + lpMint, + ), + ]); + } + + removeLiquidityIx( + ammAddr: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + lpTokensToBurn: BN, + minBaseAmount: BN, + minQuoteAmount: BN, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); + + return this.program.methods + .removeLiquidity({ + lpTokensToBurn, + minBaseAmount, + minQuoteAmount, + }) + .accounts({ + user: this.provider.publicKey, + amm: ammAddr, + lpMint, + userLpAccount: getAssociatedTokenAddressSync( + lpMint, + this.provider.publicKey, + true, + ), + userBaseAccount: getAssociatedTokenAddressSync( + baseMint, + this.provider.publicKey, + true, + ), + userQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + this.provider.publicKey, + true, + ), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), + }); + } + + async swap( + amm: PublicKey, + swapType: SwapType, + inputAmount: number, + outputAmountMin: number, + ) { + const storedAmm = await this.getAmm(amm); + + let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); + let baseDecimals = await this.getDecimals(storedAmm.baseMint); + + let inputAmountScaled: BN; + let outputAmountMinScaled: BN; + if (swapType.buy) { + inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); + } else { + inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); + } + + return await this.swapIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + swapType, + inputAmountScaled, + outputAmountMinScaled, + ).rpc(); + } + + swapIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + swapType: SwapType, + inputAmount: BN, + outputAmountMin: BN, + user: PublicKey = this.provider.publicKey, + ) { + const receivingToken = swapType.buy ? baseMint : quoteMint; + + return this.program.methods + .swap({ + swapType, + inputAmount, + outputAmountMin, + }) + .accounts({ + user, + amm, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + // create the receiving token account if it doesn't exist + createAssociatedTokenAccountIdempotentInstruction( + user, + getAssociatedTokenAddressSync(receivingToken, user, true), + user, + receivingToken, + ), + ]); + } + + async crankThatTwap(amm: PublicKey) { + return this.crankThatTwapIx(amm).rpc(); + } + + crankThatTwapIx(amm: PublicKey) { + return this.program.methods.crankThatTwap().accounts({ + amm, + }); + } + + async getDecimals(mint: PublicKey): Promise { + return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) + .decimals; + } +} diff --git a/sdk2/src/amm/v0.4/index.ts b/sdk2/src/amm/v0.4/index.ts new file mode 100644 index 000000000..cf8af7f89 --- /dev/null +++ b/sdk2/src/amm/v0.4/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./AmmClient.js"; diff --git a/sdk2/src/amm/v0.4/pda.ts b/sdk2/src/amm/v0.4/pda.ts new file mode 100644 index 000000000..9d6abcd19 --- /dev/null +++ b/sdk2/src/amm/v0.4/pda.ts @@ -0,0 +1,28 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { AMM_V0_4_PROGRAM_ID } from "../../constants.js"; + +export const getAmmAddr = ( + programId: PublicKey = AMM_V0_4_PROGRAM_ID, + baseMint: PublicKey, + quoteMint: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("amm__"), + baseMint.toBuffer(), + quoteMint.toBuffer(), + ], + programId, + ); +}; + +export const getAmmLpMintAddr = ( + programId: PublicKey = AMM_V0_4_PROGRAM_ID, + amm: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/amm/v0.4/types/amm.ts b/sdk2/src/amm/v0.4/types/amm.ts new file mode 100644 index 000000000..72fc00cc8 --- /dev/null +++ b/sdk2/src/amm/v0.4/types/amm.ts @@ -0,0 +1,1647 @@ +export type Amm = { + version: "0.4.1"; + name: "amm"; + instructions: [ + { + name: "createAmm"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "CreateAmmArgs"; + }; + }, + ]; + }, + { + name: "addLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddLiquidityArgs"; + }; + }, + ]; + }, + { + name: "removeLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "RemoveLiquidityArgs"; + }; + }, + ]; + }, + { + name: "swap"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "SwapArgs"; + }; + }, + ]; + }, + { + name: "crankThatTwap"; + accounts: [ + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "amm"; + type: { + kind: "struct"; + fields: [ + { + name: "bump"; + type: "u8"; + }, + { + name: "createdAtSlot"; + type: "u64"; + }, + { + name: "lpMint"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "baseMintDecimals"; + type: "u8"; + }, + { + name: "quoteMintDecimals"; + type: "u8"; + }, + { + name: "baseAmount"; + type: "u64"; + }, + { + name: "quoteAmount"; + type: "u64"; + }, + { + name: "oracle"; + type: { + defined: "TwapOracle"; + }; + }, + { + name: "seqNum"; + type: "u64"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "user"; + type: "publicKey"; + }, + { + name: "amm"; + type: "publicKey"; + }, + { + name: "postBaseReserves"; + type: "u64"; + }, + { + name: "postQuoteReserves"; + type: "u64"; + }, + { + name: "oracleLastPrice"; + type: "u128"; + }, + { + name: "oracleLastObservation"; + type: "u128"; + }, + { + name: "oracleAggregator"; + type: "u128"; + }, + { + name: "seqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "AddLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "quoteAmount"; + docs: ["How much quote token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "maxBaseAmount"; + docs: ["The maximum base token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "minLpTokens"; + docs: ["The minimum LP token you will get back"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "CreateAmmArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + type: "u64"; + }, + ]; + }; + }, + { + name: "RemoveLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "lpTokensToBurn"; + type: "u64"; + }, + { + name: "minQuoteAmount"; + type: "u64"; + }, + { + name: "minBaseAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "SwapArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "outputAmountMin"; + type: "u64"; + }, + ]; + }; + }, + { + name: "TwapOracle"; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdatedSlot"; + type: "u64"; + }, + { + name: "lastPrice"; + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ]; + type: "u128"; + }, + { + name: "lastObservation"; + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ]; + type: "u128"; + }, + { + name: "aggregator"; + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ]; + type: "u128"; + }, + { + name: "maxObservationChangePerUpdate"; + docs: ["The most that an observation can change per update."]; + type: "u128"; + }, + { + name: "initialObservation"; + docs: ["What the initial `latest_observation` is set to."]; + type: "u128"; + }, + { + name: "startDelaySlots"; + docs: [ + "Number of slots after amm.created_at_slot to start recording TWAP", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "SwapType"; + type: { + kind: "enum"; + variants: [ + { + name: "Buy"; + }, + { + name: "Sell"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "SwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + ]; + }, + { + name: "AddLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "maxBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "minLpTokens"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "lpTokensMinted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "RemoveLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "lpTokensBurned"; + type: "u64"; + index: false; + }, + { + name: "minQuoteAmount"; + type: "u64"; + index: false; + }, + { + name: "minBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "CreateAmmEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "lpMint"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "vaultAtaBase"; + type: "publicKey"; + index: false; + }, + { + name: "vaultAtaQuote"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "CrankThatTwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AssertFailed"; + msg: "An assertion failed"; + }, + { + code: 6001; + name: "NoSlotsPassed"; + msg: "Can't get a TWAP before some observations have been stored"; + }, + { + code: 6002; + name: "NoReserves"; + msg: "Can't swap through a pool without token reserves on either side"; + }, + { + code: 6003; + name: "InputAmountOverflow"; + msg: "Input token amount is too large for a swap, causes overflow"; + }, + { + code: 6004; + name: "AddLiquidityCalculationError"; + msg: "Add liquidity calculation error"; + }, + { + code: 6005; + name: "DecimalScaleError"; + msg: "Error in decimal scale conversion"; + }, + { + code: 6006; + name: "SameTokenMints"; + msg: "You can't create an AMM pool where the token mints are the same"; + }, + { + code: 6007; + name: "SwapSlippageExceeded"; + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; + }, + { + code: 6008; + name: "InsufficientBalance"; + msg: "The user had insufficient balance to do this"; + }, + { + code: 6009; + name: "ZeroLiquidityRemove"; + msg: "Must remove a non-zero amount of liquidity"; + }, + { + code: 6010; + name: "ZeroLiquidityToAdd"; + msg: "Cannot add liquidity with 0 tokens on either side"; + }, + { + code: 6011; + name: "ZeroMinLpTokens"; + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; + }, + { + code: 6012; + name: "AddLiquiditySlippageExceeded"; + msg: "LP wouldn't have gotten back `lp_token_min`"; + }, + { + code: 6013; + name: "AddLiquidityMaxBaseExceeded"; + msg: "LP would have spent more than `max_base_amount`"; + }, + { + code: 6014; + name: "InsufficientQuoteAmount"; + msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; + }, + { + code: 6015; + name: "ZeroSwapAmount"; + msg: "Users must swap a non-zero amount"; + }, + { + code: 6016; + name: "ConstantProductInvariantFailed"; + msg: "K should always be increasing"; + }, + { + code: 6017; + name: "CastingOverflow"; + msg: "Casting has caused an overflow"; + }, + ]; +}; + +export const IDL: Amm = { + version: "0.4.1", + name: "amm", + instructions: [ + { + name: "createAmm", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "CreateAmmArgs", + }, + }, + ], + }, + { + name: "addLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddLiquidityArgs", + }, + }, + ], + }, + { + name: "removeLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "RemoveLiquidityArgs", + }, + }, + ], + }, + { + name: "swap", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "SwapArgs", + }, + }, + ], + }, + { + name: "crankThatTwap", + accounts: [ + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "amm", + type: { + kind: "struct", + fields: [ + { + name: "bump", + type: "u8", + }, + { + name: "createdAtSlot", + type: "u64", + }, + { + name: "lpMint", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "baseMintDecimals", + type: "u8", + }, + { + name: "quoteMintDecimals", + type: "u8", + }, + { + name: "baseAmount", + type: "u64", + }, + { + name: "quoteAmount", + type: "u64", + }, + { + name: "oracle", + type: { + defined: "TwapOracle", + }, + }, + { + name: "seqNum", + type: "u64", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "user", + type: "publicKey", + }, + { + name: "amm", + type: "publicKey", + }, + { + name: "postBaseReserves", + type: "u64", + }, + { + name: "postQuoteReserves", + type: "u64", + }, + { + name: "oracleLastPrice", + type: "u128", + }, + { + name: "oracleLastObservation", + type: "u128", + }, + { + name: "oracleAggregator", + type: "u128", + }, + { + name: "seqNum", + type: "u64", + }, + ], + }, + }, + { + name: "AddLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "quoteAmount", + docs: ["How much quote token you will deposit to the pool"], + type: "u64", + }, + { + name: "maxBaseAmount", + docs: ["The maximum base token you will deposit to the pool"], + type: "u64", + }, + { + name: "minLpTokens", + docs: ["The minimum LP token you will get back"], + type: "u64", + }, + ], + }, + }, + { + name: "CreateAmmArgs", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + type: "u64", + }, + ], + }, + }, + { + name: "RemoveLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "lpTokensToBurn", + type: "u64", + }, + { + name: "minQuoteAmount", + type: "u64", + }, + { + name: "minBaseAmount", + type: "u64", + }, + ], + }, + }, + { + name: "SwapArgs", + type: { + kind: "struct", + fields: [ + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "inputAmount", + type: "u64", + }, + { + name: "outputAmountMin", + type: "u64", + }, + ], + }, + }, + { + name: "TwapOracle", + type: { + kind: "struct", + fields: [ + { + name: "lastUpdatedSlot", + type: "u64", + }, + { + name: "lastPrice", + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ], + type: "u128", + }, + { + name: "lastObservation", + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ], + type: "u128", + }, + { + name: "aggregator", + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ], + type: "u128", + }, + { + name: "maxObservationChangePerUpdate", + docs: ["The most that an observation can change per update."], + type: "u128", + }, + { + name: "initialObservation", + docs: ["What the initial `latest_observation` is set to."], + type: "u128", + }, + { + name: "startDelaySlots", + docs: [ + "Number of slots after amm.created_at_slot to start recording TWAP", + ], + type: "u64", + }, + ], + }, + }, + { + name: "SwapType", + type: { + kind: "enum", + variants: [ + { + name: "Buy", + }, + { + name: "Sell", + }, + ], + }, + }, + ], + events: [ + { + name: "SwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + ], + }, + { + name: "AddLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "maxBaseAmount", + type: "u64", + index: false, + }, + { + name: "minLpTokens", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "lpTokensMinted", + type: "u64", + index: false, + }, + ], + }, + { + name: "RemoveLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "lpTokensBurned", + type: "u64", + index: false, + }, + { + name: "minQuoteAmount", + type: "u64", + index: false, + }, + { + name: "minBaseAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + ], + }, + { + name: "CreateAmmEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "lpMint", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "vaultAtaBase", + type: "publicKey", + index: false, + }, + { + name: "vaultAtaQuote", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "CrankThatTwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AssertFailed", + msg: "An assertion failed", + }, + { + code: 6001, + name: "NoSlotsPassed", + msg: "Can't get a TWAP before some observations have been stored", + }, + { + code: 6002, + name: "NoReserves", + msg: "Can't swap through a pool without token reserves on either side", + }, + { + code: 6003, + name: "InputAmountOverflow", + msg: "Input token amount is too large for a swap, causes overflow", + }, + { + code: 6004, + name: "AddLiquidityCalculationError", + msg: "Add liquidity calculation error", + }, + { + code: 6005, + name: "DecimalScaleError", + msg: "Error in decimal scale conversion", + }, + { + code: 6006, + name: "SameTokenMints", + msg: "You can't create an AMM pool where the token mints are the same", + }, + { + code: 6007, + name: "SwapSlippageExceeded", + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", + }, + { + code: 6008, + name: "InsufficientBalance", + msg: "The user had insufficient balance to do this", + }, + { + code: 6009, + name: "ZeroLiquidityRemove", + msg: "Must remove a non-zero amount of liquidity", + }, + { + code: 6010, + name: "ZeroLiquidityToAdd", + msg: "Cannot add liquidity with 0 tokens on either side", + }, + { + code: 6011, + name: "ZeroMinLpTokens", + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", + }, + { + code: 6012, + name: "AddLiquiditySlippageExceeded", + msg: "LP wouldn't have gotten back `lp_token_min`", + }, + { + code: 6013, + name: "AddLiquidityMaxBaseExceeded", + msg: "LP would have spent more than `max_base_amount`", + }, + { + code: 6014, + name: "InsufficientQuoteAmount", + msg: "`quote_amount` must be greater than 100000000 when initializing a pool", + }, + { + code: 6015, + name: "ZeroSwapAmount", + msg: "Users must swap a non-zero amount", + }, + { + code: 6016, + name: "ConstantProductInvariantFailed", + msg: "K should always be increasing", + }, + { + code: 6017, + name: "CastingOverflow", + msg: "Casting has caused an overflow", + }, + ], +}; diff --git a/sdk2/src/amm/v0.4/types/index.ts b/sdk2/src/amm/v0.4/types/index.ts new file mode 100644 index 000000000..5313bb6dd --- /dev/null +++ b/sdk2/src/amm/v0.4/types/index.ts @@ -0,0 +1,19 @@ +import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; +export { AmmProgram, AmmIDL }; + +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +export type Amm = IdlAccounts["amm"]; + +export type SwapEvent = IdlEvents["SwapEvent"]; +export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; +export type RemoveLiquidityEvent = + IdlEvents["RemoveLiquidityEvent"]; +export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; +export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; +export type AmmEvent = + | SwapEvent + | AddLiquidityEvent + | RemoveLiquidityEvent + | CreateAmmEvent + | CrankThatTwapEvent; diff --git a/sdk2/src/autocrat/v0.4/AutocratClient.ts b/sdk2/src/autocrat/v0.4/AutocratClient.ts new file mode 100644 index 000000000..ae3e8c231 --- /dev/null +++ b/sdk2/src/autocrat/v0.4/AutocratClient.ts @@ -0,0 +1,789 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { + AccountInfo, + AccountMeta, + AddressLookupTableAccount, + ComputeBudgetProgram, + Connection, + Keypair, + PublicKey, + Transaction, + TransactionInstruction, +} from "@solana/web3.js"; +import { PriceMath } from "../../priceMath.js"; +import { ProposalInstruction, InitializeDaoParams } from "./types/index.js"; + +import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; + +import BN from "bn.js"; +import { + AMM_V0_4_PROGRAM_ID, + AUTOCRAT_V0_4_PROGRAM_ID, + CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + MAINNET_USDC, + USDC_DECIMALS, +} from "../../constants.js"; +import { InstructionUtils } from "../../utils.js"; +import { getAmmAddr, getAmmLpMintAddr } from "../../amm/v0.4/pda.js"; +import { + getConditionalTokenMintAddr, + getQuestionAddr, + getVaultAddr, +} from "../../conditional_vault/v0.4/pda.js"; +import { getDaoTreasuryAddr, getProposalAddr } from "./pda.js"; +import { getEventAuthorityAddr } from "../../pda.js"; +import { ConditionalVaultClient } from "../../conditional_vault/v0.4/ConditionalVaultClient.js"; +import { AmmClient } from "../../amm/v0.4/AmmClient.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + unpackMint, +} from "@solana/spl-token"; +import { sha256 } from "@noble/hashes/sha256"; +import { Dao, Proposal } from "./types/index.js"; + +export type CreateClientParams = { + provider: AnchorProvider; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export type ProposalVaults = { + baseVault: PublicKey; + quoteVault: PublicKey; +}; + +export class AutocratClient { + public readonly provider: AnchorProvider; + public readonly autocrat: Program; + public readonly vaultClient: ConditionalVaultClient; + public readonly ammClient: AmmClient; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + autocratProgramId: PublicKey, + conditionalVaultProgramId: PublicKey, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.autocrat = new Program( + AutocratIDL, + autocratProgramId, + provider, + ); + this.vaultClient = ConditionalVaultClient.createClient({ + provider, + conditionalVaultProgramId, + }); + this.ammClient = AmmClient.createClient({ provider, ammProgramId }); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateClientParams, + ): AutocratClient { + let { + provider, + autocratProgramId, + conditionalVaultProgramId, + ammProgramId, + } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AutocratClient( + provider, + autocratProgramId || AUTOCRAT_V0_4_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + ammProgramId || AMM_V0_4_PROGRAM_ID, + luts, + ); + } + + getProgramId(): PublicKey { + return this.autocrat.programId; + } + + async getProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetch(proposal); + } + + async getDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetch(dao); + } + + async fetchProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetchNullable(proposal); + } + + async fetchDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetchNullable(dao); + } + + async deserializeProposal( + accountInfo: AccountInfo, + ): Promise { + return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); + } + + async deserializeDao(accountInfo: AccountInfo): Promise { + return this.autocrat.coder.accounts.decode("dao", accountInfo.data); + } + + getProposalPdas( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + dao: PublicKey, + ): { + question: PublicKey; + baseVault: PublicKey; + quoteVault: PublicKey; + passBaseMint: PublicKey; + passQuoteMint: PublicKey; + failBaseMint: PublicKey; + failQuoteMint: PublicKey; + passAmm: PublicKey; + failAmm: PublicKey; + passLp: PublicKey; + failLp: PublicKey; + } { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const [question] = getQuestionAddr( + vaultProgramId, + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const [baseVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + baseMint, + ); + const [quoteVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + question, + quoteMint, + ); + + const [failBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 0, + ); + const [failQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 0, + ); + + const [passBaseMint] = getConditionalTokenMintAddr( + vaultProgramId, + baseVault, + 1, + ); + const [passQuoteMint] = getConditionalTokenMintAddr( + vaultProgramId, + quoteVault, + 1, + ); + + const [passAmm] = getAmmAddr( + this.ammClient.program.programId, + passBaseMint, + passQuoteMint, + ); + const [failAmm] = getAmmAddr( + this.ammClient.program.programId, + failBaseMint, + failQuoteMint, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + return { + question, + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + passAmm, + failAmm, + passLp, + failLp, + }; + } + + async initializeDao( + tokenMint: PublicKey, + tokenPriceUiAmount: number, + minBaseFutarchicLiquidity: number, + minQuoteFutarchicLiquidity: number, + usdcMint: PublicKey = MAINNET_USDC, + daoKeypair: Keypair = Keypair.generate(), + twapStartDelaySlots: BN, + ): Promise { + let tokenDecimals = unpackMint( + tokenMint, + await this.provider.connection.getAccountInfo(tokenMint), + ).decimals; + + let scaledPrice = PriceMath.getAmmPrice( + tokenPriceUiAmount, + tokenDecimals, + USDC_DECIMALS, + ); + + // console.log( + // PriceMath.getHumanPrice(scaledPrice, tokenDecimals, USDC_DECIMALS) + // ); + + await this.initializeDaoIx( + daoKeypair, + tokenMint, + { + twapStartDelaySlots, + twapInitialObservation: scaledPrice, + twapMaxObservationChangePerUpdate: scaledPrice.divn(50), + minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( + new BN(10).pow(new BN(USDC_DECIMALS)), + ), + minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( + new BN(10).pow(new BN(tokenDecimals)), + ), + passThresholdBps: null, + slotsPerProposal: null, + }, + usdcMint, + ) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 40_000, + }), + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: 1, + }), + ]) + .rpc({ maxRetries: 5 }); + + return daoKeypair.publicKey; + } + + initializeDaoIx( + daoKeypair: Keypair, + tokenMint: PublicKey, + params: InitializeDaoParams, + usdcMint: PublicKey = MAINNET_USDC, + ) { + return this.autocrat.methods + .initializeDao(params) + .accounts({ + dao: daoKeypair.publicKey, + tokenMint, + usdcMint, + }) + .signers([daoKeypair]); + } + + async initializeProposal( + dao: PublicKey, + descriptionUrl: string, + instruction: ProposalInstruction, + baseTokensToLP: BN, + quoteTokensToLP: BN, + ): Promise { + const storedDao = await this.getDao(dao); + + const nonce = new BN(Math.random() * 2 ** 50); + + let [proposal] = getProposalAddr( + this.autocrat.programId, + this.provider.publicKey, + nonce, + ); + + await this.vaultClient.initializeQuestion( + sha256(`Will ${proposal} pass?/FAIL/PASS`), + proposal, + 2, + ); + + const { + baseVault, + quoteVault, + passAmm, + failAmm, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + question, + } = this.getProposalPdas( + proposal, + storedDao.tokenMint, + storedDao.usdcMint, + dao, + ); + + // it's important that these happen in a single atomic transaction + await this.vaultClient + .initializeVaultIx(question, storedDao.tokenMint, 2) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.initializeVaultIx(question, storedDao.usdcMint, 2), + this.ammClient.initializeAmmIx( + passBaseMint, + passQuoteMint, + storedDao.twapStartDelaySlots, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + this.ammClient.initializeAmmIx( + failBaseMint, + failQuoteMint, + storedDao.twapStartDelaySlots, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + ), + ) + .rpc(); + + await this.vaultClient + .splitTokensIx( + question, + baseVault, + storedDao.tokenMint, + baseTokensToLP, + 2, + ) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.splitTokensIx( + question, + quoteVault, + storedDao.usdcMint, + quoteTokensToLP, + 2, + ), + ), + ) + .rpc(); + + await this.ammClient + .addLiquidityIx( + passAmm, + passBaseMint, + passQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ) + .postInstructions( + await InstructionUtils.getInstructions( + this.ammClient.addLiquidityIx( + failAmm, + failBaseMint, + failQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ), + ), + ) + .rpc(); + + // this is how many original tokens are created + const lpTokens = quoteTokensToLP; + + await this.initializeProposalIx( + descriptionUrl, + instruction, + dao, + storedDao.tokenMint, + storedDao.usdcMint, + lpTokens, + lpTokens, + nonce, + question, + ).rpc(); + + return proposal; + } + + // async createProposalTxAndPDAs( + // dao: PublicKey, + // descriptionUrl: string, + // instruction: ProposalInstruction, + // baseTokensToLP: BN, + // quoteTokensToLP: BN + // ): Promise< + // [ + // Transaction[], + // { + // proposalAcct: PublicKey; + // baseCondVaultAcct: PublicKey; + // quoteCondVaultAcct: PublicKey; + // passMarketAcct: PublicKey; + // failMarketAcct: PublicKey; + // } + // ] + // > { + // const storedDao = await this.getDao(dao); + + // const nonce = new BN(Math.random() * 2 ** 50); + + // let [proposal] = getProposalAddr( + // this.autocrat.programId, + // this.provider.publicKey, + // nonce + // ); + + // const { + // baseVault, + // quoteVault, + // passAmm, + // failAmm, + // passBaseMint, + // passQuoteMint, + // failBaseMint, + // failQuoteMint, + // } = this.getProposalPdas( + // proposal, + // storedDao.tokenMint, + // storedDao.usdcMint, + // dao + // ); + + // // it's important that these happen in a single atomic transaction + // const initVaultTx = await this.vaultClient + // .initializeVaultIx(proposal, storedDao.tokenMint) + // .postInstructions( + // await InstructionUtils.getInstructions( + // this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), + // this.ammClient.createAmmIx( + // passBaseMint, + // passQuoteMint, + // storedDao.twapInitialObservation, + // storedDao.twapMaxObservationChangePerUpdate + // ), + // this.ammClient.createAmmIx( + // failBaseMint, + // failQuoteMint, + // storedDao.twapInitialObservation, + // storedDao.twapMaxObservationChangePerUpdate + // ) + // ) + // ) + // .transaction(); + + // const mintConditionalTokensTx = await this.vaultClient + // .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) + // .postInstructions( + // await InstructionUtils.getInstructions( + // this.vaultClient.mintConditionalTokensIx( + // quoteVault, + // storedDao.usdcMint, + // quoteTokensToLP + // ) + // ) + // ) + // .transaction(); + + // const addLiquidityTx = await this.ammClient + // .addLiquidityIx( + // passAmm, + // passBaseMint, + // passQuoteMint, + // quoteTokensToLP, + // baseTokensToLP, + // new BN(0) + // ) + // .postInstructions( + // await InstructionUtils.getInstructions( + // this.ammClient.addLiquidityIx( + // failAmm, + // failBaseMint, + // failQuoteMint, + // quoteTokensToLP, + // baseTokensToLP, + // new BN(0) + // ) + // ) + // ) + // .transaction(); + + // // this is how many original tokens are created + // const lpTokens = quoteTokensToLP; + + // const initTx = await this.initializeProposalIx( + // descriptionUrl, + // instruction, + // dao, + // storedDao.tokenMint, + // storedDao.usdcMint, + // lpTokens, + // lpTokens, + // nonce, + // question + // ).transaction(); + + // return [ + // [initVaultTx, mintConditionalTokensTx, addLiquidityTx, initTx], + // { + // baseCondVaultAcct: baseVault, + // quoteCondVaultAcct: quoteVault, + // failMarketAcct: failAmm, + // passMarketAcct: passAmm, + // proposalAcct: proposal, + // }, + // ]; + // } + + initializeProposalIx( + descriptionUrl: string, + instruction: ProposalInstruction, + dao: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + passLpTokensToLock: BN, + failLpTokensToLock: BN, + nonce: BN, + question: PublicKey, + proposer: PublicKey = this.provider.publicKey, + ) { + let [proposal] = getProposalAddr(this.autocrat.programId, proposer, nonce); + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( + proposal, + baseMint, + quoteMint, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + const passLpVaultAccount = getAssociatedTokenAddressSync( + passLp, + daoTreasury, + true, + ); + const failLpVaultAccount = getAssociatedTokenAddressSync( + failLp, + daoTreasury, + true, + ); + + return this.autocrat.methods + .initializeProposal({ + descriptionUrl, + instruction, + passLpTokensToLock, + failLpTokensToLock, + nonce, + }) + .accounts({ + question, + proposal, + dao, + baseVault, + quoteVault, + passAmm, + failAmm, + passLpMint: passLp, + failLpMint: failLp, + passLpUserAccount: getAssociatedTokenAddressSync( + passLp, + proposer, + true, + ), + failLpUserAccount: getAssociatedTokenAddressSync( + failLp, + proposer, + true, + ), + passLpVaultAccount, + failLpVaultAccount, + proposer, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + proposer, + passLpVaultAccount, + daoTreasury, + passLp, + ), + createAssociatedTokenAccountIdempotentInstruction( + proposer, + failLpVaultAccount, + daoTreasury, + failLp, + ), + ]); + } + + async finalizeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + let storedDao = await this.getDao(storedProposal.dao); + + return this.finalizeProposalIx( + proposal, + storedProposal.instruction, + storedProposal.dao, + storedDao.tokenMint, + storedDao.usdcMint, + storedProposal.proposer, + ).rpc(); + } + + finalizeProposalIx( + proposal: PublicKey, + instruction: any, + dao: PublicKey, + daoToken: PublicKey, + usdc: PublicKey, + proposer: PublicKey, + ) { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const { question, passAmm, failAmm } = this.getProposalPdas( + proposal, + daoToken, + usdc, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); + + return this.autocrat.methods.finalizeProposal().accounts({ + proposal, + passAmm, + failAmm, + dao, + question, + // baseVault, + // quoteVault, + passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer, true), + failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer, true), + passLpVaultAccount: getAssociatedTokenAddressSync( + passLp, + daoTreasury, + true, + ), + failLpVaultAccount: getAssociatedTokenAddressSync( + failLp, + daoTreasury, + true, + ), + vaultProgram: this.vaultClient.vaultProgram.programId, + treasury: daoTreasury, + vaultEventAuthority, + }); + } + + async executeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + + return this.executeProposalIx( + proposal, + storedProposal.dao, + storedProposal.instruction, + ).rpc(); + } + + executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + return this.autocrat.methods + .executeProposal() + .accounts({ + proposal, + dao, + // daoTreasury, + }) + .remainingAccounts( + instruction.accounts + .concat({ + pubkey: instruction.programId, + isWritable: false, + isSigner: false, + }) + .map((meta: AccountMeta) => + meta.pubkey.equals(daoTreasury) + ? { ...meta, isSigner: false } + : meta, + ), + ); + } + + // cranks the TWAPs of multiple proposals' markets. there's a limit on the + // number of proposals you can pass in, which I can't determine rn because + // there aren't enough proposals on devnet + async crankProposalMarkets( + proposals: PublicKey[], + priorityFeeMicroLamports: number, + ) { + const amms: PublicKey[] = []; + + for (const proposal of proposals) { + const storedProposal = await this.getProposal(proposal); + amms.push(storedProposal.passAmm); + amms.push(storedProposal.failAmm); + } + + while (true) { + let ixs: TransactionInstruction[] = []; + + for (const amm of amms) { + ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); + } + + let tx = new Transaction(); + tx.add( + ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), + ); + tx.add( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: priorityFeeMicroLamports, + }), + ); + tx.add(...ixs); + try { + await this.provider.sendAndConfirm(tx); + } catch (err) { + console.log("err", err); + } + + await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds + } + } +} diff --git a/sdk2/src/autocrat/v0.4/index.ts b/sdk2/src/autocrat/v0.4/index.ts new file mode 100644 index 000000000..6e8fd3617 --- /dev/null +++ b/sdk2/src/autocrat/v0.4/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./AutocratClient.js"; diff --git a/sdk2/src/autocrat/v0.4/pda.ts b/sdk2/src/autocrat/v0.4/pda.ts new file mode 100644 index 000000000..07e8ed636 --- /dev/null +++ b/sdk2/src/autocrat/v0.4/pda.ts @@ -0,0 +1,26 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import BN from "bn.js"; +import { AUTOCRAT_V0_4_PROGRAM_ID } from "../../constants.js"; + +export const getDaoTreasuryAddr = ( + programId: PublicKey = AUTOCRAT_V0_4_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); +}; + +export const getProposalAddr = ( + programId: PublicKey = AUTOCRAT_V0_4_PROGRAM_ID, + proposer: PublicKey, + nonce: BN, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("proposal"), + proposer.toBuffer(), + nonce.toArrayLike(Buffer, "le", 8), + ], + programId, + ); +}; diff --git a/sdk2/src/autocrat/v0.4/types/autocrat.ts b/sdk2/src/autocrat/v0.4/types/autocrat.ts new file mode 100644 index 000000000..c1d8a3f89 --- /dev/null +++ b/sdk2/src/autocrat/v0.4/types/autocrat.ts @@ -0,0 +1,2013 @@ +export type Autocrat = { + version: "0.4.2"; + name: "autocrat"; + instructions: [ + { + name: "initializeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: false; + isSigner: false; + }, + { + name: "usdcMint"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeDaoParams"; + }; + }, + ]; + }, + { + name: "initializeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeProposalParams"; + }; + }, + ]; + }, + { + name: "finalizeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "treasury"; + isMut: false; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "executeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "treasury"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "daoParams"; + type: { + defined: "UpdateDaoParams"; + }; + }, + ]; + }, + ]; + accounts: [ + { + name: "dao"; + type: { + kind: "struct"; + fields: [ + { + name: "treasuryPdaBump"; + type: "u8"; + }, + { + name: "treasury"; + type: "publicKey"; + }, + { + name: "tokenMint"; + type: "publicKey"; + }, + { + name: "usdcMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "slotsPerProposal"; + type: "u64"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + docs: [ + "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", + ]; + type: "u64"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "proposal"; + type: { + kind: "struct"; + fields: [ + { + name: "number"; + type: "u32"; + }, + { + name: "proposer"; + type: "publicKey"; + }, + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "slotEnqueued"; + type: "u64"; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + }, + { + name: "instruction"; + type: { + defined: "ProposalInstruction"; + }; + }, + { + name: "passAmm"; + type: "publicKey"; + }, + { + name: "failAmm"; + type: "publicKey"; + }, + { + name: "baseVault"; + type: "publicKey"; + }, + { + name: "quoteVault"; + type: "publicKey"; + }, + { + name: "dao"; + type: "publicKey"; + }, + { + name: "passLpTokensLocked"; + type: "u64"; + }, + { + name: "failLpTokensLocked"; + type: "u64"; + }, + { + name: "nonce"; + docs: [ + "We need to include a per-proposer nonce to prevent some weird proposal", + "front-running edge cases. Using a `u64` means that proposers are unlikely", + "to run into collisions, even if they generate nonces randomly - I've run", + "the math :D", + ]; + type: "u64"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "question"; + type: "publicKey"; + }, + { + name: "durationInSlots"; + type: "u64"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + ]; + }; + }, + { + name: "InitializeDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySlots"; + type: "u64"; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "slotsPerProposal"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "InitializeProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "instruction"; + type: { + defined: "ProposalInstruction"; + }; + }, + { + name: "passLpTokensToLock"; + type: "u64"; + }, + { + name: "failLpTokensToLock"; + type: "u64"; + }, + { + name: "nonce"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "slotsPerProposal"; + type: { + option: "u64"; + }; + }, + { + name: "twapInitialObservation"; + type: { + option: "u128"; + }; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: { + option: "u128"; + }; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "minBaseFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "ProposalAccount"; + type: { + kind: "struct"; + fields: [ + { + name: "pubkey"; + type: "publicKey"; + }, + { + name: "isSigner"; + type: "bool"; + }, + { + name: "isWritable"; + type: "bool"; + }, + ]; + }; + }, + { + name: "ProposalInstruction"; + type: { + kind: "struct"; + fields: [ + { + name: "programId"; + type: "publicKey"; + }, + { + name: "accounts"; + type: { + vec: { + defined: "ProposalAccount"; + }; + }; + }, + { + name: "data"; + type: "bytes"; + }, + ]; + }; + }, + { + name: "ProposalState"; + type: { + kind: "enum"; + variants: [ + { + name: "Pending"; + }, + { + name: "Passed"; + }, + { + name: "Failed"; + }, + { + name: "Executed"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "InitializeDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "tokenMint"; + type: "publicKey"; + index: false; + }, + { + name: "usdcMint"; + type: "publicKey"; + index: false; + }, + { + name: "treasury"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "slotsPerProposal"; + type: "u64"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "UpdateDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "slotsPerProposal"; + type: "u64"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "InitializeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "quoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseVault"; + type: "publicKey"; + index: false; + }, + { + name: "passAmm"; + type: "publicKey"; + index: false; + }, + { + name: "failAmm"; + type: "publicKey"; + index: false; + }, + { + name: "passLpMint"; + type: "publicKey"; + index: false; + }, + { + name: "failLpMint"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "nonce"; + type: "u64"; + index: false; + }, + { + name: "number"; + type: "u32"; + index: false; + }, + { + name: "passLpTokensLocked"; + type: "u64"; + index: false; + }, + { + name: "failLpTokensLocked"; + type: "u64"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "instruction"; + type: { + defined: "ProposalInstruction"; + }; + index: false; + }, + { + name: "durationInSlots"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "FinalizeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "failMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "threshold"; + type: "u128"; + index: false; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + index: false; + }, + ]; + }, + { + name: "ExecuteProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AmmTooOld"; + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; + }, + { + code: 6001; + name: "InvalidInitialObservation"; + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; + }, + { + code: 6002; + name: "InvalidMaxObservationChange"; + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; + }, + { + code: 6003; + name: "InvalidStartDelaySlots"; + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; + }, + { + code: 6004; + name: "InvalidSettlementAuthority"; + msg: "One of the vaults has an invalid `settlement_authority`"; + }, + { + code: 6005; + name: "ProposalTooYoung"; + msg: "Proposal is too young to be executed or rejected"; + }, + { + code: 6006; + name: "MarketsTooYoung"; + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; + }, + { + code: 6007; + name: "ProposalAlreadyFinalized"; + msg: "This proposal has already been finalized"; + }, + { + code: 6008; + name: "InvalidVaultNonce"; + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; + }, + { + code: 6009; + name: "ProposalNotPassed"; + msg: "This proposal can't be executed because it isn't in the passed state"; + }, + { + code: 6010; + name: "InsufficientLpTokenBalance"; + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; + }, + { + code: 6011; + name: "InsufficientLpTokenLock"; + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; + }, + ]; +}; + +export const IDL: Autocrat = { + version: "0.4.2", + name: "autocrat", + instructions: [ + { + name: "initializeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMint", + isMut: false, + isSigner: false, + }, + { + name: "usdcMint", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeDaoParams", + }, + }, + ], + }, + { + name: "initializeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeProposalParams", + }, + }, + ], + }, + { + name: "finalizeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "treasury", + isMut: false, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "executeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "treasury", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "daoParams", + type: { + defined: "UpdateDaoParams", + }, + }, + ], + }, + ], + accounts: [ + { + name: "dao", + type: { + kind: "struct", + fields: [ + { + name: "treasuryPdaBump", + type: "u8", + }, + { + name: "treasury", + type: "publicKey", + }, + { + name: "tokenMint", + type: "publicKey", + }, + { + name: "usdcMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "slotsPerProposal", + type: "u64", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + docs: [ + "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", + ], + type: "u64", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + ], + }, + }, + { + name: "proposal", + type: { + kind: "struct", + fields: [ + { + name: "number", + type: "u32", + }, + { + name: "proposer", + type: "publicKey", + }, + { + name: "descriptionUrl", + type: "string", + }, + { + name: "slotEnqueued", + type: "u64", + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + }, + { + name: "instruction", + type: { + defined: "ProposalInstruction", + }, + }, + { + name: "passAmm", + type: "publicKey", + }, + { + name: "failAmm", + type: "publicKey", + }, + { + name: "baseVault", + type: "publicKey", + }, + { + name: "quoteVault", + type: "publicKey", + }, + { + name: "dao", + type: "publicKey", + }, + { + name: "passLpTokensLocked", + type: "u64", + }, + { + name: "failLpTokensLocked", + type: "u64", + }, + { + name: "nonce", + docs: [ + "We need to include a per-proposer nonce to prevent some weird proposal", + "front-running edge cases. Using a `u64` means that proposers are unlikely", + "to run into collisions, even if they generate nonces randomly - I've run", + "the math :D", + ], + type: "u64", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "question", + type: "publicKey", + }, + { + name: "durationInSlots", + type: "u64", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + ], + }, + }, + { + name: "InitializeDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySlots", + type: "u64", + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "slotsPerProposal", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "InitializeProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "descriptionUrl", + type: "string", + }, + { + name: "instruction", + type: { + defined: "ProposalInstruction", + }, + }, + { + name: "passLpTokensToLock", + type: "u64", + }, + { + name: "failLpTokensToLock", + type: "u64", + }, + { + name: "nonce", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "slotsPerProposal", + type: { + option: "u64", + }, + }, + { + name: "twapInitialObservation", + type: { + option: "u128", + }, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: { + option: "u128", + }, + }, + { + name: "minQuoteFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "minBaseFutarchicLiquidity", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "ProposalAccount", + type: { + kind: "struct", + fields: [ + { + name: "pubkey", + type: "publicKey", + }, + { + name: "isSigner", + type: "bool", + }, + { + name: "isWritable", + type: "bool", + }, + ], + }, + }, + { + name: "ProposalInstruction", + type: { + kind: "struct", + fields: [ + { + name: "programId", + type: "publicKey", + }, + { + name: "accounts", + type: { + vec: { + defined: "ProposalAccount", + }, + }, + }, + { + name: "data", + type: "bytes", + }, + ], + }, + }, + { + name: "ProposalState", + type: { + kind: "enum", + variants: [ + { + name: "Pending", + }, + { + name: "Passed", + }, + { + name: "Failed", + }, + { + name: "Executed", + }, + ], + }, + }, + ], + events: [ + { + name: "InitializeDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "tokenMint", + type: "publicKey", + index: false, + }, + { + name: "usdcMint", + type: "publicKey", + index: false, + }, + { + name: "treasury", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "slotsPerProposal", + type: "u64", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + ], + }, + { + name: "UpdateDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "slotsPerProposal", + type: "u64", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + ], + }, + { + name: "InitializeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "quoteVault", + type: "publicKey", + index: false, + }, + { + name: "baseVault", + type: "publicKey", + index: false, + }, + { + name: "passAmm", + type: "publicKey", + index: false, + }, + { + name: "failAmm", + type: "publicKey", + index: false, + }, + { + name: "passLpMint", + type: "publicKey", + index: false, + }, + { + name: "failLpMint", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "nonce", + type: "u64", + index: false, + }, + { + name: "number", + type: "u32", + index: false, + }, + { + name: "passLpTokensLocked", + type: "u64", + index: false, + }, + { + name: "failLpTokensLocked", + type: "u64", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "instruction", + type: { + defined: "ProposalInstruction", + }, + index: false, + }, + { + name: "durationInSlots", + type: "u64", + index: false, + }, + ], + }, + { + name: "FinalizeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passMarketTwap", + type: "u128", + index: false, + }, + { + name: "failMarketTwap", + type: "u128", + index: false, + }, + { + name: "threshold", + type: "u128", + index: false, + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + index: false, + }, + ], + }, + { + name: "ExecuteProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AmmTooOld", + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", + }, + { + code: 6001, + name: "InvalidInitialObservation", + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", + }, + { + code: 6002, + name: "InvalidMaxObservationChange", + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", + }, + { + code: 6003, + name: "InvalidStartDelaySlots", + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", + }, + { + code: 6004, + name: "InvalidSettlementAuthority", + msg: "One of the vaults has an invalid `settlement_authority`", + }, + { + code: 6005, + name: "ProposalTooYoung", + msg: "Proposal is too young to be executed or rejected", + }, + { + code: 6006, + name: "MarketsTooYoung", + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", + }, + { + code: 6007, + name: "ProposalAlreadyFinalized", + msg: "This proposal has already been finalized", + }, + { + code: 6008, + name: "InvalidVaultNonce", + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", + }, + { + code: 6009, + name: "ProposalNotPassed", + msg: "This proposal can't be executed because it isn't in the passed state", + }, + { + code: 6010, + name: "InsufficientLpTokenBalance", + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", + }, + { + code: 6011, + name: "InsufficientLpTokenLock", + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", + }, + ], +}; diff --git a/sdk2/src/autocrat/v0.4/types/index.ts b/sdk2/src/autocrat/v0.4/types/index.ts new file mode 100644 index 000000000..8cc574a57 --- /dev/null +++ b/sdk2/src/autocrat/v0.4/types/index.ts @@ -0,0 +1,29 @@ +import { Autocrat as AutocratProgram, IDL as AutocratIDL } from "./autocrat.js"; +export { AutocratProgram, AutocratIDL }; + +import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; + +export type InitializeDaoParams = + IdlTypes["InitializeDaoParams"]; +export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; +export type ProposalInstruction = + IdlTypes["ProposalInstruction"]; + +export type Dao = IdlAccounts["dao"]; +export type Proposal = IdlAccounts["proposal"]; + +export type InitializeDaoEvent = + IdlEvents["InitializeDaoEvent"]; +export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; +export type InitializeProposalEvent = + IdlEvents["InitializeProposalEvent"]; +export type FinalizeProposalEvent = + IdlEvents["FinalizeProposalEvent"]; +export type ExecuteProposalEvent = + IdlEvents["ExecuteProposalEvent"]; +export type AutocratEvent = + | InitializeDaoEvent + | UpdateDaoEvent + | InitializeProposalEvent + | FinalizeProposalEvent + | ExecuteProposalEvent; diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index ae1a653d5..9aebc0669 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -2,6 +2,16 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; import { BN } from "bn.js"; +export const AUTOCRAT_V0_4_PROGRAM_ID = new PublicKey( + "autowMzCbM29YXMgVG3T62Hkgo7RcyrvgQQkd54fDQL", +); +export const AMM_V0_4_PROGRAM_ID = new PublicKey( + "AMMyu265tkBpRW21iGQxKGLaves3gKm2JcMUqfXNSpqD", +); +export const LAUNCHPAD_V0_4_PROGRAM_ID = new PublicKey( + "AfJJJ5UqxhBKoE3grkKAZZsoXDE9kncbMKvqSHGsCNrE", +); + export const AUTOCRAT_V0_5_PROGRAM_ID = new PublicKey( "auToUr3CQza3D4qreT6Std2MTomfzvrEeCC5qh7ivW5", ); diff --git a/sdk2/src/launchpad/v0.4/LaunchpadClient.ts b/sdk2/src/launchpad/v0.4/LaunchpadClient.ts new file mode 100644 index 000000000..e8e71dab6 --- /dev/null +++ b/sdk2/src/launchpad/v0.4/LaunchpadClient.ts @@ -0,0 +1,410 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + PublicKey, + Keypair, + AccountInfo, + ComputeBudgetProgram, +} from "@solana/web3.js"; +import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; +import { + LAUNCHPAD_V0_4_PROGRAM_ID, + RAYDIUM_AUTHORITY, + LOW_FEE_RAYDIUM_CONFIG, + RAYDIUM_CP_SWAP_PROGRAM_ID, + RAYDIUM_CREATE_POOL_FEE_RECEIVE, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_AUTHORITY, + DEVNET_LOW_FEE_RAYDIUM_CONFIG, + DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, + DEVNET_USDC, +} from "../../constants.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { FundingRecord, Launch } from "./types/index.js"; +import { + getFundingRecordAddr, + getLaunchAddr, + getLaunchDaoAddr, + getLaunchSignerAddr, + getLiquidityPoolAddr, + getRaydiumCpmmLpMintAddr, +} from "./pda.js"; +import { getDaoTreasuryAddr } from "../../autocrat/v0.4/pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; +import { AutocratClient } from "../../autocrat/v0.4/AutocratClient.js"; +import * as anchor from "@coral-xyz/anchor"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + public autocratClient: AutocratClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + this.launchpad = new Program( + LaunchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_4_PROGRAM_ID, + this.provider, + ); + this.autocratClient = AutocratClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + ammProgramId: params.ammProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord( + fundingRecord: PublicKey, + ): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable( + fundingRecord, + ); + } + + async deserializeFundingRecord( + accountInfo: AccountInfo, + ): Promise { + return this.launchpad.coder.accounts.decode( + "fundingRecord", + accountInfo.data, + ); + } + + initializeLaunchIx( + tokenName: string, + tokenSymbol: string, + tokenUri: string, + minimumRaiseAmount: BN, + secondsForLaunch: number, + tokenMint: PublicKey, + launchAuthority: PublicKey = this.provider.publicKey, + isDevnet: boolean = false, + payer: PublicKey = this.provider.publicKey, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + + const [launch] = getLaunchAddr(this.launchpad.programId, tokenMint); + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const usdcVault = getAssociatedTokenAddressSync(USDC, launchSigner, true); + + const tokenVault = getAssociatedTokenAddressSync( + tokenMint, + launchSigner, + true, + ); + const [tokenMetadata] = getMetadataAddr(tokenMint); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, + tokenSymbol, + tokenUri, + }) + .accounts({ + launch, + launchSigner, + usdcVault, + tokenVault, + launchAuthority, + usdcMint: USDC, + tokenMint, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(USDC, launchSigner, true), + launchSigner, + USDC, + ), + ]); + // .signers([tokenMintKp]); + } + + startLaunchIx( + launch: PublicKey, + launchAuthority: PublicKey = this.provider.publicKey, + ) { + return this.launchpad.methods.startLaunch().accounts({ + launch, + launchAuthority, + }); + } + + fundIx( + launch: PublicKey, + amount: BN, + funder: PublicKey = this.provider.publicKey, + isDevnet: boolean = false, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const launchUsdcVault = getAssociatedTokenAddressSync( + USDC, + launchSigner, + true, + ); + const funderUsdcAccount = getAssociatedTokenAddressSync(USDC, funder, true); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods.fund(amount).accounts({ + launch, + launchUsdcVault, + fundingRecord, + funder, + funderUsdcAccount, + launchSigner, + }); + } + + completeLaunchIx( + launch: PublicKey, + tokenMint: PublicKey, + isDevnet: boolean = false, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const launchUsdcVault = getAssociatedTokenAddressSync( + USDC, + launchSigner, + true, + ); + const launchTokenVault = getAssociatedTokenAddressSync( + tokenMint, + launchSigner, + true, + ); + + // const daoKp = Keypair.generate(); + const [dao] = getLaunchDaoAddr(this.launchpad.programId, launch); + const [daoTreasury] = getDaoTreasuryAddr( + this.autocratClient.getProgramId(), + dao, + ); + const treasuryUsdcAccount = getAssociatedTokenAddressSync( + USDC, + daoTreasury, + true, + ); + + const [poolState] = getLiquidityPoolAddr(this.launchpad.programId, dao); + + const cpSwapProgramId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + + const [lpMint] = getRaydiumCpmmLpMintAddr(poolState, isDevnet); + + const lpVault = getAssociatedTokenAddressSync(lpMint, launchSigner, true); + + const [poolTokenVault] = PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("pool_vault"), + poolState.toBuffer(), + tokenMint.toBuffer(), + ], + cpSwapProgramId, + ); + + const [poolUsdcVault] = PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("pool_vault"), + poolState.toBuffer(), + USDC.toBuffer(), + ], + cpSwapProgramId, + ); + + const [observationState] = PublicKey.findProgramAddressSync( + [anchor.utils.bytes.utf8.encode("observation"), poolState.toBuffer()], + cpSwapProgramId, + ); + + const [autocratEventAuthority] = getEventAuthorityAddr( + this.autocratClient.getProgramId(), + ); + + const [tokenMetadata] = getMetadataAddr(tokenMint); + + return this.launchpad.methods + .completeLaunch() + .accounts({ + launch, + launchSigner, + launchUsdcVault, + launchTokenVault, + dao, + daoTreasury, + treasuryUsdcAccount, + treasuryLpAccount: getAssociatedTokenAddressSync( + lpMint, + daoTreasury, + true, + ), + usdcMint: USDC, + tokenMint, + tokenMetadata, + lpMint, + lpVault, + poolTokenVault, + poolUsdcVault, + poolState, + observationState, + cpSwapProgram: cpSwapProgramId, + authority: isDevnet ? DEVNET_RAYDIUM_AUTHORITY : RAYDIUM_AUTHORITY, + ammConfig: isDevnet + ? DEVNET_LOW_FEE_RAYDIUM_CONFIG + : LOW_FEE_RAYDIUM_CONFIG, + createPoolFee: isDevnet + ? DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE + : RAYDIUM_CREATE_POOL_FEE_RECEIVE, + autocratProgram: this.autocratClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + autocratEventAuthority, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + treasuryUsdcAccount, + daoTreasury, + USDC, + ), + ]); + } + + refundIx( + launch: PublicKey, + funder: PublicKey = this.provider.publicKey, + isDevnet: boolean = false, + ) { + const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; + + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + const launchUsdcVault = getAssociatedTokenAddressSync( + USDC, + launchSigner, + true, + ); + const funderUsdcAccount = getAssociatedTokenAddressSync(USDC, funder, true); + + return this.launchpad.methods.refund().accounts({ + launch, + launchSigner, + launchUsdcVault, + funder, + funderUsdcAccount, + fundingRecord, + }); + } + + claimIx( + launch: PublicKey, + tokenMint: PublicKey, + funder: PublicKey = this.provider.publicKey, + ) { + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods + .claim() + .accounts({ + launch, + fundingRecord, + launchSigner, + funder, + funderTokenAccount: getAssociatedTokenAddressSync( + tokenMint, + funder, + true, + ), + tokenMint, + launchTokenVault: getAssociatedTokenAddressSync( + tokenMint, + launchSigner, + true, + ), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(tokenMint, funder, true), + funder, + tokenMint, + ), + ]); + } +} diff --git a/sdk2/src/launchpad/v0.4/index.ts b/sdk2/src/launchpad/v0.4/index.ts new file mode 100644 index 000000000..b5b9717d0 --- /dev/null +++ b/sdk2/src/launchpad/v0.4/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./LaunchpadClient.js"; diff --git a/sdk2/src/launchpad/v0.4/pda.ts b/sdk2/src/launchpad/v0.4/pda.ts new file mode 100644 index 000000000..3e5b9a370 --- /dev/null +++ b/sdk2/src/launchpad/v0.4/pda.ts @@ -0,0 +1,71 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { + LAUNCHPAD_V0_4_PROGRAM_ID, + RAYDIUM_CP_SWAP_PROGRAM_ID, + DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, +} from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_4_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_4_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_4_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; + +export const getLaunchDaoAddr = ( + programId: PublicKey = LAUNCHPAD_V0_4_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_dao"), launch.toBuffer()], + programId, + ); +}; + +export const getLiquidityPoolAddr = ( + programId: PublicKey = LAUNCHPAD_V0_4_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_state"), dao.toBuffer()], + programId, + ); +}; + +export const getRaydiumCpmmLpMintAddr = ( + poolState: PublicKey, + isDevnet: boolean, +): [PublicKey, number] => { + const programId = isDevnet + ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID + : RAYDIUM_CP_SWAP_PROGRAM_ID; + return PublicKey.findProgramAddressSync( + [Buffer.from("pool_lp_mint"), poolState.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/launchpad/v0.4/types/index.ts b/sdk2/src/launchpad/v0.4/types/index.ts new file mode 100644 index 000000000..8ee0e3354 --- /dev/null +++ b/sdk2/src/launchpad/v0.4/types/index.ts @@ -0,0 +1,29 @@ +import { + Launchpad as LaunchpadProgram, + IDL as LaunchpadIDL, +} from "./launchpad.js"; +export { LaunchpadProgram, LaunchpadIDL }; + +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +export type Launch = IdlAccounts["launch"]; +export type FundingRecord = IdlAccounts["fundingRecord"]; + +export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; +export type LaunchCompletedEvent = + IdlEvents["LaunchCompletedEvent"]; +export type LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type LaunchpadEvent = + | LaunchClaimEvent + | LaunchCompletedEvent + | LaunchFundedEvent + | LaunchInitializedEvent + | LaunchRefundedEvent + | LaunchStartedEvent; diff --git a/sdk2/src/launchpad/v0.4/types/launchpad.ts b/sdk2/src/launchpad/v0.4/types/launchpad.ts new file mode 100644 index 000000000..50a6f63aa --- /dev/null +++ b/sdk2/src/launchpad/v0.4/types/launchpad.ts @@ -0,0 +1,1999 @@ +export type Launchpad = { + version: "0.4.1"; + name: "launchpad"; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "usdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "usdcMint"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchUsdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderUsdcAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "completeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: false; + }, + { + name: "launchUsdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchTokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryUsdcAccount"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammConfig"; + isMut: true; + isSigner: false; + docs: [ + "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", + ]; + }, + { + name: "poolState"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "usdcMint"; + isMut: false; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "lpVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolTokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolUsdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "createPoolFee"; + isMut: true; + isSigner: false; + docs: ["create pool fee account"]; + }, + { + name: "observationState"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoTreasury"; + isMut: false; + isSigner: false; + }, + { + name: "cpSwapProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchUsdcVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: true; + isSigner: true; + }, + { + name: "funderUsdcAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "launchTokenVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this funding record. Useful for sorting events.", + ]; + type: "u64"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchUsdcVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchTokenVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "tokenMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "usdcMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: "i64"; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoTreasury"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "tokenMint"; + type: "publicKey"; + index: false; + }, + { + name: "usdcMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "fundingRecordSeqNum"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidTokenKey"; + msg: "Token mint key must end in 'meta'"; + }, + { + code: 6005; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6006; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6007; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6008; + name: "LaunchNotRefunding"; + msg: "Launch needs to be in refunding state to get a refund"; + }, + { + code: 6009; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6010; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + ]; +}; + +export const IDL: Launchpad = { + version: "0.4.1", + name: "launchpad", + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "tokenMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "usdcVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "usdcMint", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchUsdcVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderUsdcAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "completeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: false, + }, + { + name: "launchUsdcVault", + isMut: true, + isSigner: false, + }, + { + name: "launchTokenVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryUsdcAccount", + isMut: true, + isSigner: false, + }, + { + name: "treasuryLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammConfig", + isMut: true, + isSigner: false, + docs: [ + "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", + ], + }, + { + name: "poolState", + isMut: true, + isSigner: false, + }, + { + name: "tokenMint", + isMut: true, + isSigner: false, + }, + { + name: "usdcMint", + isMut: false, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "lpVault", + isMut: true, + isSigner: false, + }, + { + name: "poolTokenVault", + isMut: true, + isSigner: false, + }, + { + name: "poolUsdcVault", + isMut: true, + isSigner: false, + }, + { + name: "createPoolFee", + isMut: true, + isSigner: false, + docs: ["create pool fee account"], + }, + { + name: "observationState", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoTreasury", + isMut: false, + isSigner: false, + }, + { + name: "cpSwapProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchUsdcVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: true, + isSigner: true, + }, + { + name: "funderUsdcAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "tokenMint", + isMut: true, + isSigner: false, + }, + { + name: "launchTokenVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "seqNum", + docs: [ + "The sequence number of this funding record. Useful for sorting events.", + ], + type: "u64", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchUsdcVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchTokenVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "tokenMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "usdcMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: "i64", + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoTreasury", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "tokenMint", + type: "publicKey", + index: false, + }, + { + name: "usdcMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "fundingRecordSeqNum", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidTokenKey", + msg: "Token mint key must end in 'meta'", + }, + { + code: 6005, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6006, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6007, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6008, + name: "LaunchNotRefunding", + msg: "Launch needs to be in refunding state to get a refund", + }, + { + code: 6009, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6010, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + ], +}; From 470bd44bdeacf4ab58bcd81005a8b88e74908162 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 7 Apr 2026 18:55:12 +0200 Subject: [PATCH 036/100] update all new functionality to sdk v2 --- rebuild.sh | 4 +- sdk2/src/futarchy/v0.6/FutarchyClient.ts | 10 +- sdk2/src/launchpad/v0.7/LaunchpadClient.ts | 15 ++ sdk2/src/launchpad/v0.7/types/launchpad_v7.ts | 154 ++++++++++++++++++ tests/launchpad_v7/unit/extendLaunch.test.ts | 2 +- 5 files changed, 174 insertions(+), 11 deletions(-) diff --git a/rebuild.sh b/rebuild.sh index d718528a0..62aa77721 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -3,11 +3,13 @@ set -e anchor build cd sdk +yarn install yarn build-local cd .. cd sdk2 -yarn install --force +yarn install yarn build-local cd .. +yarn install --force yarn lint:fix echo "✅ SDK types synced successfully" \ No newline at end of file diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk2/src/futarchy/v0.6/FutarchyClient.ts index a800cc05d..9a56bab74 100644 --- a/sdk2/src/futarchy/v0.6/FutarchyClient.ts +++ b/sdk2/src/futarchy/v0.6/FutarchyClient.ts @@ -567,15 +567,7 @@ export class FutarchyClient { this.vaultClient.vaultProgram.programId, )[0], question, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(outputMint, trader, true), - trader, - outputMint, - ), - ]); + }); } squadsProposalCreateTx({ diff --git a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts index d23398eef..51da373e5 100644 --- a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts @@ -705,6 +705,21 @@ export class LaunchpadClient { }); } + extendLaunchIx({ + launch, + durationSeconds, + admin = METADAO_MULTISIG_VAULT, + }: { + launch: PublicKey; + durationSeconds: number; + admin?: PublicKey; + }) { + return this.launchpad.methods.extendLaunch({ durationSeconds }).accounts({ + launch, + admin, + }); + } + getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { return getLaunchAddr(this.launchpad.programId, baseMint)[0]; } diff --git a/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts b/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts index fb82a3b6e..e5b1bf7e9 100644 --- a/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts +++ b/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts @@ -808,6 +808,39 @@ export type LaunchpadV7 = { ]; args: []; }, + { + name: "extendLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ExtendLaunchArgs"; + }; + }, + ]; + }, ]; accounts: [ { @@ -1358,6 +1391,18 @@ export type LaunchpadV7 = { ]; }; }, + { + name: "ExtendLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "durationSeconds"; + type: "u32"; + }, + ]; + }; + }, { name: "InitializeLaunchArgs"; type: { @@ -1873,6 +1918,33 @@ export type LaunchpadV7 = { }, ]; }, + { + name: "LaunchExtendedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "oldSecondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "newSecondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, ]; errors: [ { @@ -2030,6 +2102,11 @@ export type LaunchpadV7 = { name: "InvalidAccumulatorActivationDelaySeconds"; msg: "Accumulator activation delay must be less than the launch duration"; }, + { + code: 6031; + name: "ExtendDurationExceedsMax"; + msg: "The extend duration would exceed the maximum allowed launch duration"; + }, ]; }; @@ -2843,6 +2920,39 @@ export const IDL: LaunchpadV7 = { ], args: [], }, + { + name: "extendLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ExtendLaunchArgs", + }, + }, + ], + }, ], accounts: [ { @@ -3393,6 +3503,18 @@ export const IDL: LaunchpadV7 = { ], }, }, + { + name: "ExtendLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "durationSeconds", + type: "u32", + }, + ], + }, + }, { name: "InitializeLaunchArgs", type: { @@ -3908,6 +4030,33 @@ export const IDL: LaunchpadV7 = { }, ], }, + { + name: "LaunchExtendedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "oldSecondsForLaunch", + type: "u32", + index: false, + }, + { + name: "newSecondsForLaunch", + type: "u32", + index: false, + }, + ], + }, ], errors: [ { @@ -4065,5 +4214,10 @@ export const IDL: LaunchpadV7 = { name: "InvalidAccumulatorActivationDelaySeconds", msg: "Accumulator activation delay must be less than the launch duration", }, + { + code: 6031, + name: "ExtendDurationExceedsMax", + msg: "The extend duration would exceed the maximum allowed launch duration", + }, ], }; diff --git a/tests/launchpad_v7/unit/extendLaunch.test.ts b/tests/launchpad_v7/unit/extendLaunch.test.ts index 7b0490c09..a24069a56 100644 --- a/tests/launchpad_v7/unit/extendLaunch.test.ts +++ b/tests/launchpad_v7/unit/extendLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; From d708284d52fd2322cf8454f3f6b26312d43a9399 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 9 Apr 2026 23:26:52 +0200 Subject: [PATCH 037/100] init launchpad v8 --- Anchor.toml | 1 + Cargo.lock | 19 + programs/v08_launchpad/Cargo.toml | 34 + programs/v08_launchpad/Xargo.toml | 2 + programs/v08_launchpad/src/allocator.rs | 136 ++ programs/v08_launchpad/src/lib.rs | 62 + vibes/launchpad_v8.md | 260 ++++ vibes/launchpad_v8_spec.md | 1819 +++++++++++++++++++++++ vibes/task-template.md | 54 + vibes/tasks.md | 246 +++ 10 files changed, 2633 insertions(+) create mode 100644 programs/v08_launchpad/Cargo.toml create mode 100644 programs/v08_launchpad/Xargo.toml create mode 100644 programs/v08_launchpad/src/allocator.rs create mode 100644 programs/v08_launchpad/src/lib.rs create mode 100644 vibes/launchpad_v8.md create mode 100644 vibes/launchpad_v8_spec.md create mode 100644 vibes/task-template.md create mode 100644 vibes/tasks.md diff --git a/Anchor.toml b/Anchor.toml index 5d83318db..fe0a7916d 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -11,6 +11,7 @@ conditional_vault = "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg" futarchy = "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq" launchpad = "MooNyh4CBUYEKyXVnjGYQ8mEiJDpGvJMdvrZx1iGeHV" launchpad_v7 = "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM" +launchpad_v8 = "MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg" liquidation = "LiQnowFbFQdYyZhF4pUbpsrZCjxRTQ1upKJxZ2VXjde" mint_governor = "gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH" performance_package_v2 = "pPV2pfrxnmstSb9j7kEeCLny5BGj6SNwCWGd6xbGGzz" diff --git a/Cargo.lock b/Cargo.lock index 99592050d..0bb4c0218 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1185,6 +1185,25 @@ dependencies = [ "squads-multisig-program", ] +[[package]] +name = "launchpad_v8" +version = "0.8.0" +dependencies = [ + "ahash 0.8.6", + "anchor-lang", + "anchor-spl", + "bid_wall", + "damm_v2_cpi", + "futarchy", + "mint_governor", + "performance_package_v2", + "solana-program", + "solana-security-txt", + "spl-memo", + "spl-token", + "squads-multisig-program", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/programs/v08_launchpad/Cargo.toml b/programs/v08_launchpad/Cargo.toml new file mode 100644 index 000000000..d2f0d277f --- /dev/null +++ b/programs/v08_launchpad/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "launchpad_v8" +version = "0.8.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "launchpad_v8" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = ["custom-heap"] +devnet = [] +production = [] +custom-heap = [] + +[dependencies] +anchor-lang = { version = "0.29.0", features = ["init-if-needed", "event-cpi"] } +anchor-spl = "0.29.0" +futarchy = { path = "../futarchy", features = ["cpi"] } +performance_package_v2 = { path = "../performance_package_v2", features = ["cpi"] } +mint_governor = { path = "../mint_governor", features = ["cpi"] } +spl-memo = "=4.0.0" +solana-program = "=1.17.14" +spl-token = "=4.0.0" +ahash = "=0.8.6" +solana-security-txt = "1.1.1" +squads-multisig-program = { git = "https://github.com/Squads-Protocol/v4", package = "squads-multisig-program", rev = "6d5235da621a2e9b7379ea358e48760e981053be", features = ["cpi"] } +damm_v2_cpi = { path = "../damm_v2_cpi", features = ["cpi"] } +bid_wall = { path = "../bid_wall", features = ["cpi"] } diff --git a/programs/v08_launchpad/Xargo.toml b/programs/v08_launchpad/Xargo.toml new file mode 100644 index 000000000..475fb71ed --- /dev/null +++ b/programs/v08_launchpad/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/programs/v08_launchpad/src/allocator.rs b/programs/v08_launchpad/src/allocator.rs new file mode 100644 index 000000000..88fdc88fb --- /dev/null +++ b/programs/v08_launchpad/src/allocator.rs @@ -0,0 +1,136 @@ +// THIS COMES DIRECTLY FROM SQUADS V4, WHICH HAS BEEN AUDITED 10 TIMES: +// https://github.com/Squads-Protocol/v4/blob/8a5642853b3dda9817477c9b540d0f84d67ede13/programs/squads_multisig_program/src/allocator.rs#L1 + +/* +Optimizing Bump Heap Allocation + +Objective: Increase available heap memory while maintaining flexibility in program invocation. + +1. Initial State: Default 32 KiB Heap + +Memory Layout: +0x300000000 0x300008000 + | | + v v + [--------------------] + ^ ^ + | | + VM Lower VM Upper + Boundary Boundary + +Default Allocator (Allocates Backwards / Top Down) (Default 32 KiB): +0x300000000 0x300008000 + | | + [--------------------] + ^ + | + Allocation starts here (SAFE) + +2. Naive Approach: Increase HEAP_LENGTH to 8 * 32 KiB + Default Allocator + +Memory Layout with Increased HEAP_LENGTH: +0x300000000 0x300008000 0x300040000 + | | | + v v v + [--------------------|------------------------------------|] + ^ ^ ^ + | | | + VM Lower VM Upper Allocation starts here + Boundary Boundary (ACCESS VIOLATION!) + +Issue: Access violation occurs without requestHeapFrame, requiring it for every transaction. + +3. Optimized Solution: Forward Allocation with Flexible Heap Usage + +Memory Layout (Same as Naive Approach): +0x300000000 0x300008000 0x300040000 + | | | + v v v + [--------------------|------------------------------------|] + ^ ^ ^ + | | | + VM Lower VM Upper Allocator & VM + Boundary Boundary Heap Limit + +Forward Allocator Behavior: + +a) Without requestHeapFrame: +0x300000000 0x300008000 + | | + [--------------------] + ^ ^ + | | + VM Lower VM Upper + Boundary Boundary + Allocation + starts here (SAFE) + +b) With requestHeapFrame: +0x300000000 0x300008000 0x300040000 + | | | + [--------------------|------------------------------------|] + ^ ^ ^ + | | | + VM Lower | VM Upper + Boundary Boundary + Allocation Allocation continues Maximum allocation + starts here with requestHeapFrame with requestHeapFrame +(SAFE) + +Key Advantages: +1. Compatibility: Functions without requestHeapFrame for allocations ≤32 KiB. +2. Extensibility: Supports larger allocations when requestHeapFrame is invoked. +3. Efficiency: Eliminates mandatory requestHeapFrame calls for all transactions. + +Conclusion: +The forward allocation strategy offers a robust solution, providing both backward +compatibility for smaller heap requirements and the flexibility to utilize extended +heap space when necessary. + +The following allocator is a copy of the bump allocator found in +solana_program::entrypoint and +https://github.com/solana-labs/solana-program-library/blob/master/examples/rust/custom-heap/src/entrypoint.rs + +but with changes to its HEAP_LENGTH and its +starting allocation address. +*/ + +use solana_program::entrypoint::HEAP_START_ADDRESS; +use std::{alloc::Layout, mem::size_of, ptr::null_mut}; + +/// Length of the memory region used for program heap. +pub const HEAP_LENGTH: usize = 8 * 32 * 1024; + +struct BumpAllocator; + +unsafe impl std::alloc::GlobalAlloc for BumpAllocator { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + const POS_PTR: *mut usize = HEAP_START_ADDRESS as *mut usize; + const TOP_ADDRESS: usize = HEAP_START_ADDRESS as usize + HEAP_LENGTH; + const BOTTOM_ADDRESS: usize = HEAP_START_ADDRESS as usize + size_of::<*mut u8>(); + let mut pos = *POS_PTR; + if pos == 0 { + // First time, set starting position to bottom address + pos = BOTTOM_ADDRESS; + } + // Align the position upwards + pos = (pos + layout.align() - 1) & !(layout.align() - 1); + let next_pos = pos.saturating_add(layout.size()); + if next_pos > TOP_ADDRESS { + return null_mut(); + } + *POS_PTR = next_pos; + pos as *mut u8 + } + + #[inline] + unsafe fn dealloc(&self, _: *mut u8, _: Layout) { + // I'm a bump allocator, I don't free + } +} + +// Only use the allocator if we're not in a no-entrypoint context +#[cfg(not(feature = "no-entrypoint"))] +#[global_allocator] +static A: BumpAllocator = BumpAllocator; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs new file mode 100644 index 000000000..57edb826f --- /dev/null +++ b/programs/v08_launchpad/src/lib.rs @@ -0,0 +1,62 @@ +//! A smart contract that facilitates the creation of new futarchic DAOs. +use anchor_lang::prelude::*; + +pub mod allocator; + +#[cfg(not(feature = "no-entrypoint"))] +use solana_security_txt::security_txt; + +#[cfg(not(feature = "no-entrypoint"))] +security_txt! { + name: "launchpad_v8", + project_url: "https://metadao.fi", + contacts: "telegram:metaproph3t,telegram:kollan_house", + source_code: "https://github.com/metaDAOproject/programs", + source_release: "v0.8.0", + policy: "The market will decide whether we pay a bug bounty.", + acknowledgements: "DCF = (CF1 / (1 + r)^1) + (CF2 / (1 + r)^2) + ... (CFn / (1 + r)^n)" +} + +declare_id!("MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg"); + +pub const TOKEN_SCALE: u64 = 1_000_000; + +pub const PRICE_SCALE: u128 = 1_000_000_000_000; + +/// 10M tokens with 6 decimals +pub const TOKENS_TO_PARTICIPANTS: u64 = 10_000_000 * TOKEN_SCALE; +/// 20% to liquidity +pub const TOKENS_TO_FUTARCHY_LIQUIDITY: u64 = 2_000_000 * TOKEN_SCALE; +/// 3M tokens to single-sided DammV2 liquidity +pub const TOKENS_TO_DAMM_V2_LIQUIDITY: u64 = TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED * TOKEN_SCALE; +/// we need this to prevent overflow +pub const TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED: u64 = 900_000; +/// 15% of the floating supply to stake +pub const PROPOSAL_MIN_STAKE_TOKENS: u64 = 1_500_000 * TOKEN_SCALE; + +// PP v2 tranche config +pub const PP_NUM_TRANCHES: usize = 5; +pub const PP_PRICE_MULTIPLIERS: [u128; 5] = [2, 4, 8, 16, 32]; + +// FutarchyTwap min_duration: 3 months +pub const PP_TWAP_MIN_DURATION: u32 = 3 * 30 * 24 * 60 * 60; // 7_776_000 seconds + +pub mod usdc_mint { + use anchor_lang::prelude::declare_id; + + #[cfg(feature = "devnet")] + declare_id!("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"); + + #[cfg(not(feature = "devnet"))] + declare_id!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); +} + +pub mod metadao_multisig_vault { + use anchor_lang::prelude::declare_id; + + // MetaDAO operations multisig vault + declare_id!("6awyHMshBGVjJ3ozdSJdyyDE1CTAXUwrpNMaRGMsb4sf"); +} + +#[program] +pub mod launchpad_v8 {} diff --git a/vibes/launchpad_v8.md b/vibes/launchpad_v8.md new file mode 100644 index 000000000..7cc99a139 --- /dev/null +++ b/vibes/launchpad_v8.md @@ -0,0 +1,260 @@ +# Launchpad v8 Design Document + +## Overview + +Launchpad v8 is the next iteration of the launch program. The two key architectural changes are: + +1. **Mint Governor integration** — instead of transferring raw mint authority to the DAO on completion, the launchpad sets up a `MintGovernor` that provides structured, delegated minting +2. **Performance Package v2** — instead of pre-minting team tokens into a locked vault, tokens are minted on demand via `mint_governor` when milestones are achieved + +These changes shift the token model from **fixed supply at launch** to **structured dilution over time**, giving the DAO fine-grained control over who can mint and how much. + +--- + +## What Changes from v7 + +### v7 Token Flow (current) + +``` +initialize_launch: + mint ALL tokens upfront → + participants (10M) + futarchy_liq (2M) + damm_liq (900K) + + performance_package + additional_tokens + +settle_launch (v7: complete_launch): + transfer mint authority → squads_multisig_vault (raw, unrestricted) + +initialize_performance_package (v7 name): + CPI → price_based_performance_package (v1) + tokens already pre-minted, transferred to PP vault +``` + +### v8 Token Flow (proposed) + +``` +initialize_launch: + 1. create token metadata (launch_signer is still raw mint authority) + 2. initialize MintGovernor (admin = launch_signer, create_key = launch_signer) + 3. add launch_signer as authorized_minter (max_total = known supply) + 4. transfer mint authority → MintGovernor PDA + 5. create base vault ATA (empty — no tokens minted yet) + + NO MINTING. MintGovernor owns the mint authority from the start. + launch_signer is admin throughout the launch lifecycle. + If the launch fails → zero tokens ever exist. + +settle_launch: + 1. mint_governor::mint_tokens → base vault (exact amount needed) + single mint: participants + futarchy_liq + damm_liq + additional_tokens + 2. initialize DAO (same as v7) + 3. provide liquidity (same as v7) + 4. distribute (same as v7) + (net zero CPI change: mint_tokens replaces the old set_authority call) + +finalize_launch: + 1. add PP v2 PDA as authorized_minter in MintGovernor (launch_signer still admin) + 2. initialize performance_package_v2 with oracle_reader + reward_function + 3. transfer MintGovernor admin → squads_multisig_vault (DAO) — final handoff + tokens minted on demand when milestones hit (via mint_governor CPI) +``` + +Fallback: if `settle_launch` CPI budget is too tight, move the mint back +to `initialize_launch` (just add a `mint_governor::mint_tokens` call at the end). +Everything else stays the same. + +--- + +## Architectural Decisions + +### Why MintGovernor instead of raw mint authority? + +In v7, `settle_launch` (then called `complete_launch`) transfers raw SPL mint authority to the DAO's squads vault. This means: +- Any squads vault transaction can mint unlimited tokens +- No per-program caps or audit trail at the protocol level +- The only gate is the Squads multisig approval + +With MintGovernor: +- The DAO admin (squads vault) controls who can mint via `add_mint_authority` / `remove_mint_authority` +- Each authorized minter can have a `max_total` cap +- All minting goes through `mint_governor::mint_tokens`, providing on-chain accounting (`total_minted`) +- The DAO can still reclaim raw authority via `reclaim_authority` if needed (escape hatch) + +### Why Performance Package v2 instead of v1? + +v1 (`price_based_performance_package`) pre-mints tokens into a vault. This has drawbacks: +- Tokens exist on day 1, diluting circulating supply accounting +- If milestones are never hit, tokens sit locked forever (but are counted in supply) +- Oracle reads raw bytes at offsets — fragile and tightly coupled to account layout + +v2 (`performance_package_v2`) mints on demand: +- Zero supply impact until milestones are actually achieved +- Cleaner oracle model (`OracleReader` enum: `Time`, `FutarchyTwap`) +- Flexible reward functions (`CliffLinear`, `Threshold`) +- The PP PDA acts as an `authorized_minter` in MintGovernor — clean CPI chain + +--- + +## Instruction Changes + +### `initialize_launch` + +**Changes from v7:** +- Remove `performance_package_token_amount` from mint calculation +- Remove `token::mint_to` — no minting at init time +- Set up MintGovernor infrastructure and transfer mint authority immediately +- Create base vault ATA (empty) +- Still store performance package config in `Launch` state for later use + +**New flow:** +1. `create_metadata_accounts_v3` — launch_signer is still the raw mint authority at this point, which metaplex requires +2. `mint_governor::initialize_mint_governor` — create_key = launch_signer, admin = launch_signer +3. `mint_governor::add_mint_authority` — launch_signer as authorized_minter, `max_total` = exact needed supply (`TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount`) +4. `mint_governor::transfer_authority_to_governor` — SPL mint authority moves from launch_signer → MintGovernor PDA +5. Create base vault ATA (empty) + +After this, the MintGovernor PDA owns mint authority and launch_signer is admin + authorized minter with unused `max_total`. No tokens exist. If the launch fails, none ever will. + +**Args changes:** +- Keep `performance_package_grantee`, `months_until_insiders_can_unlock`, `performance_package_token_amount` +- Same args as v7 — the tranche structure (5 tranches at 2x/4x/8x/16x/32x) is derived from these at `finalize_launch` time, just targeting PP v2 instead of v1 + +**New accounts needed:** +- `mint_governor` — MintGovernor PDA (initialized via CPI) +- `mint_authority` — MintAuthority PDA for launch_signer (initialized via CPI) +- `mint_governor_program` — the MintGovernor program +- `mint_governor_event_authority` — for CPI events + +### `settle_launch` + +**(v7: `complete_launch`)** + +**Changes from v7:** +- Remove `transfer_mint_authority_to_dao()` (`token::set_authority`) +- Add: `mint_governor::mint_tokens` — single mint of exact needed supply into base vault +- Net zero CPI change: one in, one out +- Everything else stays the same (DAO init, liquidity, Meteora, bid wall, etc.) + +The mint happens at the top of the handler, before any distribution. At this point +we know `total_approved_amount` and can compute exact allocations. The base vault +ATA already exists (created during `initialize_launch`, just empty). + +**Net account impact:** Roughly neutral. We swap `base_mint` authority accounts +for `mint_governor` + `mint_authority` + `mint_governor_program` accounts. + +**New accounts needed:** +- `mint_governor` — the MintGovernor PDA (already exists from init) +- `mint_authority` — the MintAuthority PDA for launch_signer (already exists from init) +- `mint_governor_program` — for the mint CPI +- `mint_governor_event_authority` — for CPI events + +### `finalize_launch` + +**Major rewrite — now targets performance_package_v2:** + +1. CPI → `mint_governor::add_mint_authority` to register the PP v2 PDA as an authorized minter + - Requires DAO admin (squads_multisig_vault) as signer → **reentrancy concern** + - Alternative: the launchpad_signer could be a temporary admin, add the authority, then transfer admin to DAO +2. CPI → `performance_package_v2::initialize_performance_package` with: + - `oracle_reader`: `FutarchyTwap { amm: dao.key(), min_duration: 3_months }` (same TWAP concept as v7) + - `reward_function`: `Threshold` with price-based tranches (2x, 4x, 8x, 16x, 32x of launch price) + - `min_unlock_timestamp`: completion time + lockup months + - `recipient`: performance_package_grantee from launch config + - `authority`: squads_multisig_vault (DAO) + +**Key difference from v7:** No token transfer. The PP v2 will CPI into mint_governor to mint tokens when milestones are hit. + +**Admin transfer happens here — not in `settle_launch`.** +The launch_signer stays MintGovernor admin through `settle_launch` so that +`finalize_launch` can add the PP v2 PDA as an authorized minter +without needing a Squads transaction. The admin transfer to squads_multisig_vault +is the very last operation in the launch lifecycle — after all minting +infrastructure is fully wired up. + +### Removed / unchanged instructions + +| Instruction | Status | +|---|---| +| `start_launch` | Unchanged | +| `fund` | Unchanged | +| `set_funding_record_approval` | Unchanged | +| `complete_launch` | Renamed → `settle_launch` | +| `claim` | Unchanged | +| `refund` | Unchanged | +| `close_launch` | Unchanged | +| `claim_additional_token_allocation` | Unchanged | +| `extend_launch` | Unchanged | +| `initialize_performance_package` | Renamed → `finalize_launch` | + +--- + +## State Changes + +### `Launch` account + +**Fields to add:** +- `mint_governor: Pubkey` — set at initialization (not optional — always present in v8) +- Performance package v2 config fields (or keep existing fields and derive v2 config from them) + +**Fields to keep:** +- `performance_package_token_amount` — no longer pre-minted, but still used to derive the PP v2 reward function at `finalize_launch` time +- `is_performance_package_initialized` — still needed to gate the instruction + +The tranche structure remains hardcoded and opinionated (5 tranches at 2x/4x/8x/16x/32x of launch price), same as v7. The only change is the target program (PP v2 + mint_governor instead of v1 vault). + +--- + +## CPI Chain + +``` +launchpad_v8::initialize_launch + ├── mpl_token_metadata::create_metadata_accounts_v3 (launch_signer is raw authority) + ├── mint_governor::initialize_mint_governor (admin = launch_signer) + ├── mint_governor::add_mint_authority (launch_signer, max_total = known supply) + └── mint_governor::transfer_authority_to_governor (mint auth → MintGovernor PDA) + (base vault ATA created via anchor init_if_needed, empty — no minting) + +launchpad_v8::settle_launch + ├── mint_governor::mint_tokens → base vault (replaces old token::set_authority) + ├── futarchy::initialize_dao (same as v7) + ├── futarchy::provide_liquidity (same as v7) + ├── bid_wall::initialize_bid_wall (same as v7, if configured) + ├── damm_v2::initialize_pool_with_dynamic_config (same as v7) + ├── mpl_token_metadata::update_metadata_accounts_v2 (metadata authority → DAO) + └── token::transfer USDC to DAO treasury (same as v7) + +launchpad_v8::finalize_launch (separate tx, post-completion) + ├── mint_governor::add_mint_authority (PP v2 PDA as authorized_minter) + ├── performance_package_v2::initialize_performance_package + └── mint_governor::update_mint_governor_admin → squads_multisig_vault +``` + +Fallback: if settle_launch CPI budget is too tight, move mint_tokens +back to initialize_launch. Everything else stays the same. + +--- + +## Open Questions + +1. (none currently) + +### Resolved + +- ~~Account pressure on `initialize_launch`~~ — v7 has ~15 accounts and 2 CPIs. v8 adds ~4 accounts and 2 net CPIs (~19 accounts, 4 CPIs total). Well within limits. +- ~~Migration path~~ — fresh program deploy, new program ID. +- ~~`additional_tokens_amount` minting~~ — included in the single `mint_governor::mint_tokens` call in `settle_launch`, part of launch_signer's `max_total`. +- ~~MintGovernor `max_total` for PP v2~~ — set to `performance_package_token_amount`. Deterministic from the hardcoded 5-tranche threshold reward function. +- ~~Metadata authority~~ — unchanged from v7, transferred to DAO via `update_metadata_accounts_v2` in `settle_launch`. + +--- + +## Dependencies + +| Program | Role in v8 | +|---|---| +| `futarchy` | DAO initialization, AMM liquidity | +| `squads_multisig` | DAO authority, spending limits | +| `mint_governor` | **NEW** — structured minting authority | +| `performance_package_v2` | **NEW** — milestone-based token rewards | +| `damm_v2_cpi` | Meteora pool creation | +| `bid_wall` | Price floor mechanism | +| `mpl_token_metadata` | Token metadata | diff --git a/vibes/launchpad_v8_spec.md b/vibes/launchpad_v8_spec.md new file mode 100644 index 000000000..1efc63af2 --- /dev/null +++ b/vibes/launchpad_v8_spec.md @@ -0,0 +1,1819 @@ +# Launchpad v8 — Implementation Spec + +> **Reference:** `vibes/launchpad_v8.md` for architectural rationale and design decisions. + +--- + +## Summary of Changes from v7 + +| Area | v7 | v8 | +|------|----|----| +| Token minting | All tokens minted upfront in `initialize_launch` | No minting at init; tokens minted on demand | +| Mint authority | Raw SPL authority transferred to DAO in `complete_launch` | MintGovernor PDA owns authority from init; admin transferred to DAO in `finalize_launch` | +| Performance package | v1 (pre-minted vault) | v2 (mint-on-demand via MintGovernor) | +| `complete_launch` | Transfers mint authority to DAO | Renamed → `settle_launch`; mints tokens via MintGovernor | +| `initialize_performance_package` | Initializes PP v1 with pre-minted tokens | Renamed → `finalize_launch`; initializes PP v2 + transfers MintGovernor admin | +| Migration instructions | `resize_launch`, `resize_funding_record` | Removed (fresh deploy, new program ID) | +| Program ID | `moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM` | `MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg` | + +--- + +## Constants + +```rust +pub const TOKEN_SCALE: u64 = 1_000_000; +pub const PRICE_SCALE: u128 = 1_000_000_000_000; +pub const TOKENS_TO_PARTICIPANTS: u64 = 10_000_000 * TOKEN_SCALE; +pub const TOKENS_TO_FUTARCHY_LIQUIDITY: u64 = 2_000_000 * TOKEN_SCALE; +pub const TOKENS_TO_DAMM_V2_LIQUIDITY: u64 = TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED * TOKEN_SCALE; +pub const TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED: u64 = 900_000; +pub const PROPOSAL_MIN_STAKE_TOKENS: u64 = 1_500_000 * TOKEN_SCALE; + +// PP v2 tranche config +pub const PP_NUM_TRANCHES: usize = 5; +pub const PP_PRICE_MULTIPLIERS: [u128; 5] = [2, 4, 8, 16, 32]; + +// FutarchyTwap min_duration: 3 months +pub const PP_TWAP_MIN_DURATION: u32 = 3 * 30 * 24 * 60 * 60; // 7_776_000 seconds +``` + +All unchanged from v7 except PP constants (new). + +--- + +## State + +### `LaunchState` (unchanged) + +```rust +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, InitSpace)] +pub enum LaunchState { + Initialized, + Live, + Closed, + Complete, + Refunding, +} +``` + +### `Launch` account + +Seeds: `[b"launch", base_mint.key()]` + +```rust +#[account] +pub struct Launch { + // -- Unchanged fields -- + pub pda_bump: u8, + pub minimum_raise_amount: u64, + pub monthly_spending_limit_amount: u64, + pub monthly_spending_limit_members: Vec, // max 10 + pub launch_authority: Pubkey, + pub launch_signer: Pubkey, + pub launch_signer_pda_bump: u8, + pub launch_quote_vault: Pubkey, + pub launch_base_vault: Pubkey, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, + pub unix_timestamp_started: Option, + pub unix_timestamp_closed: Option, + pub total_committed_amount: u64, + pub state: LaunchState, + pub seq_num: u64, + pub seconds_for_launch: u32, + pub dao: Option, + pub dao_vault: Option, + pub performance_package_grantee: Pubkey, + pub performance_package_token_amount: u64, + pub months_until_insiders_can_unlock: u8, + pub team_address: Pubkey, + pub total_approved_amount: u64, + pub additional_tokens_amount: u64, + pub additional_tokens_recipient: Option, + pub additional_tokens_claimed: bool, + pub unix_timestamp_completed: Option, + pub is_performance_package_initialized: bool, + pub accumulator_activation_delay_seconds: u32, + pub has_bid_wall: bool, + + // -- New field -- + pub mint_governor: Pubkey, // Set at initialization +} +``` + +### `FundingRecord` account (unchanged) + +Seeds: `[b"funding_record", launch.key(), funder.key()]` + +```rust +#[account] +pub struct FundingRecord { + pub pda_bump: u8, + pub funder: Pubkey, + pub launch: Pubkey, + pub committed_amount: u64, + pub is_tokens_claimed: bool, + pub is_usdc_refunded: bool, + pub approved_amount: u64, + pub committed_amount_accumulator: u128, + pub last_accumulator_update: i64, +} +``` + +### `launch_signer` PDA (unchanged) + +Seeds: `[b"launch_signer", launch.key()]` + +Unchanged PDA used as the signing authority for the launch program. + +--- + +## Instructions + +### 1. `initialize_launch` — CHANGED + +**Changes from v7:** +- Remove `token::mint_to` — no tokens minted at init +- Add MintGovernor setup: init governor, add launch_signer as minter, transfer mint authority +- Store `mint_governor` pubkey in Launch state + +#### Args + +```rust +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct InitializeLaunchArgs { + pub minimum_raise_amount: u64, + pub monthly_spending_limit_amount: u64, + pub monthly_spending_limit_members: Vec, + pub seconds_for_launch: u32, + pub token_name: String, + pub token_symbol: String, + pub token_uri: String, + pub performance_package_grantee: Pubkey, + pub performance_package_token_amount: u64, + pub months_until_insiders_can_unlock: u8, + pub team_address: Pubkey, + pub additional_tokens_amount: u64, + pub accumulator_activation_delay_seconds: u32, + pub has_bid_wall: bool, +} +``` + +Unchanged from v7. + +#### Accounts + +```rust +#[derive(Accounts)] +#[instruction(args: InitializeLaunchArgs)] +pub struct InitializeLaunch<'info> { + // -- Same as v7 -- + #[account(init, payer = payer, space = 8 + Launch::INIT_SPACE, + seeds = [b"launch", base_mint.key().as_ref()], bump)] + pub launch: Account<'info, Launch>, + + #[account(mut, mint::decimals = 6, mint::authority = launch_signer)] + pub base_mint: Account<'info, Mint>, + + #[account(mut, seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), + base_mint.key().as_ref()], seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, bump)] + pub token_metadata: UncheckedAccount<'info>, + + #[account(seeds = [b"launch_signer", launch.key().as_ref()], bump)] + pub launch_signer: UncheckedAccount<'info>, + + #[account(init_if_needed, payer = payer, associated_token::mint = quote_mint, + associated_token::authority = launch_signer)] + pub quote_vault: Account<'info, TokenAccount>, + + #[account(init_if_needed, payer = payer, associated_token::mint = base_mint, + associated_token::authority = launch_signer)] + pub base_vault: Account<'info, TokenAccount>, + + #[account(mut)] + pub payer: Signer<'info>, + + pub launch_authority: UncheckedAccount<'info>, + + #[account(mint::decimals = 6, address = usdc_mint::id())] + pub quote_mint: Account<'info, Mint>, + + pub additional_tokens_recipient: Option>, + + // -- New: MintGovernor accounts -- + /// PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)] + /// Initialized via CPI to mint_governor::initialize_mint_governor + #[account(mut)] + pub mint_governor: UncheckedAccount<'info>, + + /// PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)] + /// Initialized via CPI to mint_governor::add_mint_authority + #[account(mut)] + pub mint_authority: UncheckedAccount<'info>, + + pub mint_governor_program: Program<'info, MintGovernorProgram>, + pub mint_governor_event_authority: UncheckedAccount<'info>, + + // -- Standard -- + pub rent: Sysvar<'info, Rent>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub system_program: Program<'info, System>, + pub token_metadata_program: Program<'info, Metadata>, +} +``` + +#### Validation + +Same as v7: +- `minimum_raise_amount > 0` +- `seconds_for_launch <= 14 days` +- `accumulator_activation_delay_seconds < seconds_for_launch` +- No freeze authority on `base_mint` +- `minimum_raise_amount >= monthly_spending_limit_amount * 6` +- `minimum_raise_amount >= futarchy::MIN_QUOTE_LIQUIDITY * 5` +- `monthly_spending_limit_amount != 0` +- `monthly_spending_limit_members.len()` in `1..=10`, no duplicates +- `months_until_insiders_can_unlock >= 12` +- `performance_package_token_amount >= 10` +- `base_mint.supply == 0` +- If `additional_tokens_amount > 0`, `additional_tokens_recipient` must be `Some` + +#### Handler + +``` +1. Initialize Launch account (state = Initialized, store all fields including mint_governor key) + +2. CPI → mpl_token_metadata::create_metadata_accounts_v3 + - mint_authority = launch_signer (still raw SPL authority at this point) + - update_authority = launch_signer + +3. CPI → mint_governor::initialize_mint_governor + - create_key = launch_signer + - admin = launch_signer + - mint = base_mint + +4. CPI → mint_governor::add_mint_authority + - admin = launch_signer + - authorized_minter = launch_signer + - max_total = Some(TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount) + +5. CPI → mint_governor::transfer_authority_to_governor + - current_authority = launch_signer + - mint = base_mint + → SPL mint authority moves from launch_signer → MintGovernor PDA + +6. NO token::mint_to (removed from v7) + +7. Emit LaunchInitializedEvent +``` + +After this instruction: +- MintGovernor PDA owns the SPL mint authority +- launch_signer is admin + authorized minter with a capped `max_total` +- Zero tokens exist +- base_vault ATA exists but is empty + +--- + +### 2. `start_launch` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct StartLaunch<'info> { + #[account(mut, has_one = launch_authority)] + pub launch: Account<'info, Launch>, + pub launch_authority: Signer<'info>, +} +``` + +Sets state `Initialized → Live`, records `unix_timestamp_started`. + +--- + +### 3. `fund` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct Fund<'info> { + #[account(mut, has_one = launch_quote_vault)] + pub launch: Account<'info, Launch>, + #[account(init_if_needed, payer = payer, space = 8 + FundingRecord::INIT_SPACE, + seeds = [b"funding_record", launch.key().as_ref(), funder.key().as_ref()], bump)] + pub funding_record: Account<'info, FundingRecord>, + #[account(mut)] + pub launch_quote_vault: Account<'info, TokenAccount>, + pub funder: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + #[account(mut, associated_token::mint = launch.quote_mint, associated_token::authority = funder)] + pub funder_quote_account: Account<'info, TokenAccount>, + pub token_program: Program<'info, Token>, + pub system_program: Program<'info, System>, +} +``` + +Transfers quote tokens from funder to vault. Updates accumulator. Emits `LaunchFundedEvent`. + +--- + +### 4. `set_funding_record_approval` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct SetFundingRecordApproval<'info> { + #[account(mut, has_one = launch_authority)] + pub launch: Account<'info, Launch>, + #[account(mut, has_one = launch)] + pub funding_record: Account<'info, FundingRecord>, + pub launch_authority: Signer<'info>, +} +``` + +Sets `approved_amount` on a funding record. Only callable while `Closed` and within 2 days of close. + +--- + +### 5. `close_launch` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct CloseLaunch<'info> { + #[account(mut)] + pub launch: Account<'info, Launch>, +} +``` + +Transitions `Live → Closed` (or `→ Refunding` if below minimum). + +--- + +### 6. `settle_launch` — CHANGED (renamed from `complete_launch`) + +**Changes from v7:** +- Renamed from `complete_launch` +- Remove `token::set_authority` (transfer mint authority to DAO) — MintGovernor admin stays as launch_signer +- Add `mint_governor::mint_tokens` — single mint of exact needed supply into base vault +- Everything else (DAO init, liquidity, Meteora, bid wall, metadata transfer, USDC transfer) stays the same + +> **Note:** The old `token::set_authority` was a direct CPI (depth 2). The new `mint_governor::mint_tokens` is depth 3 (launchpad → mint_governor → token::mint_to). Still well within the depth-4 limit. + +#### Accounts + +```rust +#[derive(Accounts)] +pub struct SettleLaunch<'info> { + // -- Same as v7 complete_launch -- + #[account(mut, has_one = launch_quote_vault, has_one = launch_base_vault, + has_one = launch_signer, has_one = base_mint, has_one = quote_mint, + has_one = mint_governor)] + pub launch: Box>, + + pub launch_authority: Option>, + + #[account(mut, seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), + base_mint.key().as_ref()], seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, bump)] + pub token_metadata: UncheckedAccount<'info>, + + #[account(mut)] + pub payer: Signer<'info>, + + #[account(mut)] + pub launch_signer: UncheckedAccount<'info>, + + #[account(mut, associated_token::mint = quote_mint, associated_token::authority = launch_signer)] + pub launch_quote_vault: Box>, + + #[account(mut, associated_token::mint = base_mint, associated_token::authority = launch_signer)] + pub launch_base_vault: Box>, + + #[account(init_if_needed, payer = payer, associated_token::mint = quote_mint, + associated_token::authority = squads_multisig_vault)] + pub treasury_quote_account: Box>, + + #[account(mut, address = meteora_accounts.base_mint.key())] + pub base_mint: Box>, + + #[account(address = meteora_accounts.quote_mint.key())] + pub quote_mint: Box>, + + // DAO / Squads accounts (same as v7) + #[account(mut)] + pub dao: UncheckedAccount<'info>, + #[account(mut)] + pub squads_multisig: UncheckedAccount<'info>, + pub squads_multisig_vault: UncheckedAccount<'info>, + #[account(mut)] + pub spending_limit: UncheckedAccount<'info>, + + // Futarchy AMM (same as v7) + #[account(mut)] + pub dao_owned_lp_position: UncheckedAccount<'info>, + #[account(mut)] + pub futarchy_amm_base_vault: UncheckedAccount<'info>, + #[account(mut)] + pub futarchy_amm_quote_vault: UncheckedAccount<'info>, + + // Bid wall (same as v7) + #[account(mut)] + pub bid_wall: UncheckedAccount<'info>, + #[account(mut)] + pub bid_wall_quote_token_account: UncheckedAccount<'info>, + + pub fee_recipient: AccountInfo<'info>, + + // -- New: MintGovernor accounts -- + #[account(mut)] + pub mint_governor: Account<'info, MintGovernor>, + + #[account(mut, has_one = mint_governor, + constraint = mint_authority.authorized_minter == launch_signer.key() + @ LaunchpadError::InvalidMintAuthority)] + pub mint_authority: Account<'info, MintAuthority>, + + pub mint_governor_program: Program<'info, MintGovernorProgram>, + pub mint_governor_event_authority: UncheckedAccount<'info>, + + // Standard + nested (same as v7) + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub static_accounts: StaticCompleteLaunchAccounts<'info>, + pub meteora_accounts: MeteoraAccounts<'info>, +} +``` + +`StaticCompleteLaunchAccounts` and `MeteoraAccounts` — same as v7. + +#### Validation + +Same as v7: +- Launch state must be `Closed` +- If within 2 days of close → `launch_authority` must be present and match +- If `launch_authority` signs → `total_approved_amount >= minimum_raise_amount` + +#### Handler + +``` +1. If total_approved_amount < minimum_raise_amount → set state to Refunding, return early + +2. (NEW) CPI → mint_governor::mint_tokens + - authorized_minter = launch_signer (signs via PDA seeds) + - destination_ata = launch_base_vault + - amount = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount + +3. Calculate launch_price = (total_approved_amount * PRICE_SCALE) / TOKENS_TO_PARTICIPANTS + +4. Allocate USDC: 20% to futarchy AMM, remainder to DAO (minus optional bid wall) + +5. CPI → futarchy::initialize_dao (same as v7) + +6. If has_bid_wall → CPI → bid_wall::initialize_bid_wall (same as v7) + +7. CPI → futarchy::provide_liquidity (same as v7) + +8. CPI → damm_v2::initialize_pool_with_dynamic_config (same as v7) + +9. CPI → mpl_token_metadata::update_metadata_accounts_v2 + - Transfer metadata update_authority from launch_signer → squads_multisig_vault + +10. Transfer USDC from launch_quote_vault → treasury_quote_account (same as v7) + +11. (REMOVED) token::set_authority — no longer transferring raw mint authority + +12. Set state = Complete, unix_timestamp_completed, dao, dao_vault +13. Emit LaunchSettledEvent +``` + +**Key difference:** MintGovernor admin remains as `launch_signer` after this instruction. The admin transfer to the DAO happens in `finalize_launch`. + +--- + +### 7. `finalize_launch` — CHANGED (renamed from `initialize_performance_package`) + +**Complete rewrite — now targets PP v2 + MintGovernor admin transfer.** + +#### Accounts + +```rust +#[derive(Accounts)] +pub struct FinalizeLaunch<'info> { + #[account(mut, has_one = launch_signer, has_one = base_mint, has_one = mint_governor, + has_one = performance_package_grantee, + constraint = launch.dao == Some(dao.key()) @ LaunchpadError::InvalidDao)] + pub launch: Box>, + + #[account(mut)] + pub payer: Signer<'info>, + + pub launch_signer: UncheckedAccount<'info>, + + #[account(address = launch.base_mint)] + pub base_mint: Account<'info, Mint>, + + // DAO / Squads + pub dao: UncheckedAccount<'info>, + + // NOTE: seeds::program = squads_program is required here because these are + // cross-program PDAs derived from the Squads program, not the launchpad. + #[account(seeds = [squads_multisig_program::SEED_PREFIX, + squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], + seeds::program = squads_program, bump)] + pub squads_multisig: UncheckedAccount<'info>, + + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), + squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], + seeds::program = squads_program, bump)] + pub squads_multisig_vault: UncheckedAccount<'info>, + + /// The performance package grantee — stored in launch state, passed here + /// for the PP v2 initialize CPI (recipient field). + pub performance_package_grantee: UncheckedAccount<'info>, + + // MintGovernor + #[account(mut)] + pub mint_governor: Account<'info, MintGovernor>, + + /// MintAuthority for PP v2 PDA — initialized via CPI + /// PDA: seeds = [b"mint_authority", mint_governor, performance_package] + #[account(mut)] + pub pp_mint_authority: UncheckedAccount<'info>, + + // Performance Package v2 + /// PP v2 account — initialized via CPI + /// PDA: seeds = [b"performance_package", launch_signer (create_key)] + #[account(mut)] + pub performance_package: UncheckedAccount<'info>, + + // Programs + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub squads_program: Program<'info, SquadsMultisig>, + pub mint_governor_program: Program<'info, MintGovernorProgram>, + pub mint_governor_event_authority: UncheckedAccount<'info>, + pub performance_package_v2_program: Program<'info, PerformancePackageV2Program>, + pub performance_package_v2_event_authority: UncheckedAccount<'info>, +} +``` + +#### Validation + +```rust +fn validate(&self) -> Result<()> { + require!(self.launch.state == LaunchState::Complete, LaunchpadError::InvalidLaunchState); + require!(!self.launch.is_performance_package_initialized, + LaunchpadError::PerformancePackageAlreadyInitialized); + Ok(()) +} +``` + +#### Handler + +``` +1. Compute launch_price = (total_approved_amount * PRICE_SCALE) / TOKENS_TO_PARTICIPANTS + +2. Build threshold tranches for PP v2: + tranches = [ + { threshold: launch_price * 2, cumulative_amount: pp_token_amount * 1 / 5 }, + { threshold: launch_price * 4, cumulative_amount: pp_token_amount * 2 / 5 }, + { threshold: launch_price * 8, cumulative_amount: pp_token_amount * 3 / 5 }, + { threshold: launch_price * 16, cumulative_amount: pp_token_amount * 4 / 5 }, + { threshold: launch_price * 32, cumulative_amount: pp_token_amount }, + ] + +3. CPI → mint_governor::add_mint_authority + - admin = launch_signer (still admin at this point) + - authorized_minter = performance_package PDA + - max_total = Some(performance_package_token_amount) + +4. CPI → performance_package_v2::initialize_performance_package + - create_key = launch_signer + - mint = base_mint + - mint_governor = launch.mint_governor + - mint_authority = pp_mint_authority (created in step 3) + - authority = squads_multisig_vault (DAO controls the PP) + - recipient = launch.performance_package_grantee + - args = InitializePerformancePackageArgs { + oracle_reader: FutarchyTwap { amm: dao.key(), min_duration: PP_TWAP_MIN_DURATION }, + reward_function: Threshold { tranches }, + min_unlock_timestamp: unix_timestamp_completed + + (months_until_insiders_can_unlock as i64) * 30 * 24 * 60 * 60, + } + +5. CPI → mint_governor::update_mint_governor_admin + - admin = launch_signer + - new_admin = squads_multisig_vault + → Final handoff: DAO now controls MintGovernor + +6. Set is_performance_package_initialized = true +7. Emit LaunchFinalizedEvent +``` + +--- + +### 8. `claim` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct Claim<'info> { + #[account(mut, has_one = launch_signer, has_one = base_mint, has_one = launch_base_vault)] + pub launch: Account<'info, Launch>, + #[account(mut, has_one = launch, has_one = funder)] + pub funding_record: Account<'info, FundingRecord>, + pub launch_signer: UncheckedAccount<'info>, + pub base_mint: Account<'info, Mint>, + #[account(mut)] + pub launch_base_vault: Account<'info, TokenAccount>, + pub funder: UncheckedAccount<'info>, + #[account(mut, associated_token::mint = base_mint, associated_token::authority = funder)] + pub funder_token_account: Account<'info, TokenAccount>, + pub token_program: Program<'info, Token>, +} +``` + +Transfers `(approved_amount / total_approved_amount) * TOKENS_TO_PARTICIPANTS` tokens to funder. + +--- + +### 9. `refund` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct Refund<'info> { + #[account(mut, has_one = launch_quote_vault, has_one = launch_signer)] + pub launch: Account<'info, Launch>, + #[account(mut, has_one = launch, has_one = funder)] + pub funding_record: Account<'info, FundingRecord>, + #[account(mut)] + pub launch_quote_vault: Account<'info, TokenAccount>, + pub launch_signer: UncheckedAccount<'info>, + pub funder: UncheckedAccount<'info>, + #[account(mut, associated_token::mint = launch.quote_mint, associated_token::authority = funder)] + pub funder_quote_account: Account<'info, TokenAccount>, + pub token_program: Program<'info, Token>, +} +``` + +Refunds USDC. If `Refunding` → full amount. If `Complete` → `committed - approved`. + +--- + +### 10. `claim_additional_token_allocation` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct ClaimAdditionalTokenAllocation<'info> { + #[account(mut, has_one = launch_base_vault, has_one = launch_signer, has_one = base_mint)] + pub launch: Account<'info, Launch>, + #[account(mut)] + pub payer: Signer<'info>, + pub launch_signer: UncheckedAccount<'info>, + #[account(mut, associated_token::mint = base_mint, associated_token::authority = launch_signer)] + pub launch_base_vault: Account<'info, TokenAccount>, + pub base_mint: Account<'info, Mint>, + pub additional_tokens_recipient: AccountInfo<'info>, + #[account(init_if_needed, payer = payer, associated_token::mint = base_mint, + associated_token::authority = additional_tokens_recipient)] + pub additional_tokens_recipient_token_account: Account<'info, TokenAccount>, + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, +} +``` + +Transfers `additional_tokens_amount` to recipient. + +--- + +### 11. `extend_launch` — UNCHANGED + +```rust +#[derive(Accounts)] +pub struct ExtendLaunch<'info> { + #[account(mut)] + pub launch: Account<'info, Launch>, + pub admin: Signer<'info>, +} +``` + +Admin (metadao_multisig_vault in production) extends `seconds_for_launch`. + +--- + +## Events + +All events use CPI events (`#[event_cpi]` / `emit_cpi!`). + +### Common fields + +```rust +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct CommonFields { + pub slot: u64, + pub unix_timestamp: i64, + pub launch_seq_num: u64, +} +``` + +### `LaunchInitializedEvent` — CHANGED + +```rust +#[event] +pub struct LaunchInitializedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub minimum_raise_amount: u64, + pub launch_authority: Pubkey, + pub launch_signer: Pubkey, + pub launch_signer_pda_bump: u8, + pub launch_usdc_vault: Pubkey, + pub launch_token_vault: Pubkey, + pub performance_package_grantee: Pubkey, + pub performance_package_token_amount: u64, + pub months_until_insiders_can_unlock: u8, + pub monthly_spending_limit_amount: u64, + pub monthly_spending_limit_members: Vec, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, + pub pda_bump: u8, + pub seconds_for_launch: u32, + pub additional_tokens_amount: u64, + pub additional_tokens_recipient: Option, + pub accumulator_activation_delay_seconds: u32, + pub has_bid_wall: bool, + pub mint_governor: Pubkey, // NEW +} +``` + +### `LaunchStartedEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchStartedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub launch_authority: Pubkey, + pub slot_started: u64, +} +``` + +### `LaunchFundedEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchFundedEvent { + pub common: CommonFields, + pub funding_record: Pubkey, + pub launch: Pubkey, + pub funder: Pubkey, + pub amount: u64, + pub total_committed_by_funder: u64, + pub total_committed: u64, + pub committed_amount_accumulator: u128, +} +``` + +### `FundingRecordApprovalSetEvent` — UNCHANGED + +```rust +#[event] +pub struct FundingRecordApprovalSetEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funding_record: Pubkey, + pub funder: Pubkey, + pub approved_amount: u64, + pub total_approved: u64, +} +``` + +### `LaunchCloseEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchCloseEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub new_state: LaunchState, +} +``` + +### `LaunchSettledEvent` — CHANGED (renamed from `LaunchCompletedEvent`) + +```rust +#[event] +pub struct LaunchSettledEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub final_state: LaunchState, + pub total_committed: u64, + pub dao: Option, + pub dao_treasury: Option, + pub total_approved_amount: u64, + pub bid_wall: Option, + pub bid_wall_amount: u64, + pub mint_governor: Pubkey, // NEW + pub tokens_minted: u64, // NEW — total tokens minted in this tx +} +``` + +### `LaunchFinalizedEvent` — CHANGED (renamed from `LaunchPerformancePackageInitializedEvent`) + +```rust +#[event] +pub struct LaunchFinalizedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub performance_package: Pubkey, + pub mint_governor: Pubkey, // NEW + pub mint_governor_new_admin: Pubkey, // NEW — the DAO vault + pub pp_mint_authority: Pubkey, // NEW +} +``` + +### `LaunchRefundedEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchRefundedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funder: Pubkey, + pub usdc_refunded: u64, + pub funding_record: Pubkey, +} +``` + +### `LaunchClaimEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchClaimEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funder: Pubkey, + pub tokens_claimed: u64, + pub funding_record: Pubkey, +} +``` + +### `LaunchClaimAdditionalTokenAllocationEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchClaimAdditionalTokenAllocationEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub additional_tokens_amount: u64, + pub additional_tokens_recipient: Pubkey, +} +``` + +### `LaunchExtendedEvent` — UNCHANGED + +```rust +#[event] +pub struct LaunchExtendedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub old_seconds_for_launch: u32, + pub new_seconds_for_launch: u32, +} +``` + +--- + +## Errors + +```rust +#[error_code] +pub enum LaunchpadError { + #[msg("Invalid amount")] + InvalidAmount, + #[msg("Supply must be zero")] + SupplyNonZero, + #[msg("Launch period must be between 1 hour and 2 weeks")] + InvalidSecondsForLaunch, + #[msg("Insufficient funds")] + InsufficientFunds, + #[msg("Invalid launch state")] + InvalidLaunchState, + #[msg("Launch period not over")] + LaunchPeriodNotOver, + #[msg("Launch is complete, no more funding allowed")] + LaunchExpired, + #[msg("Refund not available")] + LaunchNotRefunding, + #[msg("Launch must be initialized to be started")] + LaunchNotInitialized, + #[msg("Freeze authority can't be set on launchpad tokens")] + FreezeAuthoritySet, + #[msg("Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0")] + InvalidMonthlySpendingLimit, + #[msg("There can only be at most 10 monthly spending limit members")] + InvalidMonthlySpendingLimitMembers, + #[msg("Invalid performance package token amount")] + InvalidPerformancePackageTokenAmount, + #[msg("Insiders must wait at least 12 months before unlocking")] + InvalidPerformancePackageMinUnlockTime, + #[msg("Launch authority must be set to complete the launch until 2 days after closing")] + LaunchAuthorityNotSet, + #[msg("The final amount raised must be >= the minimum raise amount")] + FinalRaiseAmountTooLow, + #[msg("Tokens already claimed")] + TokensAlreadyClaimed, + #[msg("USDC already refunded")] + MoneyAlreadyRefunded, + #[msg("Invariant violated")] + InvariantViolated, + #[msg("Launch must be live to be closed")] + LaunchNotLive, + #[msg("Minimum raise amount too low for liquidity")] + InvalidMinimumRaiseAmount, + #[msg("Final raise amount already set")] + FinalRaiseAmountAlreadySet, + #[msg("Total approved amount too low")] + TotalApprovedAmountTooLow, + #[msg("Additional tokens recipient must be set when amount > 0")] + InvalidAdditionalTokensRecipient, + #[msg("No additional tokens recipient set")] + NoAdditionalTokensRecipientSet, + #[msg("Additional tokens already claimed")] + AdditionalTokensAlreadyClaimed, + #[msg("Funding record approval period is over")] + FundingRecordApprovalPeriodOver, + #[msg("Performance package already initialized")] + PerformancePackageAlreadyInitialized, + #[msg("Invalid DAO")] + InvalidDao, + #[msg("Accumulator activation delay must be less than the launch duration")] + InvalidAccumulatorActivationDelaySeconds, + #[msg("Extend duration would exceed maximum allowed launch duration")] + ExtendDurationExceedsMax, + #[msg("Mint authority does not match expected")] // NEW + InvalidMintAuthority, +} +``` + +Same error variants as v7, reordered/renamed for clarity. `InvalidMintAuthority` added for MintGovernor account validation. + +--- + +## SDK2 Client + +### Directory: `sdk2/src/launchpad/v0.8/` + +Files: +- `LaunchpadClient.ts` +- `pda.ts` +- `types/index.ts` +- `types/v08_launchpad.ts` (generated from IDL) +- `index.ts` (re-exports) + +### `pda.ts` + +```typescript +import { PublicKey } from "@solana/web3.js"; +import { LAUNCHPAD_V0_8_PROGRAM_ID } from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; +``` + +PDA functions are identical to v0.7, just targeting the v0.8 program ID. + +### `LaunchpadClient.ts` + +```typescript +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { PublicKey, ComputeBudgetProgram, SystemProgram } from "@solana/web3.js"; +import { + ASSOCIATED_TOKEN_PROGRAM_ID, + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from "@solana/spl-token"; +import BN from "bn.js"; + +// Type imports from generated IDL +import { V08Launchpad as Launchpad, IDL as LaunchpadIDL } from "./types/v08_launchpad.js"; +import { Launch, FundingRecord } from "./types/index.js"; + +// PDA imports +import { getLaunchAddr, getLaunchSignerAddr, getFundingRecordAddr } from "./pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; + +// Sub-client imports +import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; +import { MintGovernorClient, getMintGovernorAddr, getMintAuthorityAddr } from "../../mint_governor/v0.7/index.js"; +import { PerformancePackageV2Client, getPerformancePackageV2Addr } from "../../performance_package_v2/v0.7/index.js"; +import { BidWallClient } from "../../bid_wall/v0.7/index.js"; +import * as multisig from "@sqds/multisig"; + +import { + LAUNCHPAD_V0_8_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, + SQUADS_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, + DAMM_V2_PROGRAM_ID, + MINT_GOVERNOR_V0_7_PROGRAM_ID, + PERFORMANCE_PACKAGE_V2_PROGRAM_ID, + METADAO_MULTISIG_VAULT, +} from "../../constants.js"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + mintGovernorProgramId?: PublicKey; + performancePackageV2ProgramId?: PublicKey; + bidWallProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + public autocratClient: FutarchyClient; + public mintGovernorClient: MintGovernorClient; + public performancePackageV2Client: PerformancePackageV2Client; + public bidWall: BidWallClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + this.launchpad = new Program( + LaunchpadIDL, + params.launchpadProgramId || LAUNCHPAD_V0_8_PROGRAM_ID, + this.provider, + ); + this.autocratClient = FutarchyClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + }); + this.mintGovernorClient = MintGovernorClient.createClient({ + provider: this.provider, + programId: params.mintGovernorProgramId, + }); + this.performancePackageV2Client = PerformancePackageV2Client.createClient({ + provider: this.provider, + programId: params.performancePackageV2ProgramId, + }); + this.bidWall = BidWallClient.createClient({ + provider: this.provider, + bidWallProgramId: params.bidWallProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + // ─── Fetch / Deserialize ──────────────────────────────────────────── + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable(fundingRecord); + } + + async deserializeFundingRecord(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("fundingRecord", accountInfo.data); + } + + // ─── Address Derivation ───────────────────────────────────────────── + + getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { + return getLaunchAddr(this.launchpad.programId, baseMint)[0]; + } + + getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { + return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; + } + + getMintGovernorAddress({ baseMint, launchSigner }: { + baseMint: PublicKey; + launchSigner: PublicKey; + }): PublicKey { + return getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + })[0]; + } + + getMintAuthorityAddress({ mintGovernor, authorizedMinter }: { + mintGovernor: PublicKey; + authorizedMinter: PublicKey; + }): PublicKey { + return getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter, + })[0]; + } + + getPerformancePackageAddress({ launch }: { launch: PublicKey }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + return getPerformancePackageV2Addr({ + programId: this.performancePackageV2Client.programId, + createKey: launchSigner, + })[0]; + } + + getLaunchDaoAddress({ launch }: { launch: PublicKey }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + return getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner })[0]; + } + + getFundingRecordAddress({ launch, funder }: { + launch: PublicKey; + funder: PublicKey; + }): PublicKey { + return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; + } + + // ─── Instruction Builders ─────────────────────────────────────────── + + initializeLaunchIx({ + tokenName, tokenSymbol, tokenUri, + minimumRaiseAmount, secondsForLaunch = 60 * 60 * 24 * 5, + baseMint, quoteMint = MAINNET_USDC, + monthlySpendingLimitAmount, monthlySpendingLimitMembers, + performancePackageGrantee, performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, teamAddress, + launchAuthority = this.provider.publicKey, + payer = this.provider.publicKey, + additionalTokensRecipient, additionalTokensAmount, + accumulatorActivationDelaySeconds = 0, + hasBidWall = false, + }: { + tokenName: string; + tokenSymbol: string; + tokenUri: string; + minimumRaiseAmount: BN; + secondsForLaunch?: number; + baseMint: PublicKey; + quoteMint?: PublicKey; + monthlySpendingLimitAmount: BN; + monthlySpendingLimitMembers: PublicKey[]; + performancePackageGrantee: PublicKey; + performancePackageTokenAmount: BN; + monthsUntilInsidersCanUnlock: number; + teamAddress: PublicKey; + launchAuthority?: PublicKey; + payer?: PublicKey; + additionalTokensRecipient?: PublicKey; + additionalTokensAmount?: BN; + accumulatorActivationDelaySeconds?: number; + hasBidWall: boolean; + }) { + const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); + const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); + const quoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); + const baseVault = getAssociatedTokenAddressSync(baseMint, launchSigner, true); + const [tokenMetadata] = getMetadataAddr(baseMint); + + // MintGovernor PDAs + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: launchSigner, + }); + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, tokenSymbol, tokenUri, + monthlySpendingLimitAmount, monthlySpendingLimitMembers, + performancePackageGrantee, performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, teamAddress, + additionalTokensAmount: additionalTokensAmount ?? new BN(0), + accumulatorActivationDelaySeconds, + hasBidWall, + }) + .accounts({ + launch, launchSigner, + quoteVault, baseVault, + launchAuthority, quoteMint, baseMint, tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + additionalTokensRecipient: additionalTokensRecipient ?? null, + // New MintGovernor accounts + mintGovernor, + mintAuthority, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, launchSigner, true), + launchSigner, + quoteMint, + ), + ]); + } + + startLaunchIx({ launch, launchAuthority = this.provider.publicKey }: { + launch: PublicKey; + launchAuthority?: PublicKey; + }) { + return this.launchpad.methods.startLaunch().accounts({ + launch, launchAuthority, + }); + } + + fundIx({ launch, amount, funder = this.provider.publicKey, quoteMint = MAINNET_USDC }: { + launch: PublicKey; + amount: BN; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); + const funderQuoteAccount = getAssociatedTokenAddressSync(quoteMint, funder, true); + const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); + + return this.launchpad.methods.fund(amount).accounts({ + launch, launchQuoteVault, fundingRecord, funder, funderQuoteAccount, + }); + } + + closeLaunchIx({ launch }: { launch: PublicKey }) { + return this.launchpad.methods.closeLaunch().accounts({ launch }); + } + + setFundingRecordApprovalIx({ launch, funder, launchAuthority = this.provider.publicKey, approvedAmount }: { + launch: PublicKey; + funder: PublicKey; + launchAuthority?: PublicKey; + approvedAmount: BN; + }) { + const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); + return this.launchpad.methods + .setFundingRecordApproval(approvedAmount) + .accounts({ launch, fundingRecord, launchAuthority }); + } + + settleLaunchIx({ + launch, quoteMint = MAINNET_USDC, baseMint, launchAuthority, + isDevnet = false, meteoraConfig, feeRecipient = METADAO_MULTISIG_VAULT, + }: { + launch: PublicKey; + quoteMint?: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey | null; + isDevnet?: boolean; + meteoraConfig: PublicKey; + feeRecipient?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); + const launchBaseVault = getAssociatedTokenAddressSync(baseMint, launchSigner, true); + const [tokenMetadata] = getMetadataAddr(baseMint); + + // DAO / Squads + const [dao] = getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner }); + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ multisigPda, index: 0 }); + const [spendingLimit] = multisig.getSpendingLimitPda({ multisigPda, createKey: dao }); + const treasuryQuoteAccount = getAssociatedTokenAddressSync(quoteMint, multisigVault, true); + const [futarchyEventAuthority] = getEventAuthorityAddr(this.autocratClient.getProgramId()); + + // Futarchy AMM + const [ammPosition] = PublicKey.findProgramAddressSync( + [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], + this.autocratClient.getProgramId(), + ); + + // MintGovernor + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: launchSigner, + }); + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + + // Meteora (same as v7) + const [poolAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], DAMM_V2_PROGRAM_ID, + ); + const [positionNftMint] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_mint"), baseMint.toBuffer()], + this.launchpad.programId, + ); + const [positionNftAccount] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + function getFirstKey(key1: PublicKey, key2: PublicKey) { + return Buffer.compare(key1.toBuffer(), key2.toBuffer()) === 1 + ? key1.toBuffer() : key2.toBuffer(); + } + function getSecondKey(key1: PublicKey, key2: PublicKey) { + return Buffer.compare(key1.toBuffer(), key2.toBuffer()) === 1 + ? key2.toBuffer() : key1.toBuffer(); + } + + const [pool] = PublicKey.findProgramAddressSync( + [Buffer.from("pool"), meteoraConfig.toBuffer(), + getFirstKey(baseMint, quoteMint), getSecondKey(baseMint, quoteMint)], + DAMM_V2_PROGRAM_ID, + ); + const [position] = PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNftMint.toBuffer()], DAMM_V2_PROGRAM_ID, + ); + const [tokenAVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], DAMM_V2_PROGRAM_ID, + ); + const [tokenBVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], DAMM_V2_PROGRAM_ID, + ); + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], this.launchpad.programId, + ); + const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); + + // Bid wall + const bidWall = this.bidWall.getBidWallAddress({ + baseMint, creator: launchSigner, nonce: new BN(0), + }); + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync(quoteMint, bidWall, true); + + return this.launchpad.methods + .settleLaunch() + .accounts({ + launch, launchSigner, launchQuoteVault, launchBaseVault, + launchAuthority, dao, treasuryQuoteAccount, quoteMint, baseMint, + tokenMetadata, + daoOwnedLpPosition: ammPosition, + futarchyAmmQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), + futarchyAmmBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + spendingLimit, bidWall, bidWallQuoteTokenAccount, feeRecipient, + // New MintGovernor accounts + mintGovernor, mintAuthority, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + // Nested (same as v7) + staticAccounts: { + futarchyProgram: this.autocratClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + futarchyEventAuthority, + squadsProgram: SQUADS_PROGRAM_ID, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury: isDevnet + ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET + : SQUADS_PROGRAM_CONFIG_TREASURY, + bidWallProgram: this.bidWall.programId, + bidWallEventAuthority: this.bidWall.getEventAuthorityAddress(), + }, + meteoraAccounts: { + dammV2Program: DAMM_V2_PROGRAM_ID, + positionNftMint, baseMint, quoteMint, + config: meteoraConfig, + token2022Program: TOKEN_2022_PROGRAM_ID, + positionNftAccount, pool, poolCreatorAuthority, + position, tokenAVault, tokenBVault, poolAuthority, + dammV2EventAuthority, + }, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), + ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), + ]); + } + + finalizeLaunchIx({ + launch, baseMint, performancePackageGrantee, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + performancePackageGrantee: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + // DAO / Squads + const [dao] = getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner }); + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ multisigPda, index: 0 }); + + // MintGovernor + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + + // PP v2 PDA (create_key = launch_signer) + const [performancePackage] = getPerformancePackageV2Addr({ + programId: this.performancePackageV2Client.programId, + createKey: launchSigner, + }); + + // MintAuthority for PP v2 + const [ppMintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: performancePackage, + }); + + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + const [ppV2EventAuthority] = getEventAuthorityAddr( + this.performancePackageV2Client.programId, + ); + + return this.launchpad.methods + .finalizeLaunch() + .accounts({ + launch, launchSigner, baseMint, payer, + dao, squadsMultisig: multisigPda, squadsMultisigVault: multisigVault, + performancePackageGrantee, + mintGovernor, ppMintAuthority, performancePackage, + tokenProgram: TOKEN_PROGRAM_ID, + squadsProgram: SQUADS_PROGRAM_ID, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + performancePackageV2Program: this.performancePackageV2Client.programId, + performancePackageV2EventAuthority: ppV2EventAuthority, + }); + } + + refundIx({ launch, funder = this.provider.publicKey, quoteMint = MAINNET_USDC }: { + launch: PublicKey; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); + const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); + const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); + const funderQuoteAccount = getAssociatedTokenAddressSync(quoteMint, funder, true); + + return this.launchpad.methods.refund().accounts({ + launch, launchSigner, launchQuoteVault, funder, funderQuoteAccount, fundingRecord, + }); + } + + claimIx(launch: PublicKey, baseMint: PublicKey, funder: PublicKey = this.provider.publicKey) { + const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); + const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); + + return this.launchpad.methods.claim().accounts({ + launch, fundingRecord, launchSigner, funder, baseMint, + funderTokenAccount: getAssociatedTokenAddressSync(baseMint, funder, true), + launchBaseVault: getAssociatedTokenAddressSync(baseMint, launchSigner, true), + }).preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, funder, true), + funder, baseMint, + ), + ]); + } + + claimAdditionalTokenAllocationIx({ launch, baseMint, additionalTokensRecipient, payer = this.provider.publicKey }: { + launch: PublicKey; + baseMint: PublicKey; + additionalTokensRecipient: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return this.launchpad.methods.claimAdditionalTokenAllocation().accounts({ + launch, payer, launchSigner, + launchBaseVault: getAssociatedTokenAddressSync(baseMint, launchSigner, true), + baseMint, additionalTokensRecipient, + additionalTokensRecipientTokenAccount: getAssociatedTokenAddressSync( + baseMint, additionalTokensRecipient, true, + ), + }); + } + + extendLaunchIx({ launch, durationSeconds, admin = METADAO_MULTISIG_VAULT }: { + launch: PublicKey; + durationSeconds: number; + admin?: PublicKey; + }) { + return this.launchpad.methods.extendLaunch({ durationSeconds }).accounts({ + launch, admin, + }); + } +} +``` + +### `constants.ts` addition + +```typescript +// Add to sdk2/src/constants.ts +export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey("MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg"); +``` + +--- + +## Tests + +### Directory: `tests/launchpad_v8/` + +``` +tests/launchpad_v8/ +├── main.test.ts +├── utils.ts +└── unit/ + ├── initializeLaunch.test.ts + ├── startLaunch.test.ts + ├── fund.test.ts + ├── closeLaunch.test.ts + ├── setFundingRecordApproval.test.ts + ├── settleLaunch.test.ts + ├── finalizeLaunch.test.ts + ├── claim.test.ts + ├── refund.test.ts + ├── claimAdditionalTokenAllocation.test.ts + └── extendLaunch.test.ts +``` + +### `utils.ts` + +Same pattern as v7 but targeting the v0.8 client: +- `initializeMintWithSeeds()` — creates a fresh mint with deterministic PDA +- Helpers to set up a full launch lifecycle (init → start → fund → close → approve → settle) + +### Test Cases + +Each `it()` block below maps 1:1 to a test. Tests marked **(v8-new)** are new for v8; all others carry over from v7. + +#### `initializeLaunch.test.ts` + +1. "initializes a launch with valid parameters" + — Launch account state = Initialized, all fields correct, mint_governor stored + — **(v8-new)** MintGovernor PDA initialized with admin = launch_signer, create_key = launch_signer + — **(v8-new)** MintAuthority for launch_signer created with correct max_total + — **(v8-new)** SPL mint authority is the MintGovernor PDA (not launch_signer) + — **(v8-new)** base_vault has zero balance, base_mint.supply == 0 +2. "fails when monthly spending limit members contains duplicates" +3. "fails when monthly spending limit members is empty" +4. "rejects accumulator activation delay >= seconds_for_launch" +5. "fails when launch signer is faked" — ConstraintSeeds error + +#### `startLaunch.test.ts` + +6. "starts launch correctly" — sets unix_timestamp_started, state = Live + +#### `fund.test.ts` + +7. "fails to fund the launch before it's started" — InvalidLaunchState +8. "successfully funds the launch" — transfers USDC, creates FundingRecord +9. "successfully funds the launch multiple times" — amounts accumulate correctly +10. "fails to fund the launch at the exact boundary second" — LaunchExpired at exact expiration +11. "fails to fund the launch after time expires" — LaunchExpired +12. "accumulator starts at 0 and last_accumulator_update is set on first fund" +13. "accumulator correctly sums across multiple time intervals" +14. "accumulator stays 0 during activation delay period" +15. "accumulator only counts time after activation delay" + +#### `closeLaunch.test.ts` + +16. "successfully closes launch after sufficient time when minimum raise is met" — state = Closed +17. "successfully closes launch after sufficient time when minimum raise is not met" — state = Refunding +18. "fails to close launch before sufficient time has passed" — LaunchPeriodNotOver +19. "fails to close launch when launch has already been closed" — LaunchNotLive +20. "fails to close launch when launch is still in Initialized state" — LaunchNotLive + +#### `setFundingRecordApproval.test.ts` + +21. "can set funding record approval for full, partial, and zero amounts" +22. "correctly updates the launch account total approved amount" — multiple funders +23. "can't set funding record approval before the launch period ends" — InvalidLaunchState +24. "can't set funding record approval after the funding record approval period ends (2 days)" — FundingRecordApprovalPeriodOver +25. "can't set funding record approval after the launch is completed" — InvalidLaunchState +26. "can't set funding record approval to an amount greater than the committed amount" — InsufficientFunds + +#### `settleLaunch.test.ts` + +27. "settles launch successfully when minimum raise is met" + — **(v8-new)** tokens minted via MintGovernor (correct total = participants + futarchy_liq + damm_liq + additional) + — **(v8-new)** base_mint.supply == expected total + — **(v8-new)** MintAuthority.total_minted updated + — **(v8-new)** MintGovernor admin is still launch_signer (NOT transferred yet) + — DAO created, Futarchy AMM has liquidity, Meteora pool created + — metadata update_authority transferred to DAO + — USDC transferred to DAO treasury, state = Complete +28. "sends all USDC to treasury when hasBidWall is false even with excess funding" +29. "initializes bid wall when hasBidWall is true and funding exceeds 1.25x minimum raise" +30. "does not initialize bid wall when hasBidWall is true and funding equals minimum raise" +31. "does not initialize bid wall when hasBidWall is true and funding is exactly 1.25x minimum raise" — boundary +32. "sets state to Refunding when total_approved_amount < minimum_raise_amount" — no tokens minted, no DAO +33. "fails when launch is in refunding state" — InvalidLaunchState + +#### `finalizeLaunch.test.ts` + +34. "finalizes launch successfully after settle" + — PP v2 MintAuthority created with authorized_minter = PP PDA, max_total = pp_token_amount + — PP v2 account: oracle_reader = FutarchyTwap (amm = dao, min_duration = 3 months) + — PP v2 account: reward_function = Threshold with 5 tranches at 2x/4x/8x/16x/32x + — PP v2 account: recipient = performance_package_grantee, authority = squads_multisig_vault + — PP v2 account: min_unlock_timestamp = completion_time + lockup months + — MintGovernor admin transferred to squads_multisig_vault + — is_performance_package_initialized = true +35. "fails when launch state is not Complete" — InvalidLaunchState +36. "can finalize only once" — PerformancePackageAlreadyInitialized + +#### `claim.test.ts` + +37. "successfully claims tokens after launch completion" — proportional amount +38. "fails when launch is not complete" — InvalidLaunchState + +#### `refund.test.ts` + +39. "allows refunds when launch is in refunding state" — full committed_amount +40. "works for oversubscribed launches" — refund = committed - approved +41. "fails when launch is not in refunding or complete state" — LaunchNotRefunding + +#### `claimAdditionalTokenAllocation.test.ts` + +42. "sets and claims additional token allocation successfully, and only once" +43. "fails to claim additional token allocation if the launch doesn't have one" — NoAdditionalTokensRecipientSet + +#### `extendLaunch.test.ts` + +44. "successfully extends a live launch" — seconds_for_launch increases +45. "funders can still fund after original deadline if extended" +46. "close_launch respects new extended deadline" — fails before new deadline + +### Integration Test + +``` +tests/integration/launchpad_v8_full_lifecycle.test.ts +``` + +End-to-end test covering the full lifecycle including PP v2 unlock: +1. `initialize_launch` → verify zero supply, MintGovernor setup +2. `start_launch` +3. Multiple `fund` calls from different funders +4. Wait for launch period → `close_launch` +5. `set_funding_record_approval` for each funder +6. `settle_launch` → verify minting, DAO creation +7. `finalize_launch` → verify PP v2 setup, admin transfer +8. `claim` for each funder +9. `refund` for over-committed funders +10. `claim_additional_token_allocation` +11. (Optional) PP v2 `start_unlock` + `complete_unlock` cycle — verify tokens minted on demand via MintGovernor + +--- + +## CPI Chain Summary + +``` +v08_launchpad::initialize_launch + ├── mpl_token_metadata::create_metadata_accounts_v3 + ├── mint_governor::initialize_mint_governor + ├── mint_governor::add_mint_authority (launch_signer) + └── mint_governor::transfer_authority_to_governor + +v08_launchpad::settle_launch + ├── mint_governor::mint_tokens → base_vault + ├── futarchy::initialize_dao + ├── futarchy::provide_liquidity + ├── bid_wall::initialize_bid_wall (if configured) + ├── damm_v2::initialize_pool_with_dynamic_config + ├── mpl_token_metadata::update_metadata_accounts_v2 + └── token::transfer (USDC → DAO treasury) + +v08_launchpad::finalize_launch + ├── mint_governor::add_mint_authority (PP v2 PDA) + ├── performance_package_v2::initialize_performance_package + └── mint_governor::update_mint_governor_admin → DAO +``` + +--- + +## Implementation Order + +Build incrementally — each phase produces a testable program. Later phases layer on top without breaking earlier work. + +### Phase 1: Scaffolding + State + +Set up the `v08_launchpad` program crate, `lib.rs` with empty instruction stubs, constants, error enum, events module, and the `Launch` / `FundingRecord` state structs (with the new `mint_governor` field). Wire up Cargo dependencies (`mint_governor`, `performance_package_v2`, etc.). Add SDK2 `launchpad/v0.8/` directory with PDA helpers and type stubs. + +Verify: `anchor build -p v08_launchpad` compiles. + +### Phase 2: `initialize_launch` + +The entry point — everything depends on this. Implement the full instruction including the MintGovernor CPI chain (init governor → add mint authority → transfer authority). No minting. + +**Tests:** #1–5 + +### Phase 3: `start_launch` + `fund` + `close_launch` + +These are unchanged from v7 and can be ported directly. They form the fundraising lifecycle that `settle_launch` depends on. + +**Tests:** #6–20 + +### Phase 4: `set_funding_record_approval` + +Unchanged from v7. Needed before settle_launch can run on the happy path (approved amounts determine what gets minted). + +**Tests:** #21–26 + +### Phase 5: `settle_launch` + +The big one — mints tokens via MintGovernor then runs the full DAO/liquidity/Meteora flow. This is the most complex instruction and requires phases 2–4 to be working. + +**Tests:** #27–33 + +### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` + +Unchanged from v7. These operate on the post-settle state. + +**Tests:** #37–43 + +### Phase 7: `finalize_launch` + +The final instruction — adds PP v2 as authorized minter, initializes PP v2, transfers MintGovernor admin to DAO. Requires settle_launch to have run. + +**Tests:** #34–36 + +### Phase 8: `extend_launch` + +Unchanged from v7. Low priority since it's an admin-only emergency lever. + +**Tests:** #44–46 + +### Phase 9: Integration test + +Full lifecycle end-to-end — see Integration Test section above. diff --git a/vibes/task-template.md b/vibes/task-template.md new file mode 100644 index 000000000..85574d7c5 --- /dev/null +++ b/vibes/task-template.md @@ -0,0 +1,54 @@ +# [Feature Name] Implementation Tasks + +## Instructions for Claude + +**READ THIS FIRST:** + +1. Look at this file and find the task marked with `[NEXT]` +2. Read the referenced section in `vibes/[implementation-plan].md` for full context +3. Do ONLY that task - nothing else +4. After completing the task, verify with `[verification command]` +5. If successful, remove the completed task from this file +6. Mark the next task with `[NEXT]` +7. Stop and wait for the user + +**DO NOT:** +- Do multiple tasks at once +- Skip ahead +- Forget to verify + +**Reference:** Full implementation plan is in `vibes/[implementation-plan].md` + +--- + +## Tasks + +### Phase N: [Phase Name] + +> Reference: `[implementation-plan].md` → "Phase N: [Phase Name]" + +- [NEXT] N.1 [Task title] + - [Detail about what to do] + - [Another detail] + - [File to create/modify] + +- [ ] N.2 [Task title] + - Reference: Section N.2 + - [Detail about what to do] + - [Accounts/Args/Other specifics] + +- [ ] N.3 [Task title] + - Reference: Section N.3 + - [Detail 1] + - [Detail 2] + - [Detail 3] + +### Phase M: [Next Phase Name] + +> Reference: `[implementation-plan].md` → "Phase M: [Next Phase Name]" + +- [ ] M.1 [Task title] + - [Details...] + +- [ ] M.2 [Task title] + - [Details...] diff --git a/vibes/tasks.md b/vibes/tasks.md new file mode 100644 index 000000000..b33d414f7 --- /dev/null +++ b/vibes/tasks.md @@ -0,0 +1,246 @@ +# Launchpad v8 Implementation Tasks + +## Instructions for Claude + +**READ THIS FIRST:** + +1. Look at this file and find the task marked with `[NEXT]` +2. Read the referenced section in `vibes/launchpad_v8_spec.md` for full context +3. Do ONLY that task - nothing else +4. After completing the task, verify with the specified verification command +5. If successful, remove the completed task from this file +6. Mark the next task with `[NEXT]` +7. Stop and wait for the user + +**DO NOT:** +- Do multiple tasks at once +- Skip ahead +- Forget to verify + +**Reference:** Full implementation plan is in `vibes/launchpad_v8_spec.md` + +--- + +## Tasks + +### Phase 1: Scaffolding + State + +> Reference: `launchpad_v8_spec.md` → "Constants", "State", "Errors", "Events" + +- [NEXT] 1.2 Add constants, state, errors, and events + - Create `src/state/launch.rs` with the `Launch` struct (including new `mint_governor` field) + - Create `src/state/funding_record.rs` with `FundingRecord` struct (unchanged from v7) + - Create `src/state/mod.rs` + - Create `src/error.rs` with all error variants from spec + - Create `src/events.rs` with all events from spec (using `CommonFields` pattern) + - Add constants to `lib.rs` (TOKEN_SCALE, PRICE_SCALE, TOKENS_TO_*, PP_* constants) + - Create `src/instructions/mod.rs` (empty, will be populated in later phases) + - Verify: `anchor build -p v08_launchpad` + +- [ ] 1.3 SDK2 scaffolding + - Add `LAUNCHPAD_V0_8_PROGRAM_ID` to `sdk2/src/constants.ts` + - Create `sdk2/src/launchpad/v0.8/pda.ts` with `getLaunchAddr`, `getLaunchSignerAddr`, `getFundingRecordAddr` + - Create `sdk2/src/launchpad/v0.8/types/index.ts` (stub — types will be generated after first build) + - Create `sdk2/src/launchpad/v0.8/index.ts` (re-exports) + - Create `sdk2/src/launchpad/v0.8/LaunchpadClient.ts` with constructor, `createClient`, fetch/deserialize methods, and address derivation helpers (no instruction builders yet) + - Verify: SDK compiles (`cd sdk2 && npx tsc --noEmit`) + +- [ ] 1.4 Test scaffolding + - Create `tests/launchpad_v8/main.test.ts` with bankrun setup (model after `tests/launchpad_v7/main.test.ts`) + - Create `tests/launchpad_v8/utils.ts` with `initializeMintWithSeeds` helper targeting v0.8 client + - Create empty unit test files in `tests/launchpad_v8/unit/` for all 11 instruction test suites + - Verify: `anchor test --skip-build` runs (tests pass vacuously since empty) + +### Phase 2: `initialize_launch` + +> Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" + +- [ ] 2.1 Implement `initialize_launch` instruction (Rust) + - Create `src/instructions/initialize_launch.rs` with `InitializeLaunchArgs`, `InitializeLaunch` accounts struct, `validate()`, and `handle()` + - Port validation logic from v7 + - Implement handler: init Launch state, create metadata CPI, MintGovernor CPI chain (init governor → add mint authority → transfer authority) + - NO token::mint_to — base vault stays empty + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 2.2 Add `initializeLaunchIx` to SDK2 client + - Add the instruction builder method to `LaunchpadClient.ts` per spec + - Derives MintGovernor + MintAuthority PDAs, passes all new accounts + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 2.3 Write `initializeLaunch` tests (tests #1–5) + - Test #1: "initializes a launch with valid parameters" — verify all Launch fields, MintGovernor setup, mint authority transfer, zero supply + - Test #2: "fails when monthly spending limit members contains duplicates" + - Test #3: "fails when monthly spending limit members is empty" + - Test #4: "rejects accumulator activation delay >= seconds_for_launch" + - Test #5: "fails when launch signer is faked" + - Verify: `anchor test --skip-build` (with `.only` on this suite) + +### Phase 3: `start_launch` + `fund` + `close_launch` + +> Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 + +- [ ] 3.1 Implement `start_launch` instruction (Rust) + - Create `src/instructions/start_launch.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 3.2 Implement `fund` instruction (Rust) + - Create `src/instructions/fund.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 3.3 Implement `close_launch` instruction (Rust) + - Create `src/instructions/close_launch.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 3.4 Add `startLaunchIx`, `fundIx`, `closeLaunchIx` to SDK2 client + - Port from v7 SDK2 client, targeting v0.8 program + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 3.5 Write `startLaunch` tests (test #6) + - Test #6: "starts launch correctly" + - Verify: `anchor test --skip-build` (with `.only`) + +- [ ] 3.6 Write `fund` tests (tests #7–15) + - Tests #7–15: all fund tests per spec + - Verify: `anchor test --skip-build` (with `.only`) + +- [ ] 3.7 Write `closeLaunch` tests (tests #16–20) + - Tests #16–20: all close_launch tests per spec + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 4: `set_funding_record_approval` + +> Reference: `launchpad_v8_spec.md` → instruction 4 + +- [ ] 4.1 Implement `set_funding_record_approval` instruction (Rust) + - Create `src/instructions/set_funding_record_approval.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 4.2 Add `setFundingRecordApprovalIx` to SDK2 client + - Port from v7 SDK2 client + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 4.3 Write `setFundingRecordApproval` tests (tests #21–26) + - Tests #21–26: all set_funding_record_approval tests per spec + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 5: `settle_launch` + +> Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" + +- [ ] 5.1 Implement `settle_launch` instruction (Rust) + - Create `src/instructions/settle_launch.rs` with `SettleLaunch` accounts struct, `validate()`, and `handle()` + - Port from v7 `complete_launch` with key changes: mint_governor::mint_tokens CPI replaces token::set_authority, no mint authority transfer + - Include StaticCompleteLaunchAccounts and MeteoraAccounts nested structs + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 5.2 Add `settleLaunchIx` to SDK2 client + - Add the instruction builder method per spec (includes MintGovernor + Meteora + DAO account derivation) + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 5.3 Write `settleLaunch` tests (tests #27–33) + - Test #27: happy path — tokens minted via MintGovernor, DAO created, liquidity, metadata transfer, USDC distribution, MintGovernor admin still launch_signer + - Test #28: sends all USDC to treasury when hasBidWall is false + - Test #29: initializes bid wall when hasBidWall is true and funding exceeds 1.25x + - Test #30: no bid wall when funding equals minimum raise + - Test #31: no bid wall at exactly 1.25x boundary + - Test #32: Refunding path — no tokens minted, no DAO + - Test #33: fails when launch is in refunding state + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` + +> Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 + +- [ ] 6.1 Implement `claim` instruction (Rust) + - Create `src/instructions/claim.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 6.2 Implement `refund` instruction (Rust) + - Create `src/instructions/refund.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 6.3 Implement `claim_additional_token_allocation` instruction (Rust) + - Create `src/instructions/claim_additional_token_allocation.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 6.4 Add `claimIx`, `refundIx`, `claimAdditionalTokenAllocationIx` to SDK2 client + - Port from v7 SDK2 client + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 6.5 Write `claim` tests (tests #37–38) + - Test #37: "successfully claims tokens after launch completion" + - Test #38: "fails when launch is not complete" + - Verify: `anchor test --skip-build` (with `.only`) + +- [ ] 6.6 Write `refund` tests (tests #39–41) + - Test #39: "allows refunds when launch is in refunding state" + - Test #40: "works for oversubscribed launches" + - Test #41: "fails when launch is not in refunding or complete state" + - Verify: `anchor test --skip-build` (with `.only`) + +- [ ] 6.7 Write `claimAdditionalTokenAllocation` tests (tests #42–43) + - Test #42: "sets and claims additional token allocation successfully, and only once" + - Test #43: "fails to claim additional token allocation if the launch doesn't have one" + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 7: `finalize_launch` + +> Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" + +- [ ] 7.1 Implement `finalize_launch` instruction (Rust) + - Create `src/instructions/finalize_launch.rs` with `FinalizeLaunch` accounts struct, `validate()`, and `handle()` + - Handler: compute tranches, CPI add_mint_authority (PP v2 PDA), CPI initialize_performance_package, CPI update_mint_governor_admin + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 7.2 Add `finalizeLaunchIx` to SDK2 client + - Add the instruction builder method per spec + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 7.3 Write `finalizeLaunch` tests (tests #34–36) + - Test #34: happy path — PP v2 setup (tranches, oracle, recipient, authority), MintGovernor admin transferred to DAO + - Test #35: "fails when launch state is not Complete" + - Test #36: "can finalize only once" + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 8: `extend_launch` + +> Reference: `launchpad_v8_spec.md` → instruction 11 + +- [ ] 8.1 Implement `extend_launch` instruction (Rust) + - Create `src/instructions/extend_launch.rs` — port from v7 + - Wire into `lib.rs` and `instructions/mod.rs` + - Verify: `./rebuild.sh` + +- [ ] 8.2 Add `extendLaunchIx` to SDK2 client + - Port from v7 SDK2 client + - Verify: `cd sdk2 && npx tsc --noEmit` + +- [ ] 8.3 Write `extendLaunch` tests (tests #44–46) + - Test #44: "successfully extends a live launch" + - Test #45: "funders can still fund after original deadline if extended" + - Test #46: "close_launch respects new extended deadline" + - Verify: `anchor test --skip-build` (with `.only`) + +### Phase 9: Integration + Full Suite + +> Reference: `launchpad_v8_spec.md` → "Integration Test" + +- [ ] 9.1 Write integration test + - Create `tests/integration/launchpad_v8_full_lifecycle.test.ts` + - Full lifecycle: init → start → fund (multiple funders) → close → approve → settle → finalize → claim → refund → claim_additional + - Verify: `anchor test --skip-build` (with `.only` on integration suite) + +- [ ] 9.2 Run full test suite + - Remove all `.only` markers + - Run `anchor test` (full build + all tests) + - All 46 unit tests + integration test must pass From 1841481926f41470c9450c6d852baa6460ed86a0 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 9 Apr 2026 23:39:05 +0200 Subject: [PATCH 038/100] launchpad v8 scaffolding --- programs/v08_launchpad/src/error.rs | 69 +++++++++ programs/v08_launchpad/src/events.rs | 141 ++++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 1 + programs/v08_launchpad/src/lib.rs | 4 + .../v08_launchpad/src/state/funding_record.rs | 25 ++++ programs/v08_launchpad/src/state/launch.rs | 96 ++++++++++++ programs/v08_launchpad/src/state/mod.rs | 5 + vibes/tasks.md | 12 +- 8 files changed, 342 insertions(+), 11 deletions(-) create mode 100644 programs/v08_launchpad/src/error.rs create mode 100644 programs/v08_launchpad/src/events.rs create mode 100644 programs/v08_launchpad/src/instructions/mod.rs create mode 100644 programs/v08_launchpad/src/state/funding_record.rs create mode 100644 programs/v08_launchpad/src/state/launch.rs create mode 100644 programs/v08_launchpad/src/state/mod.rs diff --git a/programs/v08_launchpad/src/error.rs b/programs/v08_launchpad/src/error.rs new file mode 100644 index 000000000..881a619b3 --- /dev/null +++ b/programs/v08_launchpad/src/error.rs @@ -0,0 +1,69 @@ +use anchor_lang::prelude::*; + +#[error_code] +pub enum LaunchpadError { + #[msg("Invalid amount")] + InvalidAmount, + #[msg("Supply must be zero")] + SupplyNonZero, + #[msg("Launch period must be between 1 hour and 2 weeks")] + InvalidSecondsForLaunch, + #[msg("Insufficient funds")] + InsufficientFunds, + #[msg("Invalid launch state")] + InvalidLaunchState, + #[msg("Launch period not over")] + LaunchPeriodNotOver, + #[msg("Launch is complete, no more funding allowed")] + LaunchExpired, + #[msg("Refund not available")] + LaunchNotRefunding, + #[msg("Launch must be initialized to be started")] + LaunchNotInitialized, + #[msg("Freeze authority can't be set on launchpad tokens")] + FreezeAuthoritySet, + #[msg("Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0")] + InvalidMonthlySpendingLimit, + #[msg("There can only be at most 10 monthly spending limit members")] + InvalidMonthlySpendingLimitMembers, + #[msg("Invalid performance package token amount")] + InvalidPerformancePackageTokenAmount, + #[msg("Insiders must wait at least 12 months before unlocking")] + InvalidPerformancePackageMinUnlockTime, + #[msg("Launch authority must be set to complete the launch until 2 days after closing")] + LaunchAuthorityNotSet, + #[msg("The final amount raised must be >= the minimum raise amount")] + FinalRaiseAmountTooLow, + #[msg("Tokens already claimed")] + TokensAlreadyClaimed, + #[msg("USDC already refunded")] + MoneyAlreadyRefunded, + #[msg("Invariant violated")] + InvariantViolated, + #[msg("Launch must be live to be closed")] + LaunchNotLive, + #[msg("Minimum raise amount too low for liquidity")] + InvalidMinimumRaiseAmount, + #[msg("Final raise amount already set")] + FinalRaiseAmountAlreadySet, + #[msg("Total approved amount too low")] + TotalApprovedAmountTooLow, + #[msg("Additional tokens recipient must be set when amount > 0")] + InvalidAdditionalTokensRecipient, + #[msg("No additional tokens recipient set")] + NoAdditionalTokensRecipientSet, + #[msg("Additional tokens already claimed")] + AdditionalTokensAlreadyClaimed, + #[msg("Funding record approval period is over")] + FundingRecordApprovalPeriodOver, + #[msg("Performance package already initialized")] + PerformancePackageAlreadyInitialized, + #[msg("Invalid DAO")] + InvalidDao, + #[msg("Accumulator activation delay must be less than the launch duration")] + InvalidAccumulatorActivationDelaySeconds, + #[msg("Extend duration would exceed maximum allowed launch duration")] + ExtendDurationExceedsMax, + #[msg("Mint authority does not match expected")] + InvalidMintAuthority, +} diff --git a/programs/v08_launchpad/src/events.rs b/programs/v08_launchpad/src/events.rs new file mode 100644 index 000000000..3b1a25750 --- /dev/null +++ b/programs/v08_launchpad/src/events.rs @@ -0,0 +1,141 @@ +use crate::state::LaunchState; +use anchor_lang::prelude::*; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct CommonFields { + pub slot: u64, + pub unix_timestamp: i64, + pub launch_seq_num: u64, +} + +impl CommonFields { + pub fn new(clock: &Clock, launch_seq_num: u64) -> Self { + Self { + slot: clock.slot, + unix_timestamp: clock.unix_timestamp, + launch_seq_num, + } + } +} + +#[event] +pub struct LaunchInitializedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub minimum_raise_amount: u64, + pub launch_authority: Pubkey, + pub launch_signer: Pubkey, + pub launch_signer_pda_bump: u8, + pub launch_usdc_vault: Pubkey, + pub launch_token_vault: Pubkey, + pub performance_package_grantee: Pubkey, + pub performance_package_token_amount: u64, + pub months_until_insiders_can_unlock: u8, + pub monthly_spending_limit_amount: u64, + pub monthly_spending_limit_members: Vec, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, + pub pda_bump: u8, + pub seconds_for_launch: u32, + pub additional_tokens_amount: u64, + pub additional_tokens_recipient: Option, + pub accumulator_activation_delay_seconds: u32, + pub has_bid_wall: bool, + pub mint_governor: Pubkey, +} + +#[event] +pub struct LaunchStartedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub launch_authority: Pubkey, + pub slot_started: u64, +} + +#[event] +pub struct LaunchFundedEvent { + pub common: CommonFields, + pub funding_record: Pubkey, + pub launch: Pubkey, + pub funder: Pubkey, + pub amount: u64, + pub total_committed_by_funder: u64, + pub total_committed: u64, + pub committed_amount_accumulator: u128, +} + +#[event] +pub struct FundingRecordApprovalSetEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funding_record: Pubkey, + pub funder: Pubkey, + pub approved_amount: u64, + pub total_approved: u64, +} + +#[event] +pub struct LaunchSettledEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub final_state: LaunchState, + pub total_committed: u64, + pub dao: Option, + pub dao_treasury: Option, + pub total_approved_amount: u64, + pub bid_wall: Option, + pub bid_wall_amount: u64, + pub mint_governor: Pubkey, + pub tokens_minted: u64, +} + +#[event] +pub struct LaunchFinalizedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub performance_package: Pubkey, + pub mint_governor: Pubkey, + pub mint_governor_new_admin: Pubkey, + pub pp_mint_authority: Pubkey, +} + +#[event] +pub struct LaunchRefundedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funder: Pubkey, + pub usdc_refunded: u64, + pub funding_record: Pubkey, +} + +#[event] +pub struct LaunchClaimEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub funder: Pubkey, + pub tokens_claimed: u64, + pub funding_record: Pubkey, +} + +#[event] +pub struct LaunchCloseEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub new_state: LaunchState, +} + +#[event] +pub struct LaunchClaimAdditionalTokenAllocationEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub additional_tokens_amount: u64, + pub additional_tokens_recipient: Pubkey, +} + +#[event] +pub struct LaunchExtendedEvent { + pub common: CommonFields, + pub launch: Pubkey, + pub old_seconds_for_launch: u32, + pub new_seconds_for_launch: u32, +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -0,0 +1 @@ + diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 57edb826f..06f078429 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -2,6 +2,10 @@ use anchor_lang::prelude::*; pub mod allocator; +pub mod error; +pub mod events; +pub mod instructions; +pub mod state; #[cfg(not(feature = "no-entrypoint"))] use solana_security_txt::security_txt; diff --git a/programs/v08_launchpad/src/state/funding_record.rs b/programs/v08_launchpad/src/state/funding_record.rs new file mode 100644 index 000000000..a3e03f68c --- /dev/null +++ b/programs/v08_launchpad/src/state/funding_record.rs @@ -0,0 +1,25 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(InitSpace)] +pub struct FundingRecord { + /// The PDA bump. + pub pda_bump: u8, + /// The funder. + pub funder: Pubkey, + /// The launch. + pub launch: Pubkey, + /// The amount of USDC that has been committed by the funder. + pub committed_amount: u64, + /// Whether the tokens have been claimed. + pub is_tokens_claimed: bool, + /// Whether the USDC has been refunded. + pub is_usdc_refunded: bool, + /// The amount of USDC that the launch authority has approved for the funder. + /// If zero, the funder has not been approved for any amount. + pub approved_amount: u64, + /// Running integral of committed_amount over time (committed_amount * seconds). + pub committed_amount_accumulator: u128, + /// Unix timestamp of the last accumulator update. + pub last_accumulator_update: i64, +} diff --git a/programs/v08_launchpad/src/state/launch.rs b/programs/v08_launchpad/src/state/launch.rs new file mode 100644 index 000000000..5558c90b9 --- /dev/null +++ b/programs/v08_launchpad/src/state/launch.rs @@ -0,0 +1,96 @@ +use anchor_lang::prelude::*; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, InitSpace)] +pub enum LaunchState { + Initialized, + Live, + Closed, + Complete, + Refunding, +} + +impl ToString for LaunchState { + fn to_string(&self) -> String { + match self { + LaunchState::Initialized => "Initialized", + LaunchState::Live => "Live", + LaunchState::Closed => "Closed", + LaunchState::Complete => "Complete", + LaunchState::Refunding => "Refunding", + } + .to_string() + } +} + +#[account] +#[derive(InitSpace)] +pub struct Launch { + /// The PDA bump. + pub pda_bump: u8, + /// The minimum amount of USDC that must be raised, otherwise + /// everyone can get their USDC back. + pub minimum_raise_amount: u64, + /// The monthly spending limit the DAO allocates to the team. Must be + /// less than 1/6th of the minimum raise amount (so 6 months of burn). + pub monthly_spending_limit_amount: u64, + /// The wallets that have access to the monthly spending limit. + #[max_len(10)] + pub monthly_spending_limit_members: Vec, + /// The account that can start the launch. + pub launch_authority: Pubkey, + /// The launch signer address. + pub launch_signer: Pubkey, + /// The PDA bump for the launch signer. + pub launch_signer_pda_bump: u8, + /// The USDC vault that will hold the USDC raised until the launch is over. + pub launch_quote_vault: Pubkey, + /// The token vault, used to send tokens to the AMM. + pub launch_base_vault: Pubkey, + /// The token that will be minted to funders and that will control the DAO. + pub base_mint: Pubkey, + /// The USDC mint. + pub quote_mint: Pubkey, + /// The unix timestamp when the launch was started. + pub unix_timestamp_started: Option, + /// The unix timestamp when the launch stopped taking new contributions. + pub unix_timestamp_closed: Option, + /// The amount of USDC that has been committed by the users. + pub total_committed_amount: u64, + /// The state of the launch. + pub state: LaunchState, + /// The sequence number of this launch. Useful for sorting events. + pub seq_num: u64, + /// The number of seconds that the launch will be live for. + pub seconds_for_launch: u32, + /// The DAO, if the launch is complete. + pub dao: Option, + /// The DAO treasury that USDC / LP is sent to, if the launch is complete. + pub dao_vault: Option, + /// The address that will receive the performance package tokens. + pub performance_package_grantee: Pubkey, + /// The amount of tokens to be granted to the performance package grantee. + pub performance_package_token_amount: u64, + /// The number of months that insiders must wait before unlocking their tokens. + pub months_until_insiders_can_unlock: u8, + /// The initial address used to sponsor team proposals. + pub team_address: Pubkey, + /// The amount of USDC that the launch authority has approved across all funders. + pub total_approved_amount: u64, + /// The amount of additional tokens to be minted on a successful launch. + pub additional_tokens_amount: u64, + /// The token account that will receive the additional tokens. + pub additional_tokens_recipient: Option, + /// Are the additional tokens claimed. + pub additional_tokens_claimed: bool, + /// The unix timestamp when the launch was completed. + pub unix_timestamp_completed: Option, + /// Whether the performance package has been initialized. + pub is_performance_package_initialized: bool, + /// Number of seconds after launch start before the funding accumulator + /// begins tracking. + pub accumulator_activation_delay_seconds: u32, + /// Whether the launch has a bid wall. + pub has_bid_wall: bool, + /// The MintGovernor PDA that owns the SPL mint authority. + pub mint_governor: Pubkey, +} diff --git a/programs/v08_launchpad/src/state/mod.rs b/programs/v08_launchpad/src/state/mod.rs new file mode 100644 index 000000000..d1d1adddc --- /dev/null +++ b/programs/v08_launchpad/src/state/mod.rs @@ -0,0 +1,5 @@ +pub mod funding_record; +pub mod launch; + +pub use funding_record::*; +pub use launch::*; diff --git a/vibes/tasks.md b/vibes/tasks.md index b33d414f7..e3494c432 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -27,17 +27,7 @@ > Reference: `launchpad_v8_spec.md` → "Constants", "State", "Errors", "Events" -- [NEXT] 1.2 Add constants, state, errors, and events - - Create `src/state/launch.rs` with the `Launch` struct (including new `mint_governor` field) - - Create `src/state/funding_record.rs` with `FundingRecord` struct (unchanged from v7) - - Create `src/state/mod.rs` - - Create `src/error.rs` with all error variants from spec - - Create `src/events.rs` with all events from spec (using `CommonFields` pattern) - - Add constants to `lib.rs` (TOKEN_SCALE, PRICE_SCALE, TOKENS_TO_*, PP_* constants) - - Create `src/instructions/mod.rs` (empty, will be populated in later phases) - - Verify: `anchor build -p v08_launchpad` - -- [ ] 1.3 SDK2 scaffolding +- [NEXT] 1.3 SDK2 scaffolding - Add `LAUNCHPAD_V0_8_PROGRAM_ID` to `sdk2/src/constants.ts` - Create `sdk2/src/launchpad/v0.8/pda.ts` with `getLaunchAddr`, `getLaunchSignerAddr`, `getFundingRecordAddr` - Create `sdk2/src/launchpad/v0.8/types/index.ts` (stub — types will be generated after first build) From 04c649976d8db2a9b6354ccbff17b06361ef4ed3 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 9 Apr 2026 23:50:41 +0200 Subject: [PATCH 039/100] sdk scaffolding --- sdk2/src/constants.ts | 3 + sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 136 +++++++++++++++++++++ sdk2/src/launchpad/v0.8/index.ts | 3 + sdk2/src/launchpad/v0.8/pda.ts | 33 +++++ sdk2/src/launchpad/v0.8/types/index.ts | 3 + vibes/tasks.md | 10 +- 6 files changed, 179 insertions(+), 9 deletions(-) create mode 100644 sdk2/src/launchpad/v0.8/LaunchpadClient.ts create mode 100644 sdk2/src/launchpad/v0.8/index.ts create mode 100644 sdk2/src/launchpad/v0.8/pda.ts create mode 100644 sdk2/src/launchpad/v0.8/types/index.ts diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index 9aebc0669..6a41f5b65 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -34,6 +34,9 @@ export const LAUNCHPAD_V0_6_PROGRAM_ID = new PublicKey( export const LAUNCHPAD_V0_7_PROGRAM_ID = new PublicKey( "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM", ); +export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey( + "MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg", +); export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", ); diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts new file mode 100644 index 000000000..786b9799d --- /dev/null +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -0,0 +1,136 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { PublicKey, AccountInfo } from "@solana/web3.js"; +import { LAUNCHPAD_V0_8_PROGRAM_ID } from "../../constants.js"; +import BN from "bn.js"; +import { + getFundingRecordAddr, + getLaunchAddr, + getLaunchSignerAddr, +} from "./pda.js"; + +import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; +import { + PerformancePackageV2Client, + getPerformancePackageV2Addr, +} from "../../performance_package_v2/v0.7/index.js"; +import { BidWallClient } from "../../bid_wall/v0.7/index.js"; + +export type CreateLaunchpadClientParams = { + provider: AnchorProvider; + launchpadProgramId?: PublicKey; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + performancePackageV2ProgramId?: PublicKey; + bidWallProgramId?: PublicKey; +}; + +export class LaunchpadClient { + public launchpad: Program; + public provider: AnchorProvider; + public autocratClient: FutarchyClient; + public performancePackageV2: PerformancePackageV2Client; + public bidWall: BidWallClient; + + private constructor(params: CreateLaunchpadClientParams) { + this.provider = params.provider; + // IDL will be wired up after first build generates the types + this.launchpad = new Program( + { + version: "0.8.0", + name: "launchpad_v8", + instructions: [], + accounts: [], + events: [], + errors: [], + } as any, + params.launchpadProgramId || LAUNCHPAD_V0_8_PROGRAM_ID, + this.provider, + ); + this.autocratClient = FutarchyClient.createClient({ + provider: this.provider, + autocratProgramId: params.autocratProgramId, + conditionalVaultProgramId: params.conditionalVaultProgramId, + }); + this.performancePackageV2 = PerformancePackageV2Client.createClient({ + provider: this.provider, + programId: params.performancePackageV2ProgramId, + }); + this.bidWall = BidWallClient.createClient({ + provider: this.provider, + bidWallProgramId: params.bidWallProgramId, + }); + } + + static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { + return new LaunchpadClient(params); + } + + getProgramId(): PublicKey { + return this.launchpad.programId; + } + + async getLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetch(launch); + } + + async fetchLaunch(launch: PublicKey): Promise { + return await this.launchpad.account.launch.fetchNullable(launch); + } + + async deserializeLaunch(accountInfo: AccountInfo): Promise { + return this.launchpad.coder.accounts.decode("launch", accountInfo.data); + } + + async getFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetch(fundingRecord); + } + + async fetchFundingRecord(fundingRecord: PublicKey): Promise { + return await this.launchpad.account.fundingRecord.fetchNullable( + fundingRecord, + ); + } + + async deserializeFundingRecord( + accountInfo: AccountInfo, + ): Promise { + return this.launchpad.coder.accounts.decode( + "fundingRecord", + accountInfo.data, + ); + } + + getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { + return getLaunchAddr(this.launchpad.programId, baseMint)[0]; + } + + getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { + return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; + } + + getLaunchPerformancePackageAddress({ + launch, + }: { + launch: PublicKey; + }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return getPerformancePackageV2Addr({ createKey: launchSigner })[0]; + } + + getLaunchDaoAddress({ launch }: { launch: PublicKey }): PublicKey { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner })[0]; + } + + getFundingRecordAddress({ + launch, + funder, + }: { + launch: PublicKey; + funder: PublicKey; + }): PublicKey { + return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; + } +} diff --git a/sdk2/src/launchpad/v0.8/index.ts b/sdk2/src/launchpad/v0.8/index.ts new file mode 100644 index 000000000..b5b9717d0 --- /dev/null +++ b/sdk2/src/launchpad/v0.8/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./LaunchpadClient.js"; diff --git a/sdk2/src/launchpad/v0.8/pda.ts b/sdk2/src/launchpad/v0.8/pda.ts new file mode 100644 index 000000000..b643fc017 --- /dev/null +++ b/sdk2/src/launchpad/v0.8/pda.ts @@ -0,0 +1,33 @@ +import { PublicKey } from "@solana/web3.js"; +import { LAUNCHPAD_V0_8_PROGRAM_ID } from "../../constants.js"; + +export function getLaunchAddr( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + tokenMint: PublicKey, +): [PublicKey, number] { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch"), tokenMint.toBuffer()], + programId, + ); +} + +export const getLaunchSignerAddr = ( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + launch: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("launch_signer"), launch.toBuffer()], + programId, + ); +}; + +export const getFundingRecordAddr = ( + programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, + launch: PublicKey, + funder: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/launchpad/v0.8/types/index.ts b/sdk2/src/launchpad/v0.8/types/index.ts new file mode 100644 index 000000000..628fa674a --- /dev/null +++ b/sdk2/src/launchpad/v0.8/types/index.ts @@ -0,0 +1,3 @@ +// Stub — types will be generated after first build +// Once the IDL is generated, this file will export types from the generated IDL +// similar to v0.7/types/index.ts diff --git a/vibes/tasks.md b/vibes/tasks.md index e3494c432..00c35d81b 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -27,15 +27,7 @@ > Reference: `launchpad_v8_spec.md` → "Constants", "State", "Errors", "Events" -- [NEXT] 1.3 SDK2 scaffolding - - Add `LAUNCHPAD_V0_8_PROGRAM_ID` to `sdk2/src/constants.ts` - - Create `sdk2/src/launchpad/v0.8/pda.ts` with `getLaunchAddr`, `getLaunchSignerAddr`, `getFundingRecordAddr` - - Create `sdk2/src/launchpad/v0.8/types/index.ts` (stub — types will be generated after first build) - - Create `sdk2/src/launchpad/v0.8/index.ts` (re-exports) - - Create `sdk2/src/launchpad/v0.8/LaunchpadClient.ts` with constructor, `createClient`, fetch/deserialize methods, and address derivation helpers (no instruction builders yet) - - Verify: SDK compiles (`cd sdk2 && npx tsc --noEmit`) - -- [ ] 1.4 Test scaffolding +- [NEXT] 1.4 Test scaffolding - Create `tests/launchpad_v8/main.test.ts` with bankrun setup (model after `tests/launchpad_v7/main.test.ts`) - Create `tests/launchpad_v8/utils.ts` with `initializeMintWithSeeds` helper targeting v0.8 client - Create empty unit test files in `tests/launchpad_v8/unit/` for all 11 instruction test suites From 356c8415686f37085f808dbc0f4c0fe931afe27f Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 00:36:45 +0200 Subject: [PATCH 040/100] tests scaffolding --- Anchor.toml | 2 +- programs/v08_launchpad/src/lib.rs | 2 +- sdk/src/v0.7/types/launchpad_v8.ts | 1945 +++++++++++++++++ sdk/src/v0.7/types/v08_launchpad.ts | 123 ++ sdk2/package.json | 1 + sdk2/src/constants.ts | 6 +- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 34 +- sdk2/src/launchpad/v0.8/types/index.ts | 47 +- sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 1945 +++++++++++++++++ sdk2/sync-types.sh | 1 + tests/launchpad_v8/main.test.ts | 66 + tests/launchpad_v8/utils.ts | 58 + tests/main.test.ts | 7 + vibes/launchpad_v8_spec.md | 4 +- vibes/tasks.md | 8 +- 15 files changed, 4217 insertions(+), 32 deletions(-) create mode 100644 sdk/src/v0.7/types/launchpad_v8.ts create mode 100644 sdk/src/v0.7/types/v08_launchpad.ts create mode 100644 sdk2/src/launchpad/v0.8/types/launchpad_v8.ts create mode 100644 tests/launchpad_v8/main.test.ts create mode 100644 tests/launchpad_v8/utils.ts diff --git a/Anchor.toml b/Anchor.toml index fe0a7916d..3016da94a 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -11,7 +11,7 @@ conditional_vault = "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg" futarchy = "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq" launchpad = "MooNyh4CBUYEKyXVnjGYQ8mEiJDpGvJMdvrZx1iGeHV" launchpad_v7 = "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM" -launchpad_v8 = "MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg" +launchpad_v8 = "moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n" liquidation = "LiQnowFbFQdYyZhF4pUbpsrZCjxRTQ1upKJxZ2VXjde" mint_governor = "gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH" performance_package_v2 = "pPV2pfrxnmstSb9j7kEeCLny5BGj6SNwCWGd6xbGGzz" diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 06f078429..de539b3b9 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -21,7 +21,7 @@ security_txt! { acknowledgements: "DCF = (CF1 / (1 + r)^1) + (CF2 / (1 + r)^2) + ... (CFn / (1 + r)^n)" } -declare_id!("MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg"); +declare_id!("moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n"); pub const TOKEN_SCALE: u64 = 1_000_000; diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts new file mode 100644 index 000000000..38972a55c --- /dev/null +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -0,0 +1,1945 @@ +export type LaunchpadV8 = { + version: "0.8.0"; + name: "launchpad_v8"; + instructions: []; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + { + name: "approvedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ]; + type: "u64"; + }, + { + name: "committedAmountAccumulator"; + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ]; + type: "u128"; + }, + { + name: "lastAccumulatorUpdate"; + docs: ["Unix timestamp of the last accumulator update."]; + type: "i64"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: ["The launch signer address."]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to the AMM."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + { + name: "teamAddress"; + docs: ["The initial address used to sponsor team proposals."]; + type: "publicKey"; + }, + { + name: "totalApprovedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ]; + type: "u64"; + }, + { + name: "additionalTokensAmount"; + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ]; + type: "u64"; + }, + { + name: "additionalTokensRecipient"; + docs: [ + "The token account that will receive the additional tokens.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "additionalTokensClaimed"; + docs: ["Are the additional tokens claimed."]; + type: "bool"; + }, + { + name: "unixTimestampCompleted"; + docs: ["The unix timestamp when the launch was completed."]; + type: { + option: "i64"; + }; + }, + { + name: "isPerformancePackageInitialized"; + docs: ["Whether the performance package has been initialized."]; + type: "bool"; + }, + { + name: "accumulatorActivationDelaySeconds"; + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ]; + type: "u32"; + }, + { + name: "hasBidWall"; + docs: ["Whether the launch has a bid wall."]; + type: "bool"; + }, + { + name: "mintGovernor"; + docs: ["The MintGovernor PDA that owns the SPL mint authority."]; + type: "publicKey"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Closed"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + index: false; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + index: false; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + index: false; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + index: false; + }, + { + name: "hasBidWall"; + type: "bool"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "committedAmountAccumulator"; + type: "u128"; + index: false; + }, + ]; + }, + { + name: "FundingRecordApprovalSetEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "approvedAmount"; + type: "u64"; + index: false; + }, + { + name: "totalApproved"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchSettledEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "totalApprovedAmount"; + type: "u64"; + index: false; + }, + { + name: "bidWall"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "bidWallAmount"; + type: "u64"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "tokensMinted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFinalizedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mintGovernorNewAdmin"; + type: "publicKey"; + index: false; + }, + { + name: "ppMintAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchCloseEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "newState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchExtendedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "oldSecondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "newSecondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6005; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6006; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6007; + name: "LaunchNotRefunding"; + msg: "Refund not available"; + }, + { + code: 6008; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6009; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6010; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimitMembers"; + msg: "There can only be at most 10 monthly spending limit members"; + }, + { + code: 6012; + name: "InvalidPerformancePackageTokenAmount"; + msg: "Invalid performance package token amount"; + }, + { + code: 6013; + name: "InvalidPerformancePackageMinUnlockTime"; + msg: "Insiders must wait at least 12 months before unlocking"; + }, + { + code: 6014; + name: "LaunchAuthorityNotSet"; + msg: "Launch authority must be set to complete the launch until 2 days after closing"; + }, + { + code: 6015; + name: "FinalRaiseAmountTooLow"; + msg: "The final amount raised must be >= the minimum raise amount"; + }, + { + code: 6016; + name: "TokensAlreadyClaimed"; + msg: "Tokens already claimed"; + }, + { + code: 6017; + name: "MoneyAlreadyRefunded"; + msg: "USDC already refunded"; + }, + { + code: 6018; + name: "InvariantViolated"; + msg: "Invariant violated"; + }, + { + code: 6019; + name: "LaunchNotLive"; + msg: "Launch must be live to be closed"; + }, + { + code: 6020; + name: "InvalidMinimumRaiseAmount"; + msg: "Minimum raise amount too low for liquidity"; + }, + { + code: 6021; + name: "FinalRaiseAmountAlreadySet"; + msg: "Final raise amount already set"; + }, + { + code: 6022; + name: "TotalApprovedAmountTooLow"; + msg: "Total approved amount too low"; + }, + { + code: 6023; + name: "InvalidAdditionalTokensRecipient"; + msg: "Additional tokens recipient must be set when amount > 0"; + }, + { + code: 6024; + name: "NoAdditionalTokensRecipientSet"; + msg: "No additional tokens recipient set"; + }, + { + code: 6025; + name: "AdditionalTokensAlreadyClaimed"; + msg: "Additional tokens already claimed"; + }, + { + code: 6026; + name: "FundingRecordApprovalPeriodOver"; + msg: "Funding record approval period is over"; + }, + { + code: 6027; + name: "PerformancePackageAlreadyInitialized"; + msg: "Performance package already initialized"; + }, + { + code: 6028; + name: "InvalidDao"; + msg: "Invalid DAO"; + }, + { + code: 6029; + name: "InvalidAccumulatorActivationDelaySeconds"; + msg: "Accumulator activation delay must be less than the launch duration"; + }, + { + code: 6030; + name: "ExtendDurationExceedsMax"; + msg: "Extend duration would exceed maximum allowed launch duration"; + }, + { + code: 6031; + name: "InvalidMintAuthority"; + msg: "Mint authority does not match expected"; + }, + ]; +}; + +export const IDL: LaunchpadV8 = { + version: "0.8.0", + name: "launchpad_v8", + instructions: [], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + { + name: "approvedAmount", + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ], + type: "u64", + }, + { + name: "committedAmountAccumulator", + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ], + type: "u128", + }, + { + name: "lastAccumulatorUpdate", + docs: ["Unix timestamp of the last accumulator update."], + type: "i64", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: ["The launch signer address."], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to the AMM."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + { + name: "teamAddress", + docs: ["The initial address used to sponsor team proposals."], + type: "publicKey", + }, + { + name: "totalApprovedAmount", + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ], + type: "u64", + }, + { + name: "additionalTokensAmount", + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ], + type: "u64", + }, + { + name: "additionalTokensRecipient", + docs: [ + "The token account that will receive the additional tokens.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "additionalTokensClaimed", + docs: ["Are the additional tokens claimed."], + type: "bool", + }, + { + name: "unixTimestampCompleted", + docs: ["The unix timestamp when the launch was completed."], + type: { + option: "i64", + }, + }, + { + name: "isPerformancePackageInitialized", + docs: ["Whether the performance package has been initialized."], + type: "bool", + }, + { + name: "accumulatorActivationDelaySeconds", + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ], + type: "u32", + }, + { + name: "hasBidWall", + docs: ["Whether the launch has a bid wall."], + type: "bool", + }, + { + name: "mintGovernor", + docs: ["The MintGovernor PDA that owns the SPL mint authority."], + type: "publicKey", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Closed", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "performancePackageGrantee", + type: "publicKey", + index: false, + }, + { + name: "performancePackageTokenAmount", + type: "u64", + index: false, + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + index: false, + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + index: false, + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + index: false, + }, + { + name: "hasBidWall", + type: "bool", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "committedAmountAccumulator", + type: "u128", + index: false, + }, + ], + }, + { + name: "FundingRecordApprovalSetEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "approvedAmount", + type: "u64", + index: false, + }, + { + name: "totalApproved", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchSettledEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "totalApprovedAmount", + type: "u64", + index: false, + }, + { + name: "bidWall", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "bidWallAmount", + type: "u64", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "tokensMinted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFinalizedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mintGovernorNewAdmin", + type: "publicKey", + index: false, + }, + { + name: "ppMintAuthority", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchCloseEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "newState", + type: { + defined: "LaunchState", + }, + index: false, + }, + ], + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchExtendedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "oldSecondsForLaunch", + type: "u32", + index: false, + }, + { + name: "newSecondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6005, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6006, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6007, + name: "LaunchNotRefunding", + msg: "Refund not available", + }, + { + code: 6008, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6009, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6010, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimitMembers", + msg: "There can only be at most 10 monthly spending limit members", + }, + { + code: 6012, + name: "InvalidPerformancePackageTokenAmount", + msg: "Invalid performance package token amount", + }, + { + code: 6013, + name: "InvalidPerformancePackageMinUnlockTime", + msg: "Insiders must wait at least 12 months before unlocking", + }, + { + code: 6014, + name: "LaunchAuthorityNotSet", + msg: "Launch authority must be set to complete the launch until 2 days after closing", + }, + { + code: 6015, + name: "FinalRaiseAmountTooLow", + msg: "The final amount raised must be >= the minimum raise amount", + }, + { + code: 6016, + name: "TokensAlreadyClaimed", + msg: "Tokens already claimed", + }, + { + code: 6017, + name: "MoneyAlreadyRefunded", + msg: "USDC already refunded", + }, + { + code: 6018, + name: "InvariantViolated", + msg: "Invariant violated", + }, + { + code: 6019, + name: "LaunchNotLive", + msg: "Launch must be live to be closed", + }, + { + code: 6020, + name: "InvalidMinimumRaiseAmount", + msg: "Minimum raise amount too low for liquidity", + }, + { + code: 6021, + name: "FinalRaiseAmountAlreadySet", + msg: "Final raise amount already set", + }, + { + code: 6022, + name: "TotalApprovedAmountTooLow", + msg: "Total approved amount too low", + }, + { + code: 6023, + name: "InvalidAdditionalTokensRecipient", + msg: "Additional tokens recipient must be set when amount > 0", + }, + { + code: 6024, + name: "NoAdditionalTokensRecipientSet", + msg: "No additional tokens recipient set", + }, + { + code: 6025, + name: "AdditionalTokensAlreadyClaimed", + msg: "Additional tokens already claimed", + }, + { + code: 6026, + name: "FundingRecordApprovalPeriodOver", + msg: "Funding record approval period is over", + }, + { + code: 6027, + name: "PerformancePackageAlreadyInitialized", + msg: "Performance package already initialized", + }, + { + code: 6028, + name: "InvalidDao", + msg: "Invalid DAO", + }, + { + code: 6029, + name: "InvalidAccumulatorActivationDelaySeconds", + msg: "Accumulator activation delay must be less than the launch duration", + }, + { + code: 6030, + name: "ExtendDurationExceedsMax", + msg: "Extend duration would exceed maximum allowed launch duration", + }, + { + code: 6031, + name: "InvalidMintAuthority", + msg: "Mint authority does not match expected", + }, + ], +}; diff --git a/sdk/src/v0.7/types/v08_launchpad.ts b/sdk/src/v0.7/types/v08_launchpad.ts new file mode 100644 index 000000000..c769e0c68 --- /dev/null +++ b/sdk/src/v0.7/types/v08_launchpad.ts @@ -0,0 +1,123 @@ +export type V08Launchpad = { + version: "0.8.0"; + name: "v08_launchpad"; + instructions: [ + { + name: "initializeLaunch"; + accounts: []; + args: []; + }, + { + name: "startLaunch"; + accounts: []; + args: []; + }, + { + name: "fund"; + accounts: []; + args: []; + }, + { + name: "setFundingRecordApproval"; + accounts: []; + args: []; + }, + { + name: "closeLaunch"; + accounts: []; + args: []; + }, + { + name: "settleLaunch"; + accounts: []; + args: []; + }, + { + name: "finalizeLaunch"; + accounts: []; + args: []; + }, + { + name: "claim"; + accounts: []; + args: []; + }, + { + name: "refund"; + accounts: []; + args: []; + }, + { + name: "claimAdditionalTokenAllocation"; + accounts: []; + args: []; + }, + { + name: "extendLaunch"; + accounts: []; + args: []; + }, + ]; +}; + +export const IDL: V08Launchpad = { + version: "0.8.0", + name: "v08_launchpad", + instructions: [ + { + name: "initializeLaunch", + accounts: [], + args: [], + }, + { + name: "startLaunch", + accounts: [], + args: [], + }, + { + name: "fund", + accounts: [], + args: [], + }, + { + name: "setFundingRecordApproval", + accounts: [], + args: [], + }, + { + name: "closeLaunch", + accounts: [], + args: [], + }, + { + name: "settleLaunch", + accounts: [], + args: [], + }, + { + name: "finalizeLaunch", + accounts: [], + args: [], + }, + { + name: "claim", + accounts: [], + args: [], + }, + { + name: "refund", + accounts: [], + args: [], + }, + { + name: "claimAdditionalTokenAllocation", + accounts: [], + args: [], + }, + { + name: "extendLaunch", + accounts: [], + args: [], + }, + ], +}; diff --git a/sdk2/package.json b/sdk2/package.json index f314c16e6..d83844c8f 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -12,6 +12,7 @@ "./futarchy/v0.6": "./dist/futarchy/v0.6/index.js", "./launchpad/v0.6": "./dist/launchpad/v0.6/index.js", "./launchpad/v0.7": "./dist/launchpad/v0.7/index.js", + "./launchpad/v0.8": "./dist/launchpad/v0.8/index.js", "./liquidation/v0.7": "./dist/liquidation/v0.7/index.js", "./mint_governor/v0.7": "./dist/mint_governor/v0.7/index.js", "./performance_package_v2/v0.7": "./dist/performance_package_v2/v0.7/index.js", diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index 6a41f5b65..6ed184826 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -35,7 +35,7 @@ export const LAUNCHPAD_V0_7_PROGRAM_ID = new PublicKey( "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM", ); export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey( - "MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg", + "moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n", ); export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", @@ -148,6 +148,10 @@ export const LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG = new PublicKey( "FaA6RM9enPh1tU9Y8LiGCq715JubLc49WGcYTdNvDfsc", ); +export const LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG = new PublicKey( + "83xS3s3egswDMouWkBwEFNZckAuAYhNrGQxrZKAe8GV", +); + export const METADAO_MULTISIG_VAULT = new PublicKey( "6awyHMshBGVjJ3ozdSJdyyDE1CTAXUwrpNMaRGMsb4sf", ); diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 786b9799d..bee670406 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -7,6 +7,12 @@ import { getLaunchAddr, getLaunchSignerAddr, } from "./pda.js"; +import { + LaunchpadProgram, + LaunchpadIDL, + Launch, + FundingRecord, +} from "./types/index.js"; import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; import { @@ -25,7 +31,7 @@ export type CreateLaunchpadClientParams = { }; export class LaunchpadClient { - public launchpad: Program; + public launchpad: Program; public provider: AnchorProvider; public autocratClient: FutarchyClient; public performancePackageV2: PerformancePackageV2Client; @@ -33,16 +39,8 @@ export class LaunchpadClient { private constructor(params: CreateLaunchpadClientParams) { this.provider = params.provider; - // IDL will be wired up after first build generates the types - this.launchpad = new Program( - { - version: "0.8.0", - name: "launchpad_v8", - instructions: [], - accounts: [], - events: [], - errors: [], - } as any, + this.launchpad = new Program( + LaunchpadIDL as any, params.launchpadProgramId || LAUNCHPAD_V0_8_PROGRAM_ID, this.provider, ); @@ -69,23 +67,25 @@ export class LaunchpadClient { return this.launchpad.programId; } - async getLaunch(launch: PublicKey): Promise { + async getLaunch(launch: PublicKey): Promise { return await this.launchpad.account.launch.fetch(launch); } - async fetchLaunch(launch: PublicKey): Promise { + async fetchLaunch(launch: PublicKey): Promise { return await this.launchpad.account.launch.fetchNullable(launch); } - async deserializeLaunch(accountInfo: AccountInfo): Promise { + async deserializeLaunch(accountInfo: AccountInfo): Promise { return this.launchpad.coder.accounts.decode("launch", accountInfo.data); } - async getFundingRecord(fundingRecord: PublicKey): Promise { + async getFundingRecord(fundingRecord: PublicKey): Promise { return await this.launchpad.account.fundingRecord.fetch(fundingRecord); } - async fetchFundingRecord(fundingRecord: PublicKey): Promise { + async fetchFundingRecord( + fundingRecord: PublicKey, + ): Promise { return await this.launchpad.account.fundingRecord.fetchNullable( fundingRecord, ); @@ -93,7 +93,7 @@ export class LaunchpadClient { async deserializeFundingRecord( accountInfo: AccountInfo, - ): Promise { + ): Promise { return this.launchpad.coder.accounts.decode( "fundingRecord", accountInfo.data, diff --git a/sdk2/src/launchpad/v0.8/types/index.ts b/sdk2/src/launchpad/v0.8/types/index.ts index 628fa674a..4815b985f 100644 --- a/sdk2/src/launchpad/v0.8/types/index.ts +++ b/sdk2/src/launchpad/v0.8/types/index.ts @@ -1,3 +1,44 @@ -// Stub — types will be generated after first build -// Once the IDL is generated, this file will export types from the generated IDL -// similar to v0.7/types/index.ts +import type { IdlAccounts, IdlEvents } from "@coral-xyz/anchor"; + +import { + LaunchpadV8 as LaunchpadProgram, + IDL as LaunchpadIDL, +} from "./launchpad_v8.js"; +export { LaunchpadProgram, LaunchpadIDL }; + +export type Launch = IdlAccounts["launch"]; +export type FundingRecord = IdlAccounts["fundingRecord"]; + +export type LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type FundingRecordApprovalSetEvent = + IdlEvents["FundingRecordApprovalSetEvent"]; +export type LaunchSettledEvent = + IdlEvents["LaunchSettledEvent"]; +export type LaunchFinalizedEvent = + IdlEvents["LaunchFinalizedEvent"]; +export type LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; +export type LaunchCloseEvent = IdlEvents["LaunchCloseEvent"]; +export type LaunchClaimAdditionalTokenAllocationEvent = + IdlEvents["LaunchClaimAdditionalTokenAllocationEvent"]; +export type LaunchExtendedEvent = + IdlEvents["LaunchExtendedEvent"]; + +export type LaunchpadEvent = + | LaunchInitializedEvent + | LaunchStartedEvent + | LaunchFundedEvent + | FundingRecordApprovalSetEvent + | LaunchSettledEvent + | LaunchFinalizedEvent + | LaunchRefundedEvent + | LaunchClaimEvent + | LaunchCloseEvent + | LaunchClaimAdditionalTokenAllocationEvent + | LaunchExtendedEvent; diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts new file mode 100644 index 000000000..38972a55c --- /dev/null +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -0,0 +1,1945 @@ +export type LaunchpadV8 = { + version: "0.8.0"; + name: "launchpad_v8"; + instructions: []; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + { + name: "approvedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ]; + type: "u64"; + }, + { + name: "committedAmountAccumulator"; + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ]; + type: "u128"; + }, + { + name: "lastAccumulatorUpdate"; + docs: ["Unix timestamp of the last accumulator update."]; + type: "i64"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: ["The launch signer address."]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to the AMM."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + { + name: "teamAddress"; + docs: ["The initial address used to sponsor team proposals."]; + type: "publicKey"; + }, + { + name: "totalApprovedAmount"; + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ]; + type: "u64"; + }, + { + name: "additionalTokensAmount"; + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ]; + type: "u64"; + }, + { + name: "additionalTokensRecipient"; + docs: [ + "The token account that will receive the additional tokens.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "additionalTokensClaimed"; + docs: ["Are the additional tokens claimed."]; + type: "bool"; + }, + { + name: "unixTimestampCompleted"; + docs: ["The unix timestamp when the launch was completed."]; + type: { + option: "i64"; + }; + }, + { + name: "isPerformancePackageInitialized"; + docs: ["Whether the performance package has been initialized."]; + type: "bool"; + }, + { + name: "accumulatorActivationDelaySeconds"; + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ]; + type: "u32"; + }, + { + name: "hasBidWall"; + docs: ["Whether the launch has a bid wall."]; + type: "bool"; + }, + { + name: "mintGovernor"; + docs: ["The MintGovernor PDA that owns the SPL mint authority."]; + type: "publicKey"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Closed"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + index: false; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + index: false; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + index: false; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + index: false; + }, + { + name: "hasBidWall"; + type: "bool"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "committedAmountAccumulator"; + type: "u128"; + index: false; + }, + ]; + }, + { + name: "FundingRecordApprovalSetEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "approvedAmount"; + type: "u64"; + index: false; + }, + { + name: "totalApproved"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchSettledEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "totalApprovedAmount"; + type: "u64"; + index: false; + }, + { + name: "bidWall"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "bidWallAmount"; + type: "u64"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "tokensMinted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFinalizedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "performancePackage"; + type: "publicKey"; + index: false; + }, + { + name: "mintGovernor"; + type: "publicKey"; + index: false; + }, + { + name: "mintGovernorNewAdmin"; + type: "publicKey"; + index: false; + }, + { + name: "ppMintAuthority"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchCloseEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "newState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + index: false; + }, + { + name: "additionalTokensRecipient"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchExtendedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "oldSecondsForLaunch"; + type: "u32"; + index: false; + }, + { + name: "newSecondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6005; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6006; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6007; + name: "LaunchNotRefunding"; + msg: "Refund not available"; + }, + { + code: 6008; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6009; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6010; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimitMembers"; + msg: "There can only be at most 10 monthly spending limit members"; + }, + { + code: 6012; + name: "InvalidPerformancePackageTokenAmount"; + msg: "Invalid performance package token amount"; + }, + { + code: 6013; + name: "InvalidPerformancePackageMinUnlockTime"; + msg: "Insiders must wait at least 12 months before unlocking"; + }, + { + code: 6014; + name: "LaunchAuthorityNotSet"; + msg: "Launch authority must be set to complete the launch until 2 days after closing"; + }, + { + code: 6015; + name: "FinalRaiseAmountTooLow"; + msg: "The final amount raised must be >= the minimum raise amount"; + }, + { + code: 6016; + name: "TokensAlreadyClaimed"; + msg: "Tokens already claimed"; + }, + { + code: 6017; + name: "MoneyAlreadyRefunded"; + msg: "USDC already refunded"; + }, + { + code: 6018; + name: "InvariantViolated"; + msg: "Invariant violated"; + }, + { + code: 6019; + name: "LaunchNotLive"; + msg: "Launch must be live to be closed"; + }, + { + code: 6020; + name: "InvalidMinimumRaiseAmount"; + msg: "Minimum raise amount too low for liquidity"; + }, + { + code: 6021; + name: "FinalRaiseAmountAlreadySet"; + msg: "Final raise amount already set"; + }, + { + code: 6022; + name: "TotalApprovedAmountTooLow"; + msg: "Total approved amount too low"; + }, + { + code: 6023; + name: "InvalidAdditionalTokensRecipient"; + msg: "Additional tokens recipient must be set when amount > 0"; + }, + { + code: 6024; + name: "NoAdditionalTokensRecipientSet"; + msg: "No additional tokens recipient set"; + }, + { + code: 6025; + name: "AdditionalTokensAlreadyClaimed"; + msg: "Additional tokens already claimed"; + }, + { + code: 6026; + name: "FundingRecordApprovalPeriodOver"; + msg: "Funding record approval period is over"; + }, + { + code: 6027; + name: "PerformancePackageAlreadyInitialized"; + msg: "Performance package already initialized"; + }, + { + code: 6028; + name: "InvalidDao"; + msg: "Invalid DAO"; + }, + { + code: 6029; + name: "InvalidAccumulatorActivationDelaySeconds"; + msg: "Accumulator activation delay must be less than the launch duration"; + }, + { + code: 6030; + name: "ExtendDurationExceedsMax"; + msg: "Extend duration would exceed maximum allowed launch duration"; + }, + { + code: 6031; + name: "InvalidMintAuthority"; + msg: "Mint authority does not match expected"; + }, + ]; +}; + +export const IDL: LaunchpadV8 = { + version: "0.8.0", + name: "launchpad_v8", + instructions: [], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + { + name: "approvedAmount", + docs: [ + "The amount of USDC that the launch authority has approved for the funder.", + "If zero, the funder has not been approved for any amount.", + ], + type: "u64", + }, + { + name: "committedAmountAccumulator", + docs: [ + "Running integral of committed_amount over time (committed_amount * seconds).", + ], + type: "u128", + }, + { + name: "lastAccumulatorUpdate", + docs: ["Unix timestamp of the last accumulator update."], + type: "i64", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: ["The launch signer address."], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to the AMM."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + { + name: "teamAddress", + docs: ["The initial address used to sponsor team proposals."], + type: "publicKey", + }, + { + name: "totalApprovedAmount", + docs: [ + "The amount of USDC that the launch authority has approved across all funders.", + ], + type: "u64", + }, + { + name: "additionalTokensAmount", + docs: [ + "The amount of additional tokens to be minted on a successful launch.", + ], + type: "u64", + }, + { + name: "additionalTokensRecipient", + docs: [ + "The token account that will receive the additional tokens.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "additionalTokensClaimed", + docs: ["Are the additional tokens claimed."], + type: "bool", + }, + { + name: "unixTimestampCompleted", + docs: ["The unix timestamp when the launch was completed."], + type: { + option: "i64", + }, + }, + { + name: "isPerformancePackageInitialized", + docs: ["Whether the performance package has been initialized."], + type: "bool", + }, + { + name: "accumulatorActivationDelaySeconds", + docs: [ + "Number of seconds after launch start before the funding accumulator", + "begins tracking.", + ], + type: "u32", + }, + { + name: "hasBidWall", + docs: ["Whether the launch has a bid wall."], + type: "bool", + }, + { + name: "mintGovernor", + docs: ["The MintGovernor PDA that owns the SPL mint authority."], + type: "publicKey", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Closed", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "performancePackageGrantee", + type: "publicKey", + index: false, + }, + { + name: "performancePackageTokenAmount", + type: "u64", + index: false, + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + index: false, + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + index: false, + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + index: false, + }, + { + name: "hasBidWall", + type: "bool", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "committedAmountAccumulator", + type: "u128", + index: false, + }, + ], + }, + { + name: "FundingRecordApprovalSetEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "approvedAmount", + type: "u64", + index: false, + }, + { + name: "totalApproved", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchSettledEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "totalApprovedAmount", + type: "u64", + index: false, + }, + { + name: "bidWall", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "bidWallAmount", + type: "u64", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "tokensMinted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFinalizedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "performancePackage", + type: "publicKey", + index: false, + }, + { + name: "mintGovernor", + type: "publicKey", + index: false, + }, + { + name: "mintGovernorNewAdmin", + type: "publicKey", + index: false, + }, + { + name: "ppMintAuthority", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchCloseEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "newState", + type: { + defined: "LaunchState", + }, + index: false, + }, + ], + }, + { + name: "LaunchClaimAdditionalTokenAllocationEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "additionalTokensAmount", + type: "u64", + index: false, + }, + { + name: "additionalTokensRecipient", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchExtendedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "oldSecondsForLaunch", + type: "u32", + index: false, + }, + { + name: "newSecondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6005, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6006, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6007, + name: "LaunchNotRefunding", + msg: "Refund not available", + }, + { + code: 6008, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6009, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6010, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimitMembers", + msg: "There can only be at most 10 monthly spending limit members", + }, + { + code: 6012, + name: "InvalidPerformancePackageTokenAmount", + msg: "Invalid performance package token amount", + }, + { + code: 6013, + name: "InvalidPerformancePackageMinUnlockTime", + msg: "Insiders must wait at least 12 months before unlocking", + }, + { + code: 6014, + name: "LaunchAuthorityNotSet", + msg: "Launch authority must be set to complete the launch until 2 days after closing", + }, + { + code: 6015, + name: "FinalRaiseAmountTooLow", + msg: "The final amount raised must be >= the minimum raise amount", + }, + { + code: 6016, + name: "TokensAlreadyClaimed", + msg: "Tokens already claimed", + }, + { + code: 6017, + name: "MoneyAlreadyRefunded", + msg: "USDC already refunded", + }, + { + code: 6018, + name: "InvariantViolated", + msg: "Invariant violated", + }, + { + code: 6019, + name: "LaunchNotLive", + msg: "Launch must be live to be closed", + }, + { + code: 6020, + name: "InvalidMinimumRaiseAmount", + msg: "Minimum raise amount too low for liquidity", + }, + { + code: 6021, + name: "FinalRaiseAmountAlreadySet", + msg: "Final raise amount already set", + }, + { + code: 6022, + name: "TotalApprovedAmountTooLow", + msg: "Total approved amount too low", + }, + { + code: 6023, + name: "InvalidAdditionalTokensRecipient", + msg: "Additional tokens recipient must be set when amount > 0", + }, + { + code: 6024, + name: "NoAdditionalTokensRecipientSet", + msg: "No additional tokens recipient set", + }, + { + code: 6025, + name: "AdditionalTokensAlreadyClaimed", + msg: "Additional tokens already claimed", + }, + { + code: 6026, + name: "FundingRecordApprovalPeriodOver", + msg: "Funding record approval period is over", + }, + { + code: 6027, + name: "PerformancePackageAlreadyInitialized", + msg: "Performance package already initialized", + }, + { + code: 6028, + name: "InvalidDao", + msg: "Invalid DAO", + }, + { + code: 6029, + name: "InvalidAccumulatorActivationDelaySeconds", + msg: "Accumulator activation delay must be less than the launch duration", + }, + { + code: 6030, + name: "ExtendDurationExceedsMax", + msg: "Extend duration would exceed maximum allowed launch duration", + }, + { + code: 6031, + name: "InvalidMintAuthority", + msg: "Mint authority does not match expected", + }, + ], +}; diff --git a/sdk2/sync-types.sh b/sdk2/sync-types.sh index 7e99ab46f..140882805 100755 --- a/sdk2/sync-types.sh +++ b/sdk2/sync-types.sh @@ -8,6 +8,7 @@ cp "$TYPES_DIR/conditional_vault.ts" ./src/conditional_vault/v0.4/ cp "$TYPES_DIR/futarchy.ts" ./src/futarchy/v0.6/types/ cp "$TYPES_DIR/launchpad.ts" ./src/launchpad/v0.6/types/ cp "$TYPES_DIR/launchpad_v7.ts" ./src/launchpad/v0.7/types/ +cp "$TYPES_DIR/launchpad_v8.ts" ./src/launchpad/v0.8/types/ cp "$TYPES_DIR/liquidation.ts" ./src/liquidation/v0.7/types/ cp "$TYPES_DIR/mint_governor.ts" ./src/mint_governor/v0.7/types/ cp "$TYPES_DIR/performance_package_v2.ts" ./src/performance_package_v2/v0.7/types/ diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts new file mode 100644 index 000000000..a3a343a03 --- /dev/null +++ b/tests/launchpad_v8/main.test.ts @@ -0,0 +1,66 @@ +import { PublicKey } from "@solana/web3.js"; +import { + LAUNCHPAD_V0_8_PROGRAM_ID, + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + MAINNET_USDC, +} from "@metadaoproject/futarchy-v2"; +import BN from "bn.js"; + +export default function suite() { + before(async function () { + const dynamicConfig = await this.banksClient.getAccount( + new PublicKey("4mPQ4VuvvtYL3CeMPt14Uj1CLpBWcVdJoLoTH9ea4Kod"), + ); + + // discriminator + vault config authority + const poolCreatorAuthorityOffset = 8 + 32; + // discriminator + vault config authority + pool creator authority + pool fees config + activation type + collect fee mode + const configTypeOffset = 8 + 32 + 32 + 128 + 1 + 1; + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + LAUNCHPAD_V0_8_PROGRAM_ID, + ); + + dynamicConfig.data.set( + poolCreatorAuthority.toBuffer(), + poolCreatorAuthorityOffset, + ); + dynamicConfig.data.set([1], configTypeOffset); + + this.context.setAccount( + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); + + this.setupBasicLaunch = async ({ + baseMint, + founders, + launchAuthority, + }: { + baseMint: PublicKey; + founders: PublicKey[]; + launchAuthority: PublicKey; + }) => { + await this.launchpad_v8 + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: new BN(100_000 * 10 ** 6), // 100k + secondsForLaunch: 60 * 60 * 24 * 4, // 4 days + baseMint, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), // 10k burn + monthlySpendingLimitMembers: founders, + performancePackageGrantee: founders[0], + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), // 5M + monthsUntilInsidersCanUnlock: 24, // 2 years + teamAddress: PublicKey.default, + launchAuthority: launchAuthority, + hasBidWall: false, + }) + .rpc(); + }; + }); +} diff --git a/tests/launchpad_v8/utils.ts b/tests/launchpad_v8/utils.ts new file mode 100644 index 000000000..ed722112c --- /dev/null +++ b/tests/launchpad_v8/utils.ts @@ -0,0 +1,58 @@ +import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; +import * as token from "@solana/spl-token"; +import { BanksClient } from "solana-bankrun"; +import { + LaunchpadClient, + getLaunchAddr, + getLaunchSignerAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; + +export async function initializeMintWithSeeds( + banksClient: BanksClient, + launchpadClient: LaunchpadClient, + payer: Signer, +): Promise<{ + tokenMint: PublicKey; + launch: PublicKey; + launchSigner: PublicKey; +}> { + const seed = Math.random().toString(36).substring(2, 15); + const tokenMint = await PublicKey.createWithSeed( + payer.publicKey, + seed, + token.TOKEN_PROGRAM_ID, + ); + + const [launch] = getLaunchAddr(launchpadClient.getProgramId(), tokenMint); + const [launchSigner] = getLaunchSignerAddr( + launchpadClient.getProgramId(), + launch, + ); + + const rent = await banksClient.getRent(); + const lamports = Number(rent.minimumBalance(BigInt(token.MINT_SIZE))); + + const tx = new Transaction().add( + SystemProgram.createAccountWithSeed({ + fromPubkey: payer.publicKey, + newAccountPubkey: tokenMint, + basePubkey: payer.publicKey, + seed, + lamports: lamports, + space: token.MINT_SIZE, + programId: token.TOKEN_PROGRAM_ID, + }), + token.createInitializeMint2Instruction(tokenMint, 6, launchSigner, null), + ); + tx.recentBlockhash = (await banksClient.getLatestBlockhash())[0]; + tx.feePayer = payer.publicKey; + tx.sign(payer); + + await banksClient.processTransaction(tx); + + return { + tokenMint, + launch, + launchSigner, + }; +} diff --git a/tests/main.test.ts b/tests/main.test.ts index 783954674..ecd21df5e 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -2,6 +2,7 @@ import conditionalVault from "./conditionalVault/main.test.js"; import futarchy from "./futarchy/main.test.js"; import launchpad from "./launchpad/main.test.js"; import launchpad_v7 from "./launchpad_v7/main.test.js"; +import launchpad_v8 from "./launchpad_v8/main.test.js"; import priceBasedPerformancePackage from "./priceBasedPerformancePackage/main.test.js"; import bidWall from "./bidWall/main.test.js"; import mintGovernor from "./mintGovernor/main.test.js"; @@ -41,6 +42,7 @@ import { sha256, } from "@metadaoproject/futarchy-v2"; import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { LaunchpadClient as LaunchpadClientV8 } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; import { PublicKey, @@ -89,6 +91,7 @@ export interface TestContext { conditionalVault: ConditionalVaultClient; futarchy: FutarchyClient; launchpad_v7: LaunchpadClientV7; + launchpad_v8: LaunchpadClientV8; launchpad_v6: LaunchpadClientV6; priceBasedPerformancePackage: PriceBasedPerformancePackageClient; bidWall: BidWallClient; @@ -255,6 +258,9 @@ before(async function () { this.launchpad_v7 = LaunchpadClientV7.createClient({ provider: provider as any, }); + this.launchpad_v8 = LaunchpadClientV8.createClient({ + provider: provider as any, + }); this.launchpad_v6 = LaunchpadClientV6.createClient({ provider: provider as any, }); @@ -741,6 +747,7 @@ before(async function () { describe("launchpad", launchpad); describe("launchpad_v7", launchpad_v7); +describe("launchpad_v8", launchpad_v8); describe("price_based_performance_package", priceBasedPerformancePackage); describe("conditional_vault", conditionalVault); describe("futarchy", futarchy); diff --git a/vibes/launchpad_v8_spec.md b/vibes/launchpad_v8_spec.md index 1efc63af2..30c526f51 100644 --- a/vibes/launchpad_v8_spec.md +++ b/vibes/launchpad_v8_spec.md @@ -14,7 +14,7 @@ | `complete_launch` | Transfers mint authority to DAO | Renamed → `settle_launch`; mints tokens via MintGovernor | | `initialize_performance_package` | Initializes PP v1 with pre-minted tokens | Renamed → `finalize_launch`; initializes PP v2 + transfers MintGovernor admin | | Migration instructions | `resize_launch`, `resize_funding_record` | Removed (fresh deploy, new program ID) | -| Program ID | `moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM` | `MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg` | +| Program ID | `moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM` | `moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n` | --- @@ -1580,7 +1580,7 @@ export class LaunchpadClient { ```typescript // Add to sdk2/src/constants.ts -export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey("MooNv7KbVWxQPCbCALJquw4D9pnVF7n8Nh2HmGqsxjg"); +export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey("moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n"); ``` --- diff --git a/vibes/tasks.md b/vibes/tasks.md index 00c35d81b..8950e13d6 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -27,17 +27,11 @@ > Reference: `launchpad_v8_spec.md` → "Constants", "State", "Errors", "Events" -- [NEXT] 1.4 Test scaffolding - - Create `tests/launchpad_v8/main.test.ts` with bankrun setup (model after `tests/launchpad_v7/main.test.ts`) - - Create `tests/launchpad_v8/utils.ts` with `initializeMintWithSeeds` helper targeting v0.8 client - - Create empty unit test files in `tests/launchpad_v8/unit/` for all 11 instruction test suites - - Verify: `anchor test --skip-build` runs (tests pass vacuously since empty) - ### Phase 2: `initialize_launch` > Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" -- [ ] 2.1 Implement `initialize_launch` instruction (Rust) +- [NEXT] 2.1 Implement `initialize_launch` instruction (Rust) - Create `src/instructions/initialize_launch.rs` with `InitializeLaunchArgs`, `InitializeLaunch` accounts struct, `validate()`, and `handle()` - Port validation logic from v7 - Implement handler: init Launch state, create metadata CPI, MintGovernor CPI chain (init governor → add mint authority → transfer authority) From 97c25c51241853fdc6cce4aa1233b8dc6bea331a Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 00:59:56 +0200 Subject: [PATCH 041/100] initialize launch ix --- .../src/instructions/initialize_launch.rs | 385 +++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 14 +- sdk/src/v0.7/types/launchpad_v8.ts | 392 +++++++++++++++++- sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 392 +++++++++++++++++- vibes/tasks.md | 10 +- 6 files changed, 1181 insertions(+), 14 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/initialize_launch.rs diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs new file mode 100644 index 000000000..0d5d7e3ed --- /dev/null +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -0,0 +1,385 @@ +use anchor_lang::prelude::*; +use anchor_spl::associated_token::AssociatedToken; +use anchor_spl::token::{Mint, Token, TokenAccount}; + +use mint_governor::{ + cpi::{ + accounts::{AddMintAuthority, InitializeMintGovernor, TransferAuthorityToGovernor}, + add_mint_authority, initialize_mint_governor, transfer_authority_to_governor, + }, + program::MintGovernor as MintGovernorProgram, + AddMintAuthorityArgs, +}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchInitializedEvent}; +use crate::state::{Launch, LaunchState}; +use crate::{ + usdc_mint, TOKENS_TO_DAMM_V2_LIQUIDITY, TOKENS_TO_FUTARCHY_LIQUIDITY, TOKENS_TO_PARTICIPANTS, +}; +use anchor_spl::metadata::{ + create_metadata_accounts_v3, mpl_token_metadata::types::DataV2, + mpl_token_metadata::ID as MPL_TOKEN_METADATA_PROGRAM_ID, CreateMetadataAccountsV3, Metadata, +}; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct InitializeLaunchArgs { + pub minimum_raise_amount: u64, + pub monthly_spending_limit_amount: u64, + pub monthly_spending_limit_members: Vec, + pub seconds_for_launch: u32, + pub token_name: String, + pub token_symbol: String, + pub token_uri: String, + pub performance_package_grantee: Pubkey, + pub performance_package_token_amount: u64, + pub months_until_insiders_can_unlock: u8, + pub team_address: Pubkey, + pub additional_tokens_amount: u64, + pub accumulator_activation_delay_seconds: u32, + pub has_bid_wall: bool, +} + +#[event_cpi] +#[derive(Accounts)] +pub struct InitializeLaunch<'info> { + #[account( + init, + payer = payer, + space = 8 + Launch::INIT_SPACE, + seeds = [b"launch", base_mint.key().as_ref()], + bump + )] + pub launch: Account<'info, Launch>, + + #[account( + mut, + mint::decimals = 6, + mint::authority = launch_signer, + )] + pub base_mint: Account<'info, Mint>, + + /// CHECK: This is the token metadata + #[account( + mut, + seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), base_mint.key().as_ref()], + seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, + bump + )] + pub token_metadata: UncheckedAccount<'info>, + + /// CHECK: This is the launch signer + #[account( + seeds = [b"launch_signer", launch.key().as_ref()], + bump + )] + pub launch_signer: UncheckedAccount<'info>, + + #[account( + init_if_needed, + payer = payer, + associated_token::mint = quote_mint, + associated_token::authority = launch_signer + )] + pub quote_vault: Account<'info, TokenAccount>, + + #[account( + init_if_needed, + payer = payer, + associated_token::mint = base_mint, + associated_token::authority = launch_signer + )] + pub base_vault: Account<'info, TokenAccount>, + + #[account(mut)] + pub payer: Signer<'info>, + + /// CHECK: account not used, just for constraints + pub launch_authority: UncheckedAccount<'info>, + + #[account(mint::decimals = 6, address = usdc_mint::id())] + pub quote_mint: Account<'info, Mint>, + + /// CHECK: Just the recipient of the additional tokens + pub additional_tokens_recipient: Option>, + + /// PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)] + /// Initialized via CPI to mint_governor::initialize_mint_governor + /// CHECK: initialized via CPI + #[account(mut)] + pub mint_governor: UncheckedAccount<'info>, + + /// PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)] + /// Initialized via CPI to mint_governor::add_mint_authority + /// CHECK: initialized via CPI + #[account(mut)] + pub mint_authority: UncheckedAccount<'info>, + + pub mint_governor_program: Program<'info, MintGovernorProgram>, + + /// CHECK: checked by mint_governor program + pub mint_governor_event_authority: UncheckedAccount<'info>, + + pub rent: Sysvar<'info, Rent>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub system_program: Program<'info, System>, + pub token_metadata_program: Program<'info, Metadata>, +} + +impl InitializeLaunch<'_> { + pub fn validate(&self, args: &InitializeLaunchArgs) -> Result<()> { + require_gt!( + args.minimum_raise_amount, + 0, + LaunchpadError::InvalidMinimumRaiseAmount + ); + + require_gte!( + 60 * 60 * 24 * 14, + args.seconds_for_launch, + LaunchpadError::InvalidSecondsForLaunch + ); + + require_gt!( + args.seconds_for_launch, + args.accumulator_activation_delay_seconds, + LaunchpadError::InvalidAccumulatorActivationDelaySeconds + ); + + require!( + self.base_mint.freeze_authority.is_none(), + LaunchpadError::FreezeAuthoritySet + ); + + require_gte!( + args.minimum_raise_amount, + args.monthly_spending_limit_amount * 6, + LaunchpadError::InvalidMonthlySpendingLimit + ); + + require_gte!( + args.minimum_raise_amount, + futarchy::MIN_QUOTE_LIQUIDITY * 5, + LaunchpadError::InvalidMinimumRaiseAmount + ); + + require_neq!( + args.monthly_spending_limit_amount, + 0, + LaunchpadError::InvalidMonthlySpendingLimit + ); + + require_gte!( + futarchy::MAX_SPENDING_LIMIT_MEMBERS, + args.monthly_spending_limit_members.len(), + LaunchpadError::InvalidMonthlySpendingLimitMembers + ); + + require!( + !args.monthly_spending_limit_members.is_empty(), + LaunchpadError::InvalidMonthlySpendingLimitMembers + ); + + let mut sorted_members = args.monthly_spending_limit_members.clone(); + sorted_members.sort(); + let has_duplicates = sorted_members.windows(2).any(|win| win[0] == win[1]); + require!( + !has_duplicates, + LaunchpadError::InvalidMonthlySpendingLimitMembers + ); + + require_gte!( + args.months_until_insiders_can_unlock, + 12, + LaunchpadError::InvalidPerformancePackageMinUnlockTime + ); + + require_gte!( + args.performance_package_token_amount, + 10, + LaunchpadError::InvalidPerformancePackageTokenAmount + ); + + require!(self.base_mint.supply == 0, LaunchpadError::SupplyNonZero); + + if args.additional_tokens_amount > 0 { + require!( + self.additional_tokens_recipient.is_some(), + LaunchpadError::InvalidAdditionalTokensRecipient + ); + } else { + require!( + self.additional_tokens_recipient.is_none(), + LaunchpadError::InvalidAdditionalTokensRecipient + ); + } + + Ok(()) + } + + pub fn handle(ctx: Context, args: InitializeLaunchArgs) -> Result<()> { + // Initialize Launch account + ctx.accounts.launch.set_inner(Launch { + minimum_raise_amount: args.minimum_raise_amount, + monthly_spending_limit_amount: args.monthly_spending_limit_amount, + monthly_spending_limit_members: args.monthly_spending_limit_members.clone(), + launch_authority: ctx.accounts.launch_authority.key(), + launch_signer: ctx.accounts.launch_signer.key(), + launch_signer_pda_bump: ctx.bumps.launch_signer, + launch_quote_vault: ctx.accounts.quote_vault.key(), + launch_base_vault: ctx.accounts.base_vault.key(), + total_committed_amount: 0, + base_mint: ctx.accounts.base_mint.key(), + quote_mint: ctx.accounts.quote_mint.key(), + pda_bump: ctx.bumps.launch, + seq_num: 0, + state: LaunchState::Initialized, + unix_timestamp_started: None, + unix_timestamp_closed: None, + seconds_for_launch: args.seconds_for_launch, + dao: None, + dao_vault: None, + performance_package_grantee: args.performance_package_grantee, + performance_package_token_amount: args.performance_package_token_amount, + months_until_insiders_can_unlock: args.months_until_insiders_can_unlock, + team_address: args.team_address, + total_approved_amount: 0, + additional_tokens_amount: args.additional_tokens_amount, + additional_tokens_recipient: ctx + .accounts + .additional_tokens_recipient + .as_ref() + .map(|a| a.key()), + additional_tokens_claimed: false, + unix_timestamp_completed: None, + is_performance_package_initialized: false, + accumulator_activation_delay_seconds: args.accumulator_activation_delay_seconds, + has_bid_wall: args.has_bid_wall, + mint_governor: ctx.accounts.mint_governor.key(), + }); + + let launch_key = ctx.accounts.launch.key(); + let seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[ctx.bumps.launch_signer], + ]; + let signer = &[&seeds[..]]; + + // Create token metadata + create_metadata_accounts_v3( + CpiContext::new_with_signer( + ctx.accounts.token_metadata_program.to_account_info(), + CreateMetadataAccountsV3 { + metadata: ctx.accounts.token_metadata.to_account_info(), + mint: ctx.accounts.base_mint.to_account_info(), + mint_authority: ctx.accounts.launch_signer.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + update_authority: ctx.accounts.launch_signer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + rent: ctx.accounts.rent.to_account_info(), + }, + signer, + ), + DataV2 { + name: args.token_name.clone(), + symbol: args.token_symbol.clone(), + uri: args.token_uri.clone(), + seller_fee_basis_points: 0, + creators: None, + collection: None, + uses: None, + }, + true, + true, + None, + )?; + + // Set up MintGovernor: create governor, add launch_signer as minter, transfer mint authority + initialize_mint_governor(CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + InitializeMintGovernor { + mint: ctx.accounts.base_mint.to_account_info(), + mint_governor: ctx.accounts.mint_governor.to_account_info(), + create_key: ctx.accounts.launch_signer.to_account_info(), + admin: ctx.accounts.launch_signer.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ))?; + + let max_total = TOKENS_TO_PARTICIPANTS + + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + + args.additional_tokens_amount; + + add_mint_authority( + CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + AddMintAuthority { + mint_governor: ctx.accounts.mint_governor.to_account_info(), + mint_authority: ctx.accounts.mint_authority.to_account_info(), + admin: ctx.accounts.launch_signer.to_account_info(), + authorized_minter: ctx.accounts.launch_signer.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ), + AddMintAuthorityArgs { + max_total: Some(max_total), + }, + )?; + + transfer_authority_to_governor(CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + TransferAuthorityToGovernor { + mint_governor: ctx.accounts.mint_governor.to_account_info(), + mint: ctx.accounts.base_mint.to_account_info(), + current_authority: ctx.accounts.launch_signer.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ))?; + + let clock = Clock::get()?; + emit_cpi!(LaunchInitializedEvent { + common: CommonFields::new(&clock, 0), + launch: ctx.accounts.launch.key(), + minimum_raise_amount: args.minimum_raise_amount, + performance_package_grantee: args.performance_package_grantee, + performance_package_token_amount: args.performance_package_token_amount, + months_until_insiders_can_unlock: args.months_until_insiders_can_unlock, + monthly_spending_limit_amount: args.monthly_spending_limit_amount, + monthly_spending_limit_members: args.monthly_spending_limit_members, + launch_authority: ctx.accounts.launch_authority.key(), + launch_signer: ctx.accounts.launch_signer.key(), + launch_signer_pda_bump: ctx.bumps.launch_signer, + launch_usdc_vault: ctx.accounts.quote_vault.key(), + launch_token_vault: ctx.accounts.base_vault.key(), + base_mint: ctx.accounts.base_mint.key(), + quote_mint: ctx.accounts.quote_mint.key(), + pda_bump: ctx.bumps.launch, + seconds_for_launch: args.seconds_for_launch, + additional_tokens_amount: args.additional_tokens_amount, + additional_tokens_recipient: ctx + .accounts + .additional_tokens_recipient + .as_ref() + .map(|a| a.key()), + accumulator_activation_delay_seconds: args.accumulator_activation_delay_seconds, + has_bid_wall: args.has_bid_wall, + mint_governor: ctx.accounts.mint_governor.key(), + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 8b1378917..2a1261123 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1 +1,3 @@ +pub mod initialize_launch; +pub use initialize_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index de539b3b9..11ad8b83f 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -7,6 +7,8 @@ pub mod events; pub mod instructions; pub mod state; +pub use instructions::*; + #[cfg(not(feature = "no-entrypoint"))] use solana_security_txt::security_txt; @@ -63,4 +65,14 @@ pub mod metadao_multisig_vault { } #[program] -pub mod launchpad_v8 {} +pub mod launchpad_v8 { + use super::*; + + #[access_control(ctx.accounts.validate(&args))] + pub fn initialize_launch( + ctx: Context, + args: InitializeLaunchArgs, + ) -> Result<()> { + InitializeLaunch::handle(ctx, args) + } +} diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 38972a55c..3875bb367 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -1,7 +1,135 @@ export type LaunchpadV8 = { version: "0.8.0"; name: "launchpad_v8"; - instructions: []; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + isOptional: true; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + docs: [ + 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', + "Initialized via CPI to mint_governor::initialize_mint_governor", + ]; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + docs: [ + 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', + "Initialized via CPI to mint_governor::add_mint_authority", + ]; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + ]; accounts: [ { name: "fundingRecord"; @@ -300,6 +428,72 @@ export type LaunchpadV8 = { ]; }; }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + }, + { + name: "hasBidWall"; + type: "bool"; + }, + ]; + }; + }, { name: "LaunchState"; type: { @@ -974,7 +1168,135 @@ export type LaunchpadV8 = { export const IDL: LaunchpadV8 = { version: "0.8.0", name: "launchpad_v8", - instructions: [], + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + isOptional: true, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + docs: [ + 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', + "Initialized via CPI to mint_governor::initialize_mint_governor", + ], + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + docs: [ + 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', + "Initialized via CPI to mint_governor::add_mint_authority", + ], + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + ], accounts: [ { name: "fundingRecord", @@ -1273,6 +1595,72 @@ export const IDL: LaunchpadV8 = { ], }, }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + { + name: "performancePackageGrantee", + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + }, + { + name: "teamAddress", + type: "publicKey", + }, + { + name: "additionalTokensAmount", + type: "u64", + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + }, + { + name: "hasBidWall", + type: "bool", + }, + ], + }, + }, { name: "LaunchState", type: { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 38972a55c..3875bb367 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -1,7 +1,135 @@ export type LaunchpadV8 = { version: "0.8.0"; name: "launchpad_v8"; - instructions: []; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + isOptional: true; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + docs: [ + 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', + "Initialized via CPI to mint_governor::initialize_mint_governor", + ]; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + docs: [ + 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', + "Initialized via CPI to mint_governor::add_mint_authority", + ]; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + ]; accounts: [ { name: "fundingRecord"; @@ -300,6 +428,72 @@ export type LaunchpadV8 = { ]; }; }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + }, + { + name: "teamAddress"; + type: "publicKey"; + }, + { + name: "additionalTokensAmount"; + type: "u64"; + }, + { + name: "accumulatorActivationDelaySeconds"; + type: "u32"; + }, + { + name: "hasBidWall"; + type: "bool"; + }, + ]; + }; + }, { name: "LaunchState"; type: { @@ -974,7 +1168,135 @@ export type LaunchpadV8 = { export const IDL: LaunchpadV8 = { version: "0.8.0", name: "launchpad_v8", - instructions: [], + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + isOptional: true, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + docs: [ + 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', + "Initialized via CPI to mint_governor::initialize_mint_governor", + ], + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + docs: [ + 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', + "Initialized via CPI to mint_governor::add_mint_authority", + ], + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + ], accounts: [ { name: "fundingRecord", @@ -1273,6 +1595,72 @@ export const IDL: LaunchpadV8 = { ], }, }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + { + name: "performancePackageGrantee", + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + }, + { + name: "teamAddress", + type: "publicKey", + }, + { + name: "additionalTokensAmount", + type: "u64", + }, + { + name: "accumulatorActivationDelaySeconds", + type: "u32", + }, + { + name: "hasBidWall", + type: "bool", + }, + ], + }, + }, { name: "LaunchState", type: { diff --git a/vibes/tasks.md b/vibes/tasks.md index 8950e13d6..3bf6ca54f 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -31,15 +31,7 @@ > Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" -- [NEXT] 2.1 Implement `initialize_launch` instruction (Rust) - - Create `src/instructions/initialize_launch.rs` with `InitializeLaunchArgs`, `InitializeLaunch` accounts struct, `validate()`, and `handle()` - - Port validation logic from v7 - - Implement handler: init Launch state, create metadata CPI, MintGovernor CPI chain (init governor → add mint authority → transfer authority) - - NO token::mint_to — base vault stays empty - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 2.2 Add `initializeLaunchIx` to SDK2 client +- [NEXT] 2.2 Add `initializeLaunchIx` to SDK2 client - Add the instruction builder method to `LaunchpadClient.ts` per spec - Derives MintGovernor + MintAuthority PDAs, passes all new accounts - Verify: `cd sdk2 && npx tsc --noEmit` From dd58c2a62751b95cef8ec5e4156d1c1148741f45 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 01:03:29 +0200 Subject: [PATCH 042/100] init launch sdk --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 167 ++++++++++++++++++++- vibes/tasks.md | 7 +- 2 files changed, 167 insertions(+), 7 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index bee670406..5a89ee069 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -1,12 +1,21 @@ import { AnchorProvider, Program } from "@coral-xyz/anchor"; import { PublicKey, AccountInfo } from "@solana/web3.js"; -import { LAUNCHPAD_V0_8_PROGRAM_ID } from "../../constants.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; import BN from "bn.js"; +import { + LAUNCHPAD_V0_8_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, + MAINNET_USDC, +} from "../../constants.js"; import { getFundingRecordAddr, getLaunchAddr, getLaunchSignerAddr, } from "./pda.js"; +import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; import { LaunchpadProgram, LaunchpadIDL, @@ -15,6 +24,11 @@ import { } from "./types/index.js"; import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; +import { + MintGovernorClient, + getMintGovernorAddr, + getMintAuthorityAddr, +} from "../../mint_governor/v0.7/index.js"; import { PerformancePackageV2Client, getPerformancePackageV2Addr, @@ -26,6 +40,7 @@ export type CreateLaunchpadClientParams = { launchpadProgramId?: PublicKey; autocratProgramId?: PublicKey; conditionalVaultProgramId?: PublicKey; + mintGovernorProgramId?: PublicKey; performancePackageV2ProgramId?: PublicKey; bidWallProgramId?: PublicKey; }; @@ -34,6 +49,7 @@ export class LaunchpadClient { public launchpad: Program; public provider: AnchorProvider; public autocratClient: FutarchyClient; + public mintGovernorClient: MintGovernorClient; public performancePackageV2: PerformancePackageV2Client; public bidWall: BidWallClient; @@ -49,6 +65,10 @@ export class LaunchpadClient { autocratProgramId: params.autocratProgramId, conditionalVaultProgramId: params.conditionalVaultProgramId, }); + this.mintGovernorClient = MintGovernorClient.createClient({ + provider: this.provider, + programId: params.mintGovernorProgramId, + }); this.performancePackageV2 = PerformancePackageV2Client.createClient({ provider: this.provider, programId: params.performancePackageV2ProgramId, @@ -108,6 +128,34 @@ export class LaunchpadClient { return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; } + getMintGovernorAddress({ + baseMint, + launchSigner, + }: { + baseMint: PublicKey; + launchSigner: PublicKey; + }): PublicKey { + return getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + })[0]; + } + + getMintAuthorityAddress({ + mintGovernor, + authorizedMinter, + }: { + mintGovernor: PublicKey; + authorizedMinter: PublicKey; + }): PublicKey { + return getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter, + })[0]; + } + getLaunchPerformancePackageAddress({ launch, }: { @@ -133,4 +181,121 @@ export class LaunchpadClient { }): PublicKey { return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; } + + initializeLaunchIx({ + tokenName, + tokenSymbol, + tokenUri, + minimumRaiseAmount, + secondsForLaunch = 60 * 60 * 24 * 5, // 5 days + baseMint, + quoteMint = MAINNET_USDC, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + launchAuthority = this.provider.publicKey, + payer = this.provider.publicKey, + additionalTokensRecipient, + additionalTokensAmount, + accumulatorActivationDelaySeconds = 0, + hasBidWall = false, + }: { + tokenName: string; + tokenSymbol: string; + tokenUri: string; + minimumRaiseAmount: BN; + secondsForLaunch?: number; + baseMint: PublicKey; + quoteMint?: PublicKey; + monthlySpendingLimitAmount: BN; + monthlySpendingLimitMembers: PublicKey[]; + performancePackageGrantee: PublicKey; + performancePackageTokenAmount: BN; + monthsUntilInsidersCanUnlock: number; + teamAddress: PublicKey; + launchAuthority?: PublicKey; + payer?: PublicKey; + additionalTokensRecipient?: PublicKey; + additionalTokensAmount?: BN; + accumulatorActivationDelaySeconds?: number; + hasBidWall: boolean; + }) { + const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); + const [launchSigner] = getLaunchSignerAddr( + this.launchpad.programId, + launch, + ); + const quoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const baseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + const [tokenMetadata] = getMetadataAddr(baseMint); + + // MintGovernor PDAs + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: launchSigner, + }); + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + + return this.launchpad.methods + .initializeLaunch({ + minimumRaiseAmount, + secondsForLaunch, + tokenName, + tokenSymbol, + tokenUri, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers, + performancePackageGrantee, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress, + additionalTokensAmount: additionalTokensAmount ?? new BN(0), + accumulatorActivationDelaySeconds, + hasBidWall, + }) + .accounts({ + launch, + launchSigner, + quoteVault, + baseVault, + launchAuthority, + quoteMint, + baseMint, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + payer, + additionalTokensRecipient: additionalTokensRecipient ?? null, + mintGovernor, + mintAuthority, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(quoteMint, launchSigner, true), + launchSigner, + quoteMint, + ), + ]); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index 3bf6ca54f..68e0a04bc 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -31,12 +31,7 @@ > Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" -- [NEXT] 2.2 Add `initializeLaunchIx` to SDK2 client - - Add the instruction builder method to `LaunchpadClient.ts` per spec - - Derives MintGovernor + MintAuthority PDAs, passes all new accounts - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 2.3 Write `initializeLaunch` tests (tests #1–5) +- [NEXT] 2.3 Write `initializeLaunch` tests (tests #1–5) - Test #1: "initializes a launch with valid parameters" — verify all Launch fields, MintGovernor setup, mint authority transfer, zero supply - Test #2: "fails when monthly spending limit members contains duplicates" - Test #3: "fails when monthly spending limit members is empty" From 13f87e008f412c1be169a5c1f8e04b1fca55e3a2 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 01:38:11 +0200 Subject: [PATCH 043/100] init launch tests --- .../src/instructions/initialize_launch.rs | 10 +- tests/launchpad_v8/main.test.ts | 3 + .../unit/initializeLaunch.test.ts | 371 ++++++++++++++++++ vibes/tasks.md | 10 +- 4 files changed, 380 insertions(+), 14 deletions(-) create mode 100644 tests/launchpad_v8/unit/initializeLaunch.test.ts diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs index 0d5d7e3ed..953999fde 100644 --- a/programs/v08_launchpad/src/instructions/initialize_launch.rs +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -50,14 +50,14 @@ pub struct InitializeLaunch<'info> { seeds = [b"launch", base_mint.key().as_ref()], bump )] - pub launch: Account<'info, Launch>, + pub launch: Box>, #[account( mut, mint::decimals = 6, mint::authority = launch_signer, )] - pub base_mint: Account<'info, Mint>, + pub base_mint: Box>, /// CHECK: This is the token metadata #[account( @@ -81,7 +81,7 @@ pub struct InitializeLaunch<'info> { associated_token::mint = quote_mint, associated_token::authority = launch_signer )] - pub quote_vault: Account<'info, TokenAccount>, + pub quote_vault: Box>, #[account( init_if_needed, @@ -89,7 +89,7 @@ pub struct InitializeLaunch<'info> { associated_token::mint = base_mint, associated_token::authority = launch_signer )] - pub base_vault: Account<'info, TokenAccount>, + pub base_vault: Box>, #[account(mut)] pub payer: Signer<'info>, @@ -98,7 +98,7 @@ pub struct InitializeLaunch<'info> { pub launch_authority: UncheckedAccount<'info>, #[account(mint::decimals = 6, address = usdc_mint::id())] - pub quote_mint: Account<'info, Mint>, + pub quote_mint: Box>, /// CHECK: Just the recipient of the additional tokens pub additional_tokens_recipient: Option>, diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index a3a343a03..30754c452 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -5,6 +5,7 @@ import { MAINNET_USDC, } from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; +import initializeLaunch from "./unit/initializeLaunch.test.js"; export default function suite() { before(async function () { @@ -63,4 +64,6 @@ export default function suite() { .rpc(); }; }); + + describe("#initialize_launch", initializeLaunch); } diff --git a/tests/launchpad_v8/unit/initializeLaunch.test.ts b/tests/launchpad_v8/unit/initializeLaunch.test.ts new file mode 100644 index 000000000..b85578be4 --- /dev/null +++ b/tests/launchpad_v8/unit/initializeLaunch.test.ts @@ -0,0 +1,371 @@ +import { + PublicKey, + Keypair, + SystemProgram, + Transaction, + Signer, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { + FutarchyClient, + MAINNET_USDC, + MPL_TOKEN_METADATA_PROGRAM_ID, +} from "@metadaoproject/futarchy-v2"; +import { + LaunchpadClient, + getLaunchAddr, + getLaunchSignerAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { + getMintGovernorAddr, + getMintAuthorityAddr, +} from "@metadaoproject/futarchy-v2/mint_governor/v0.7"; +import { getMetadataAddr } from "@metadaoproject/futarchy-v2"; +import { BN } from "bn.js"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import * as token from "@solana/spl-token"; +import { initializeMintWithSeeds } from "../utils.js"; +import { expectError } from "../../utils.js"; + +export default function suite() { + let futarchyClient: FutarchyClient; + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Signer; + + before(async function () { + futarchyClient = this.futarchy; + launchpadClient = this.launchpad_v8; + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + }); + + it("initializes a launch with valid parameters", async function () { + const minRaise = new BN(1000_000000); // 1000 USDC + const secondsForLaunch = 60 * 60 * 24 * 7; // 1 week + const monthlySpend = new BN(100_000000); + const recipientAddress = Keypair.generate().publicKey; + const premineAmount = new BN(500_000_000); + + const [, pdaBump] = getLaunchAddr(launchpadClient.getProgramId(), META); + const [, launchSignerPdaBump] = getLaunchSignerAddr( + launchpadClient.getProgramId(), + launch, + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: monthlySpend, + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: recipientAddress, + performancePackageTokenAmount: premineAmount, + monthsUntilInsidersCanUnlock: 18, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: true, + }) + .rpc(); + + const storedLaunch = await launchpadClient.fetchLaunch(launch); + + // Core launch fields + assert.equal( + storedLaunch.minimumRaiseAmount.toString(), + minRaise.toString(), + ); + assert.ok(storedLaunch.launchAuthority.equals(launchAuthority.publicKey)); + assert.ok(storedLaunch.launchSigner.equals(launchSigner)); + assert.equal(storedLaunch.launchSignerPdaBump, launchSignerPdaBump); + assert.ok( + storedLaunch.launchQuoteVault.equals( + token.getAssociatedTokenAddressSync(MAINNET_USDC, launchSigner, true), + ), + ); + assert.ok( + storedLaunch.launchBaseVault.equals( + token.getAssociatedTokenAddressSync(META, launchSigner, true), + ), + ); + assert.ok(storedLaunch.baseMint.equals(META)); + assert.equal(storedLaunch.pdaBump, pdaBump); + assert.equal(storedLaunch.totalCommittedAmount.toString(), "0"); + assert.equal(storedLaunch.seqNum.toString(), "0"); + assert.exists(storedLaunch.state.initialized); + assert.isNull(storedLaunch.unixTimestampStarted); + assert.isNull(storedLaunch.dao); + assert.equal(storedLaunch.accumulatorActivationDelaySeconds, 0); + assert.isTrue(storedLaunch.hasBidWall); + + // MintGovernor PDA stored on launch + const mintGovernorClient = launchpadClient.mintGovernorClient; + const [expectedMintGovernor] = getMintGovernorAddr({ + programId: mintGovernorClient.programId, + mint: META, + createKey: launchSigner, + }); + assert.ok(storedLaunch.mintGovernor.equals(expectedMintGovernor)); + + // MintGovernor initialized with admin = launch_signer + const mintGovernorAccount = + await mintGovernorClient.fetchMintGovernor(expectedMintGovernor); + assert.ok(mintGovernorAccount.admin.equals(launchSigner)); + assert.ok(mintGovernorAccount.mint.equals(META)); + + // MintAuthority for launch_signer with correct max_total + const [expectedMintAuthority] = getMintAuthorityAddr({ + programId: mintGovernorClient.programId, + mintGovernor: expectedMintGovernor, + authorizedMinter: launchSigner, + }); + const mintAuthorityAccount = await mintGovernorClient.fetchMintAuthority( + expectedMintAuthority, + ); + assert.ok(mintAuthorityAccount.authorizedMinter.equals(launchSigner)); + // max_total = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount + // = 10_000_000 + 2_000_000 + 900_000 + 0 = 12_900_000 tokens (scaled by 10^6) + const expectedMaxTotal = new BN("12900000000000"); // 12_900_000 * 1_000_000 + assert.equal( + mintAuthorityAccount.maxTotal.toString(), + expectedMaxTotal.toString(), + ); + + // SPL mint authority is the MintGovernor PDA + const mintInfo = await this.getMint(META); + assert.ok(mintInfo.mintAuthority.equals(expectedMintGovernor)); + + // Zero supply, zero base vault balance + assert.equal(mintInfo.supply.toString(), "0"); + const baseVaultBalance = await this.getTokenBalance(META, launchSigner); + assert.equal(baseVaultBalance.toString(), "0"); + }); + + it("fails when monthly spending limit members contains duplicates", async function () { + const minRaise = new BN(1000_000000); + const secondsForLaunch = 60 * 60 * 24 * 7; + const monthlySpend = new BN(100_000000); + const recipientAddress = Keypair.generate().publicKey; + const premineAmount = new BN(500_000_000); + + const callbacks = expectError( + "InvalidMonthlySpendingLimitMembers", + "Should have rejected duplicate monthly spending limit members", + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: monthlySpend, + monthlySpendingLimitMembers: [ + this.payer.publicKey, + this.payer.publicKey, + ], + performancePackageGrantee: recipientAddress, + performancePackageTokenAmount: premineAmount, + monthsUntilInsidersCanUnlock: 18, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: false, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("fails when monthly spending limit members is empty", async function () { + const minRaise = new BN(1000_000000); + const secondsForLaunch = 60 * 60 * 24 * 7; + const monthlySpend = new BN(100_000000); + const recipientAddress = Keypair.generate().publicKey; + const premineAmount = new BN(500_000_000); + + const callbacks = expectError( + "InvalidMonthlySpendingLimitMembers", + "Should have rejected empty monthly spending limit members", + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: monthlySpend, + monthlySpendingLimitMembers: [], + performancePackageGrantee: recipientAddress, + performancePackageTokenAmount: premineAmount, + monthsUntilInsidersCanUnlock: 18, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: false, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("rejects accumulator activation delay >= seconds_for_launch", async function () { + const minRaise = new BN(1000_000000); + const secondsForLaunch = 60 * 60 * 24 * 7; + const monthlySpend = new BN(100_000000); + const recipientAddress = Keypair.generate().publicKey; + const premineAmount = new BN(500_000_000); + + const callbacks = expectError( + "InvalidAccumulatorActivationDelaySeconds", + "Should have rejected accumulator activation delay >= seconds_for_launch", + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: monthlySpend, + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: recipientAddress, + performancePackageTokenAmount: premineAmount, + monthsUntilInsidersCanUnlock: 18, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + accumulatorActivationDelaySeconds: secondsForLaunch, + hasBidWall: false, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("fails when launch signer is faked", async function () { + const minRaise = new BN(1000_000000); + const secondsForLaunch = 60 * 60 * 24 * 7; + const fakeLaunchSigner = Keypair.generate(); + const monthlySpend = new BN(100_000000); + const recipientAddress = Keypair.generate().publicKey; + const premineAmount = new BN(500_000_000); + + const fakeSignerFrom = Keypair.generate(); + const fakeSignerFromPubkey = fakeSignerFrom.publicKey; + + META = await PublicKey.createWithSeed( + fakeSignerFrom.publicKey, + "fake-launch-signer", + token.TOKEN_PROGRAM_ID, + ); + + const rent = await this.banksClient.getRent(); + + const lamports = Number(await rent.minimumBalance(BigInt(token.MINT_SIZE))); + + const tx = new Transaction().add( + SystemProgram.createAccountWithSeed({ + fromPubkey: this.payer.publicKey, + newAccountPubkey: META, + basePubkey: fakeSignerFromPubkey, + seed: "fake-launch-signer", + lamports: lamports, + space: token.MINT_SIZE, + programId: token.TOKEN_PROGRAM_ID, + }), + token.createInitializeMint2Instruction( + META, + 6, + fakeLaunchSigner.publicKey, + null, + ), + ); + tx.recentBlockhash = (await this.banksClient.getLatestBlockhash())[0]; + tx.feePayer = this.payer.publicKey; + tx.sign(this.payer, fakeSignerFrom); + + await this.banksClient.processTransaction(tx); + + const [tokenMetadata] = getMetadataAddr(META); + + const callbacks = expectError( + "ConstraintSeeds", + "Should have rejected faked launch signer", + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: monthlySpend, + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: recipientAddress, + performancePackageTokenAmount: premineAmount, + monthsUntilInsidersCanUnlock: 18, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: false, + }) + .accounts({ + launch, + launchSigner: fakeLaunchSigner.publicKey, + quoteVault: token.getAssociatedTokenAddressSync( + MAINNET_USDC, + fakeLaunchSigner.publicKey, + true, + ), + baseVault: token.getAssociatedTokenAddressSync( + META, + fakeLaunchSigner.publicKey, + true, + ), + launchAuthority: launchAuthority.publicKey, + quoteMint: MAINNET_USDC, + baseMint: META, + tokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + }) + .preInstructions([ + token.createAssociatedTokenAccountIdempotentInstruction( + this.payer.publicKey, + getAssociatedTokenAddressSync( + MAINNET_USDC, + fakeLaunchSigner.publicKey, + true, + ), + fakeLaunchSigner.publicKey, + MAINNET_USDC, + ), + ]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index 68e0a04bc..e9aa11dab 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -31,19 +31,11 @@ > Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" -- [NEXT] 2.3 Write `initializeLaunch` tests (tests #1–5) - - Test #1: "initializes a launch with valid parameters" — verify all Launch fields, MintGovernor setup, mint authority transfer, zero supply - - Test #2: "fails when monthly spending limit members contains duplicates" - - Test #3: "fails when monthly spending limit members is empty" - - Test #4: "rejects accumulator activation delay >= seconds_for_launch" - - Test #5: "fails when launch signer is faked" - - Verify: `anchor test --skip-build` (with `.only` on this suite) - ### Phase 3: `start_launch` + `fund` + `close_launch` > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [ ] 3.1 Implement `start_launch` instruction (Rust) +- [NEXT] 3.1 Implement `start_launch` instruction (Rust) - Create `src/instructions/start_launch.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 51c0a8e4e394a6956b2b6a21297f5136b185cbaa Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 01:49:51 +0200 Subject: [PATCH 044/100] start launch ix --- programs/launchpad | 2 +- .../v08_launchpad/src/instructions/mod.rs | 2 + .../src/instructions/start_launch.rs | 46 ++++++++++++++++ programs/v08_launchpad/src/lib.rs | 5 ++ sdk/src/v0.7/types/launchpad_v8.ts | 52 +++++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 52 +++++++++++++++++++ vibes/tasks.md | 7 +-- 7 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/start_launch.rs diff --git a/programs/launchpad b/programs/launchpad index 95304772f..9cb969192 120000 --- a/programs/launchpad +++ b/programs/launchpad @@ -1 +1 @@ -v07_launchpad \ No newline at end of file +v08_launchpad \ No newline at end of file diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 2a1261123..b2dd35f62 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,3 +1,5 @@ pub mod initialize_launch; +pub mod start_launch; pub use initialize_launch::*; +pub use start_launch::*; diff --git a/programs/v08_launchpad/src/instructions/start_launch.rs b/programs/v08_launchpad/src/instructions/start_launch.rs new file mode 100644 index 000000000..54bd9b264 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/start_launch.rs @@ -0,0 +1,46 @@ +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchStartedEvent}; +use crate::state::{Launch, LaunchState}; +use anchor_lang::prelude::*; + +#[event_cpi] +#[derive(Accounts)] +pub struct StartLaunch<'info> { + #[account( + mut, + has_one = launch_authority, + )] + pub launch: Account<'info, Launch>, + + pub launch_authority: Signer<'info>, +} + +impl StartLaunch<'_> { + pub fn validate(&self) -> Result<()> { + require!( + self.launch.state == LaunchState::Initialized, + LaunchpadError::LaunchNotInitialized + ); + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch = &mut ctx.accounts.launch; + let clock = Clock::get()?; + + launch.state = LaunchState::Live; + launch.unix_timestamp_started = Some(clock.unix_timestamp); + + launch.seq_num += 1; + + emit_cpi!(LaunchStartedEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: ctx.accounts.launch.key(), + launch_authority: ctx.accounts.launch_authority.key(), + slot_started: clock.slot, + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 11ad8b83f..9e2bc632c 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -75,4 +75,9 @@ pub mod launchpad_v8 { ) -> Result<()> { InitializeLaunch::handle(ctx, args) } + + #[access_control(ctx.accounts.validate())] + pub fn start_launch(ctx: Context) -> Result<()> { + StartLaunch::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 3875bb367..2cd41b1c2 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -129,6 +129,32 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1296,6 +1322,32 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 3875bb367..2cd41b1c2 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -129,6 +129,32 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1296,6 +1322,32 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index e9aa11dab..44405e81b 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -35,12 +35,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.1 Implement `start_launch` instruction (Rust) - - Create `src/instructions/start_launch.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 3.2 Implement `fund` instruction (Rust) +- [NEXT] 3.2 Implement `fund` instruction (Rust) - Create `src/instructions/fund.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 4c10c1011d26b1bf9430001121f5208a7ca8d254 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 01:56:29 +0200 Subject: [PATCH 045/100] fund ix --- .../v08_launchpad/src/instructions/fund.rs | 133 ++++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 5 + sdk/src/v0.7/types/launchpad_v8.ts | 122 ++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 122 ++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 385 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/fund.rs diff --git a/programs/v08_launchpad/src/instructions/fund.rs b/programs/v08_launchpad/src/instructions/fund.rs new file mode 100644 index 000000000..734215e6d --- /dev/null +++ b/programs/v08_launchpad/src/instructions/fund.rs @@ -0,0 +1,133 @@ +use anchor_lang::prelude::*; +use anchor_spl::token::{self, Token, TokenAccount, Transfer}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchFundedEvent}; +use crate::state::{FundingRecord, Launch, LaunchState}; + +#[event_cpi] +#[derive(Accounts)] +pub struct Fund<'info> { + #[account( + mut, + has_one = launch_quote_vault, + )] + pub launch: Account<'info, Launch>, + + #[account( + init_if_needed, + payer = payer, + space = 8 + FundingRecord::INIT_SPACE, + seeds = [b"funding_record", launch.key().as_ref(), funder.key().as_ref()], + bump + )] + pub funding_record: Account<'info, FundingRecord>, + + #[account(mut)] + pub launch_quote_vault: Account<'info, TokenAccount>, + + pub funder: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + + #[account( + mut, + associated_token::mint = launch.quote_mint, + associated_token::authority = funder + )] + pub funder_quote_account: Account<'info, TokenAccount>, + + pub token_program: Program<'info, Token>, + pub system_program: Program<'info, System>, +} + +impl Fund<'_> { + pub fn validate(&self, amount: u64) -> Result<()> { + require!(amount > 0, LaunchpadError::InvalidAmount); + + require_gte!( + self.funder_quote_account.amount, + amount, + LaunchpadError::InsufficientFunds + ); + + require!( + self.launch.state == LaunchState::Live, + LaunchpadError::InvalidLaunchState + ); + + let clock = Clock::get()?; + + require_gt!( + self.launch.unix_timestamp_started.unwrap() + self.launch.seconds_for_launch as i64, + clock.unix_timestamp, + LaunchpadError::LaunchExpired + ); + + Ok(()) + } + + pub fn handle(ctx: Context, amount: u64) -> Result<()> { + token::transfer( + CpiContext::new( + ctx.accounts.token_program.to_account_info(), + Transfer { + from: ctx.accounts.funder_quote_account.to_account_info(), + to: ctx.accounts.launch_quote_vault.to_account_info(), + authority: ctx.accounts.funder.to_account_info(), + }, + ), + amount, + )?; + + let funding_record = &mut ctx.accounts.funding_record; + let clock = Clock::get()?; + + if funding_record.funder == ctx.accounts.funder.key() { + // Existing funding record — flush accumulator before changing committed_amount + let activation_timestamp = ctx.accounts.launch.unix_timestamp_started.unwrap() + + ctx.accounts.launch.accumulator_activation_delay_seconds as i64; + let now = clock.unix_timestamp; + + if funding_record.last_accumulator_update > 0 && now > activation_timestamp { + let period_start = + std::cmp::max(funding_record.last_accumulator_update, activation_timestamp); + let elapsed = now - period_start; + funding_record.committed_amount_accumulator += + (funding_record.committed_amount as u128) * (elapsed as u128); + } + + funding_record.last_accumulator_update = now; + funding_record.committed_amount += amount; + } else { + funding_record.set_inner(FundingRecord { + pda_bump: ctx.bumps.funding_record, + funder: ctx.accounts.funder.key(), + launch: ctx.accounts.launch.key(), + committed_amount: amount, + is_tokens_claimed: false, + is_usdc_refunded: false, + approved_amount: 0, + committed_amount_accumulator: 0, + last_accumulator_update: clock.unix_timestamp, + }); + } + + ctx.accounts.launch.total_committed_amount += amount; + + ctx.accounts.launch.seq_num += 1; + + emit_cpi!(LaunchFundedEvent { + common: CommonFields::new(&clock, ctx.accounts.launch.seq_num), + launch: ctx.accounts.launch.key(), + funder: ctx.accounts.funder.key(), + amount, + total_committed: ctx.accounts.launch.total_committed_amount, + funding_record: funding_record.key(), + total_committed_by_funder: funding_record.committed_amount, + committed_amount_accumulator: funding_record.committed_amount_accumulator, + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index b2dd35f62..a06957a02 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,5 +1,7 @@ +pub mod fund; pub mod initialize_launch; pub mod start_launch; +pub use fund::*; pub use initialize_launch::*; pub use start_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 9e2bc632c..d3c08d1c5 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -80,4 +80,9 @@ pub mod launchpad_v8 { pub fn start_launch(ctx: Context) -> Result<()> { StartLaunch::handle(ctx) } + + #[access_control(ctx.accounts.validate(amount))] + pub fn fund(ctx: Context, amount: u64) -> Result<()> { + Fund::handle(ctx, amount) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 2cd41b1c2..1e467a851 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -155,6 +155,67 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, ]; accounts: [ { @@ -1348,6 +1409,67 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 2cd41b1c2..1e467a851 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -155,6 +155,67 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, ]; accounts: [ { @@ -1348,6 +1409,67 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 44405e81b..56fcf2448 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -35,12 +35,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.2 Implement `fund` instruction (Rust) - - Create `src/instructions/fund.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 3.3 Implement `close_launch` instruction (Rust) +- [NEXT] 3.3 Implement `close_launch` instruction (Rust) - Create `src/instructions/close_launch.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From b3550e18dd9a2e4e9c96bde1e01f671d963dd58d Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 02:01:26 +0200 Subject: [PATCH 046/100] close launch ix --- .../src/instructions/close_launch.rs | 57 +++++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 5 ++ sdk/src/v0.7/types/launchpad_v8.ts | 42 ++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 42 ++++++++++++++ vibes/tasks.md | 7 +-- 6 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/close_launch.rs diff --git a/programs/v08_launchpad/src/instructions/close_launch.rs b/programs/v08_launchpad/src/instructions/close_launch.rs new file mode 100644 index 000000000..1eeb4be77 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/close_launch.rs @@ -0,0 +1,57 @@ +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchCloseEvent}; +use crate::state::{Launch, LaunchState}; +use anchor_lang::prelude::*; + +#[event_cpi] +#[derive(Accounts)] +pub struct CloseLaunch<'info> { + #[account(mut)] + pub launch: Account<'info, Launch>, +} + +impl CloseLaunch<'_> { + pub fn validate(&self) -> Result<()> { + require_eq!( + self.launch.state, + LaunchState::Live, + LaunchpadError::LaunchNotLive + ); + + let clock = Clock::get()?; + + require_gte!( + clock.unix_timestamp, + self.launch + .unix_timestamp_started + .unwrap() + .saturating_add(self.launch.seconds_for_launch.try_into().unwrap()), + LaunchpadError::LaunchPeriodNotOver + ); + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch = &mut ctx.accounts.launch; + let clock = Clock::get()?; + + if launch.minimum_raise_amount > launch.total_committed_amount { + launch.state = LaunchState::Refunding; + launch.unix_timestamp_closed = Some(clock.unix_timestamp); + } else { + launch.state = LaunchState::Closed; + launch.unix_timestamp_closed = Some(clock.unix_timestamp); + } + + launch.seq_num += 1; + + emit_cpi!(LaunchCloseEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + new_state: launch.state, + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index a06957a02..bdd032df0 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,7 +1,9 @@ +pub mod close_launch; pub mod fund; pub mod initialize_launch; pub mod start_launch; +pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; pub use start_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index d3c08d1c5..8db74b300 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -85,4 +85,9 @@ pub mod launchpad_v8 { pub fn fund(ctx: Context, amount: u64) -> Result<()> { Fund::handle(ctx, amount) } + + #[access_control(ctx.accounts.validate())] + pub fn close_launch(ctx: Context) -> Result<()> { + CloseLaunch::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 1e467a851..93fc5169b 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -216,6 +216,27 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "closeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1470,6 +1491,27 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "closeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 1e467a851..93fc5169b 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -216,6 +216,27 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "closeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1470,6 +1491,27 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "closeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 56fcf2448..bec5f2c37 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -35,12 +35,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.3 Implement `close_launch` instruction (Rust) - - Create `src/instructions/close_launch.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 3.4 Add `startLaunchIx`, `fundIx`, `closeLaunchIx` to SDK2 client +- [NEXT] 3.4 Add `startLaunchIx`, `fundIx`, `closeLaunchIx` to SDK2 client - Port from v7 SDK2 client, targeting v0.8 program - Verify: `cd sdk2 && npx tsc --noEmit` From 61e57eafad214e6c5d0a03c33e6c01ce94c6cec7 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 02:05:17 +0200 Subject: [PATCH 047/100] update sdk ixs --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 60 ++++++++++++++++++++++ vibes/tasks.md | 6 +-- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 5a89ee069..cec22490a 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -298,4 +298,64 @@ export class LaunchpadClient { ), ]); } + + startLaunchIx({ + launch, + launchAuthority = this.provider.publicKey, + }: { + launch: PublicKey; + launchAuthority?: PublicKey; + }) { + return this.launchpad.methods.startLaunch().accounts({ + launch, + launchAuthority, + }); + } + + fundIx({ + launch, + amount, + funder = this.provider.publicKey, + payer = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + amount: BN; + funder?: PublicKey; + payer?: PublicKey; + quoteMint?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods.fund(amount).accounts({ + launch, + launchQuoteVault, + fundingRecord, + funder, + payer, + funderQuoteAccount, + }); + } + + closeLaunchIx({ launch }: { launch: PublicKey }) { + return this.launchpad.methods.closeLaunch().accounts({ + launch, + }); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index bec5f2c37..b181e04bd 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -35,11 +35,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.4 Add `startLaunchIx`, `fundIx`, `closeLaunchIx` to SDK2 client - - Port from v7 SDK2 client, targeting v0.8 program - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 3.5 Write `startLaunch` tests (test #6) +- [NEXT] 3.5 Write `startLaunch` tests (test #6) - Test #6: "starts launch correctly" - Verify: `anchor test --skip-build` (with `.only`) From 6db8ebc60e5dd4b3ede3985f6ffcae80858df86f Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 02:12:35 +0200 Subject: [PATCH 048/100] start launch test --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/startLaunch.test.ts | 59 +++++++++++++++++++++ vibes/tasks.md | 8 ++- 3 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 tests/launchpad_v8/unit/startLaunch.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index 30754c452..f8bbf9074 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -6,6 +6,7 @@ import { } from "@metadaoproject/futarchy-v2"; import BN from "bn.js"; import initializeLaunch from "./unit/initializeLaunch.test.js"; +import startLaunch from "./unit/startLaunch.test.js"; export default function suite() { before(async function () { @@ -66,4 +67,5 @@ export default function suite() { }); describe("#initialize_launch", initializeLaunch); + describe("#start_launch", startLaunch); } diff --git a/tests/launchpad_v8/unit/startLaunch.test.ts b/tests/launchpad_v8/unit/startLaunch.test.ts new file mode 100644 index 000000000..116afbb0d --- /dev/null +++ b/tests/launchpad_v8/unit/startLaunch.test.ts @@ -0,0 +1,59 @@ +import { PublicKey, Keypair, Signer } from "@solana/web3.js"; +import { assert } from "chai"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { initializeMintWithSeeds } from "../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchAuthority: Signer; + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + }); + + it.only("starts launch correctly", async function () { + // Check initial state + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.isNull(launchAccount.unixTimestampStarted); + assert.exists(launchAccount.state.initialized); + + const clock = await this.banksClient.getClock(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + launchAccount = await launchpadClient.fetchLaunch(launch); + + assert.exists(launchAccount.state.live); + assert.equal( + launchAccount.unixTimestampStarted.toString(), + clock.unixTimestamp.toString(), + ); + assert.equal(launchAccount.seqNum.toString(), "1"); + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index b181e04bd..606f106c8 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -17,6 +17,8 @@ - Skip ahead - Forget to verify +**IMPORTANT:** After completing a task, always run `./rebuild.sh` before handing back to the user. This rebuilds programs, regenerates SDK types, syncs node_modules, and lints. + **Reference:** Full implementation plan is in `vibes/launchpad_v8_spec.md` --- @@ -35,11 +37,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.5 Write `startLaunch` tests (test #6) - - Test #6: "starts launch correctly" - - Verify: `anchor test --skip-build` (with `.only`) - -- [ ] 3.6 Write `fund` tests (tests #7–15) +- [NEXT] 3.6 Write `fund` tests (tests #7–15) - Tests #7–15: all fund tests per spec - Verify: `anchor test --skip-build` (with `.only`) From 9d3e61a5d60b0ee8098b6df8933f64b502c79d51 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 02:25:00 +0200 Subject: [PATCH 049/100] fund tests --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/fund.test.ts | 591 ++++++++++++++++++++ tests/launchpad_v8/unit/startLaunch.test.ts | 2 +- vibes/tasks.md | 6 +- 4 files changed, 595 insertions(+), 6 deletions(-) create mode 100644 tests/launchpad_v8/unit/fund.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index f8bbf9074..ca4e3d8d5 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -7,6 +7,7 @@ import { import BN from "bn.js"; import initializeLaunch from "./unit/initializeLaunch.test.js"; import startLaunch from "./unit/startLaunch.test.js"; +import fund from "./unit/fund.test.js"; export default function suite() { before(async function () { @@ -68,4 +69,5 @@ export default function suite() { describe("#initialize_launch", initializeLaunch); describe("#start_launch", startLaunch); + describe("#fund", fund); } diff --git a/tests/launchpad_v8/unit/fund.test.ts b/tests/launchpad_v8/unit/fund.test.ts new file mode 100644 index 000000000..a7c99cc66 --- /dev/null +++ b/tests/launchpad_v8/unit/fund.test.ts @@ -0,0 +1,591 @@ +import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; +import { assert } from "chai"; +import { + LaunchpadClient, + getFundingRecordAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { getAccount } from "spl-token-bankrun"; +import { BN } from "bn.js"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { initializeMintWithSeeds } from "../utils.js"; +import { expectError } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + let quoteVault: PublicKey; + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + quoteVault = getAssociatedTokenAddressSync( + MAINNET_USDC, + launchSigner, + true, + ); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + }); + + it("fails to fund the launch before it's started", async function () { + const fundAmount = new BN(100 * 10 ** 6); + + const callbacks = expectError( + "InvalidLaunchState", + "Should have rejected funding before launch started", + ); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("successfully funds the launch", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundAmount = new BN(100 * 10 ** 6); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalCommittedAmount.toString(), + fundAmount.toString(), + ); + + const usdcVaultAccount = await getAccount(this.banksClient, quoteVault); + assert.equal(usdcVaultAccount.amount.toString(), fundAmount.toString()); + + const [fundingRecord, pdaBump] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal( + fundingRecordAccount.committedAmount.toString(), + fundAmount.toString(), + ); + assert.equal(fundingRecordAccount.pdaBump, pdaBump); + assert.ok(fundingRecordAccount.funder.equals(this.payer.publicKey)); + assert.ok(fundingRecordAccount.launch.equals(launch)); + assert.isFalse(fundingRecordAccount.isTokensClaimed); + assert.isFalse(fundingRecordAccount.isUsdcRefunded); + assert.equal(fundingRecordAccount.approvedAmount.toString(), "0"); + }); + + it("two different funders get independent funding records", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const funder2 = new Keypair(); + await this.createTokenAccount(MAINNET_USDC, funder2.publicKey); + await this.transfer( + MAINNET_USDC, + this.payer, + funder2.publicKey, + 500 * 10 ** 6, + ); + + const amount1 = new BN(100 * 10 ** 6); + const amount2 = new BN(300 * 10 ** 6); + + // Funder 1 (payer) + await launchpadClient + .fundIx({ + launch, + amount: amount1, + payer: this.payer.publicKey, + }) + .rpc(); + + // Funder 2 + await launchpadClient + .fundIx({ + launch, + amount: amount2, + funder: funder2.publicKey, + payer: this.payer.publicKey, + }) + .signers([funder2]) + .rpc(); + + // Each funding record is independent + const [fr1] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + const [fr2] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + funder2.publicKey, + ); + + const frAccount1 = await launchpadClient.fetchFundingRecord(fr1); + const frAccount2 = await launchpadClient.fetchFundingRecord(fr2); + + assert.equal(frAccount1.committedAmount.toString(), amount1.toString()); + assert.ok(frAccount1.funder.equals(this.payer.publicKey)); + + assert.equal(frAccount2.committedAmount.toString(), amount2.toString()); + assert.ok(frAccount2.funder.equals(funder2.publicKey)); + + // Launch total is the sum + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalCommittedAmount.toString(), + amount1.add(amount2).toString(), + ); + + const usdcVaultAccount = await getAccount(this.banksClient, quoteVault); + assert.equal( + usdcVaultAccount.amount.toString(), + amount1.add(amount2).toString(), + ); + }); + + it("successfully funds the launch multiple times", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundAmount1 = new BN(100 * 10 ** 6); + const fundAmount2 = new BN(200 * 10 ** 6); + const totalAmount = fundAmount1.add(fundAmount2); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount1, + payer: this.payer.publicKey, + }) + .rpc(); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount2, + payer: this.payer.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalCommittedAmount.toString(), + totalAmount.toString(), + ); + + const usdcVaultAccount = await getAccount(this.banksClient, quoteVault); + assert.equal(usdcVaultAccount.amount.toString(), totalAmount.toString()); + + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal( + fundingRecordAccount.committedAmount.toString(), + totalAmount.toString(), + ); + }); + + it("fails to fund the launch at the exact boundary second", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + const secondsForLaunch = launchAccount.secondsForLaunch; + + // Advance to the exact expiration boundary + await this.advanceBySeconds(secondsForLaunch); + + const fundAmount = new BN(100 * 10 ** 6); + + const callbacks = expectError( + "LaunchExpired", + "Should have rejected funding at exact boundary", + ); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("fails to fund the launch after time expires", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + const secondsForLaunch = launchAccount.secondsForLaunch; + + // Advance past the launch period + await this.advanceBySeconds(secondsForLaunch + 10); + + const fundAmount = new BN(100 * 10 ** 6); + + const callbacks = expectError( + "LaunchExpired", + "Should have rejected funding after expiration", + ); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("accumulator starts at 0 and last_accumulator_update is set on first fund", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const clock = await this.banksClient.getClock(); + + const fundAmount = new BN(100 * 10 ** 6); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal( + fundingRecordAccount.committedAmountAccumulator.toString(), + "0", + ); + assert.equal( + fundingRecordAccount.lastAccumulatorUpdate.toString(), + clock.unixTimestamp.toString(), + ); + }); + + it("accumulator correctly sums across multiple time intervals", async function () { + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundAmount1 = new BN(100 * 10 ** 6); + const fundAmount2 = new BN(200 * 10 ** 6); + + // First fund at t=0 + await launchpadClient + .fundIx({ + launch, + amount: fundAmount1, + payer: this.payer.publicKey, + }) + .rpc(); + + const clock1 = await this.banksClient.getClock(); + + // Advance 60 seconds + const elapsed1 = 60; + await this.advanceBySeconds(elapsed1); + + // Second fund at t=60 + await launchpadClient + .fundIx({ + launch, + amount: fundAmount2, + payer: this.payer.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + + // Accumulator = fundAmount1 * elapsed1 = 100_000_000 * 60 = 6_000_000_000 + const expectedAccumulator = new BN(100 * 10 ** 6).muln(elapsed1); + assert.equal( + fundingRecordAccount.committedAmountAccumulator.toString(), + expectedAccumulator.toString(), + ); + assert.equal( + fundingRecordAccount.committedAmount.toString(), + fundAmount1.add(fundAmount2).toString(), + ); + }); + + it("accumulator stays 0 during activation delay period", async function () { + // Create a launch with accumulator activation delay + const delayResult = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + const delayMeta = delayResult.tokenMint; + const delayLaunch = delayResult.launch; + const delayLaunchSigner = delayResult.launchSigner; + const delayLaunchAuthority = new Keypair(); + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + const delaySeconds = 3600; // 1 hour delay + + await launchpadClient + .initializeLaunchIx({ + tokenName: "DELAY", + tokenSymbol: "DELAY", + tokenUri: "https://example.com", + minimumRaiseAmount: new BN(100_000 * 10 ** 6), + secondsForLaunch, + baseMint: delayMeta, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: delayLaunchAuthority.publicKey, + accumulatorActivationDelaySeconds: delaySeconds, + hasBidWall: false, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch: delayLaunch, + launchAuthority: delayLaunchAuthority.publicKey, + }) + .signers([delayLaunchAuthority]) + .rpc(); + + const fundAmount = new BN(100 * 10 ** 6); + + // Fund at t=0 (within delay period) + await launchpadClient + .fundIx({ + launch: delayLaunch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + // Advance 30 minutes (still within 1 hour delay) + await this.advanceBySeconds(1800); + + // Fund again still within delay period + await launchpadClient + .fundIx({ + launch: delayLaunch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + delayLaunch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + + // Accumulator should remain 0 because both funds happened during the delay period + assert.equal( + fundingRecordAccount.committedAmountAccumulator.toString(), + "0", + ); + }); + + it("accumulator only counts time after activation delay", async function () { + // Create a launch with accumulator activation delay + const delayResult = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + const delayMeta = delayResult.tokenMint; + const delayLaunch = delayResult.launch; + const delayLaunchSigner = delayResult.launchSigner; + const delayLaunchAuthority = new Keypair(); + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + const delaySeconds = 3600; // 1 hour delay + + await launchpadClient + .initializeLaunchIx({ + tokenName: "DELAY2", + tokenSymbol: "DELAY2", + tokenUri: "https://example.com", + minimumRaiseAmount: new BN(100_000 * 10 ** 6), + secondsForLaunch, + baseMint: delayMeta, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: delayLaunchAuthority.publicKey, + accumulatorActivationDelaySeconds: delaySeconds, + hasBidWall: false, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch: delayLaunch, + launchAuthority: delayLaunchAuthority.publicKey, + }) + .signers([delayLaunchAuthority]) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(delayLaunch); + const startTime = launchAccount.unixTimestampStarted.toNumber(); + const activationTimestamp = startTime + delaySeconds; + + const fundAmount = new BN(100 * 10 ** 6); + + // Fund at t=0 (before activation) + await launchpadClient + .fundIx({ + launch: delayLaunch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + // Advance past the activation delay + 120 seconds + const timeAfterActivation = 120; + await this.advanceBySeconds(delaySeconds + timeAfterActivation); + + // Fund again after activation delay + await launchpadClient + .fundIx({ + launch: delayLaunch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + delayLaunch, + this.payer.publicKey, + ); + + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + + // The accumulator should only count time after the activation timestamp. + // period_start = max(last_accumulator_update=startTime, activation_timestamp) = activation_timestamp + // elapsed = (startTime + delaySeconds + timeAfterActivation) - activation_timestamp = timeAfterActivation = 120 + // accumulator = fundAmount * 120 = 100_000_000 * 120 = 12_000_000_000 + const expectedAccumulator = new BN(100 * 10 ** 6).muln(timeAfterActivation); + assert.equal( + fundingRecordAccount.committedAmountAccumulator.toString(), + expectedAccumulator.toString(), + ); + }); +} diff --git a/tests/launchpad_v8/unit/startLaunch.test.ts b/tests/launchpad_v8/unit/startLaunch.test.ts index 116afbb0d..5cf37b868 100644 --- a/tests/launchpad_v8/unit/startLaunch.test.ts +++ b/tests/launchpad_v8/unit/startLaunch.test.ts @@ -31,7 +31,7 @@ export default function suite() { }); }); - it.only("starts launch correctly", async function () { + it("starts launch correctly", async function () { // Check initial state let launchAccount = await launchpadClient.fetchLaunch(launch); assert.isNull(launchAccount.unixTimestampStarted); diff --git a/vibes/tasks.md b/vibes/tasks.md index 606f106c8..015a6d1bb 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -37,11 +37,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.6 Write `fund` tests (tests #7–15) - - Tests #7–15: all fund tests per spec - - Verify: `anchor test --skip-build` (with `.only`) - -- [ ] 3.7 Write `closeLaunch` tests (tests #16–20) +- [NEXT] 3.7 Write `closeLaunch` tests (tests #16–20) - Tests #16–20: all close_launch tests per spec - Verify: `anchor test --skip-build` (with `.only`) From a72ace5d7dec3532bbcde9c36d6ed57b3b5bc741 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 02:32:31 +0200 Subject: [PATCH 050/100] close launch tests --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/closeLaunch.test.ts | 190 ++++++++++++++++++++ vibes/tasks.md | 6 +- 3 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 tests/launchpad_v8/unit/closeLaunch.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index ca4e3d8d5..51eee8ddd 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -8,6 +8,7 @@ import BN from "bn.js"; import initializeLaunch from "./unit/initializeLaunch.test.js"; import startLaunch from "./unit/startLaunch.test.js"; import fund from "./unit/fund.test.js"; +import closeLaunch from "./unit/closeLaunch.test.js"; export default function suite() { before(async function () { @@ -70,4 +71,5 @@ export default function suite() { describe("#initialize_launch", initializeLaunch); describe("#start_launch", startLaunch); describe("#fund", fund); + describe("#close_launch", closeLaunch); } diff --git a/tests/launchpad_v8/unit/closeLaunch.test.ts b/tests/launchpad_v8/unit/closeLaunch.test.ts new file mode 100644 index 000000000..4504e5264 --- /dev/null +++ b/tests/launchpad_v8/unit/closeLaunch.test.ts @@ -0,0 +1,190 @@ +import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; +import { assert } from "chai"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { BN } from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { expectError } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + }); + + it("successfully closes launch after sufficient time when minimum raise is met", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + const secondsForLaunch = launchAccount.secondsForLaunch; + + await this.advanceBySeconds(secondsForLaunch + 100); + + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + const updatedLaunch = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(updatedLaunch.state, { closed: {} }); + assert.isNotNull(updatedLaunch.unixTimestampClosed); + }); + + it("successfully closes launch after sufficient time when minimum raise is not met", async function () { + const fundAmount = new BN(100 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + const secondsForLaunch = launchAccount.secondsForLaunch; + + await this.advanceBySeconds(secondsForLaunch + 100); + + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + const updatedLaunch = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(updatedLaunch.state, { refunding: {} }); + assert.isNotNull(updatedLaunch.unixTimestampClosed); + }); + + it("fails to close launch before sufficient time has passed", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + await this.advanceBySeconds(60 * 60); + + const callbacks = expectError( + "LaunchPeriodNotOver", + "Should have rejected closing before launch period ended", + ); + + await launchpadClient + .closeLaunchIx({ launch }) + .rpc() + .then(callbacks[0], callbacks[1]); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { live: {} }); + assert.isNull(launchAccount.unixTimestampClosed); + }); + + it("fails to close launch when launch has already been closed", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + const secondsForLaunch = launchAccount.secondsForLaunch; + + await this.advanceBySeconds(secondsForLaunch + 100); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + const callbacks = expectError( + "LaunchNotLive", + "Should have rejected closing an already closed launch", + ); + + await launchpadClient + .closeLaunchIx({ launch }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("fails to close launch when launch is still in Initialized state", async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + const newLaunch = result.launch; + const newMETA = result.tokenMint; + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META2", + tokenSymbol: "META2", + tokenUri: "https://example.com", + minimumRaiseAmount: new BN(100_000 * 10 ** 6), + secondsForLaunch: 60 * 60 * 24 * 4, + baseMint: newMETA, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: false, + }) + .rpc(); + + const callbacks = expectError( + "LaunchNotLive", + "Should have rejected closing an initialized (not started) launch", + ); + + await launchpadClient + .closeLaunchIx({ launch: newLaunch }) + .rpc() + .then(callbacks[0], callbacks[1]); + + const launchAccount = await launchpadClient.fetchLaunch(newLaunch); + assert.deepEqual(launchAccount.state, { initialized: {} }); + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index 015a6d1bb..3144f36a1 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -37,15 +37,11 @@ > Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 -- [NEXT] 3.7 Write `closeLaunch` tests (tests #16–20) - - Tests #16–20: all close_launch tests per spec - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 4: `set_funding_record_approval` > Reference: `launchpad_v8_spec.md` → instruction 4 -- [ ] 4.1 Implement `set_funding_record_approval` instruction (Rust) +- [NEXT] 4.1 Implement `set_funding_record_approval` instruction (Rust) - Create `src/instructions/set_funding_record_approval.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 1b48e0031c01ce78cb467c530110c7079c51d1da Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 17:52:04 +0200 Subject: [PATCH 051/100] set funding record approval ix --- .../v08_launchpad/src/instructions/mod.rs | 2 + .../set_funding_record_approval.rs | 81 +++++++++++++++++++ programs/v08_launchpad/src/lib.rs | 8 ++ sdk/src/v0.7/types/launchpad_v8.ts | 72 +++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 72 +++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 236 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/set_funding_record_approval.rs diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index bdd032df0..7ec66a1e3 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,9 +1,11 @@ pub mod close_launch; pub mod fund; pub mod initialize_launch; +pub mod set_funding_record_approval; pub mod start_launch; pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; +pub use set_funding_record_approval::*; pub use start_launch::*; diff --git a/programs/v08_launchpad/src/instructions/set_funding_record_approval.rs b/programs/v08_launchpad/src/instructions/set_funding_record_approval.rs new file mode 100644 index 000000000..768e027c9 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/set_funding_record_approval.rs @@ -0,0 +1,81 @@ +use anchor_lang::prelude::*; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, FundingRecordApprovalSetEvent}; +use crate::state::{FundingRecord, Launch, LaunchState}; + +#[event_cpi] +#[derive(Accounts)] +pub struct SetFundingRecordApproval<'info> { + #[account( + mut, + has_one = launch_authority, + )] + pub launch: Account<'info, Launch>, + + #[account( + mut, + has_one = launch, + )] + pub funding_record: Account<'info, FundingRecord>, + + pub launch_authority: Signer<'info>, +} + +impl SetFundingRecordApproval<'_> { + pub fn validate(&self, approved_amount: u64) -> Result<()> { + let clock = Clock::get()?; + + require!( + self.launch.state == LaunchState::Closed, + LaunchpadError::InvalidLaunchState + ); + + let two_days_after_close = self + .launch + .unix_timestamp_closed + .unwrap() + .saturating_add(60 * 60 * 24 * 2); + + require_gt!( + two_days_after_close, + clock.unix_timestamp, + LaunchpadError::FundingRecordApprovalPeriodOver + ); + + require_gte!( + self.funding_record.committed_amount, + approved_amount, + LaunchpadError::InsufficientFunds + ); + + Ok(()) + } + + pub fn handle(ctx: Context, approved_amount: u64) -> Result<()> { + let funding_record = &mut ctx.accounts.funding_record; + let launch = &mut ctx.accounts.launch; + + if approved_amount >= funding_record.approved_amount { + launch.total_approved_amount += approved_amount - funding_record.approved_amount; + } else { + launch.total_approved_amount -= funding_record.approved_amount - approved_amount; + } + + launch.seq_num += 1; + + funding_record.approved_amount = approved_amount; + + let clock = Clock::get()?; + emit_cpi!(FundingRecordApprovalSetEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + funding_record: funding_record.key(), + funder: funding_record.funder, + approved_amount, + total_approved: launch.total_approved_amount, + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 8db74b300..72a4fee8a 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -90,4 +90,12 @@ pub mod launchpad_v8 { pub fn close_launch(ctx: Context) -> Result<()> { CloseLaunch::handle(ctx) } + + #[access_control(ctx.accounts.validate(approved_amount))] + pub fn set_funding_record_approval( + ctx: Context, + approved_amount: u64, + ) -> Result<()> { + SetFundingRecordApproval::handle(ctx, approved_amount) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 93fc5169b..f4e04fbfc 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -237,6 +237,42 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "setFundingRecordApproval"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "approvedAmount"; + type: "u64"; + }, + ]; + }, ]; accounts: [ { @@ -1512,6 +1548,42 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "setFundingRecordApproval", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "approvedAmount", + type: "u64", + }, + ], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 93fc5169b..f4e04fbfc 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -237,6 +237,42 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "setFundingRecordApproval"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "approvedAmount"; + type: "u64"; + }, + ]; + }, ]; accounts: [ { @@ -1512,6 +1548,42 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "setFundingRecordApproval", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "approvedAmount", + type: "u64", + }, + ], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 3144f36a1..2d77a164e 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -41,12 +41,7 @@ > Reference: `launchpad_v8_spec.md` → instruction 4 -- [NEXT] 4.1 Implement `set_funding_record_approval` instruction (Rust) - - Create `src/instructions/set_funding_record_approval.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 4.2 Add `setFundingRecordApprovalIx` to SDK2 client +- [NEXT] 4.2 Add `setFundingRecordApprovalIx` to SDK2 client - Port from v7 SDK2 client - Verify: `cd sdk2 && npx tsc --noEmit` From 723031cfcc78ebc5d1b1e5b87f6879e4b31d4cd5 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 17:56:07 +0200 Subject: [PATCH 052/100] set funding record approval sdk --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 26 ++++++++++++++++++++++ vibes/tasks.md | 6 +---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index cec22490a..af074a22c 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -358,4 +358,30 @@ export class LaunchpadClient { launch, }); } + + setFundingRecordApprovalIx({ + launch, + funder, + launchAuthority = this.provider.publicKey, + approvedAmount, + }: { + launch: PublicKey; + funder: PublicKey; + launchAuthority?: PublicKey; + approvedAmount: BN; + }) { + let fundingRecord = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + )[0]; + + return this.launchpad.methods + .setFundingRecordApproval(approvedAmount) + .accounts({ + launch, + fundingRecord, + launchAuthority, + }); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index 2d77a164e..bf67e2d8e 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -41,11 +41,7 @@ > Reference: `launchpad_v8_spec.md` → instruction 4 -- [NEXT] 4.2 Add `setFundingRecordApprovalIx` to SDK2 client - - Port from v7 SDK2 client - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 4.3 Write `setFundingRecordApproval` tests (tests #21–26) +- [NEXT] 4.3 Write `setFundingRecordApproval` tests (tests #21–26) - Tests #21–26: all set_funding_record_approval tests per spec - Verify: `anchor test --skip-build` (with `.only`) From 8bb156b0186ac084973f06c0392c9a65c0e51937 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 18:16:48 +0200 Subject: [PATCH 053/100] set funding record tests --- tests/launchpad_v8/main.test.ts | 2 + .../unit/setFundingRecordApproval.test.ts | 317 ++++++++++++++++++ vibes/tasks.md | 10 +- 3 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 tests/launchpad_v8/unit/setFundingRecordApproval.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index 51eee8ddd..7b47a4c8e 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -9,6 +9,7 @@ import initializeLaunch from "./unit/initializeLaunch.test.js"; import startLaunch from "./unit/startLaunch.test.js"; import fund from "./unit/fund.test.js"; import closeLaunch from "./unit/closeLaunch.test.js"; +import setFundingRecordApproval from "./unit/setFundingRecordApproval.test.js"; export default function suite() { before(async function () { @@ -72,4 +73,5 @@ export default function suite() { describe("#start_launch", startLaunch); describe("#fund", fund); describe("#close_launch", closeLaunch); + describe("#set_funding_record_approval", setFundingRecordApproval); } diff --git a/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts b/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts new file mode 100644 index 000000000..851396a3e --- /dev/null +++ b/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts @@ -0,0 +1,317 @@ +import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; +import { assert } from "chai"; +import { + LaunchpadClient, + getFundingRecordAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { BN } from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { expectError } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + const funder1 = Keypair.generate(); + const funder2 = Keypair.generate(); + const funder3 = Keypair.generate(); + const funder4 = Keypair.generate(); + + const funder1Amount = new BN(30_000 * 10 ** 6); // 30,000 USDC + const funder2Amount = new BN(40_000 * 10 ** 6); // 40,000 USDC + const funder3Amount = new BN(20_000 * 10 ** 6); // 20,000 USDC + const funder4Amount = new BN(50_000 * 10 ** 6); // 50,000 USDC + + async function fundLaunch() { + await launchpadClient + .fundIx({ launch, amount: funder1Amount, funder: funder1.publicKey }) + .signers([funder1]) + .rpc(); + await launchpadClient + .fundIx({ launch, amount: funder2Amount, funder: funder2.publicKey }) + .signers([funder2]) + .rpc(); + await launchpadClient + .fundIx({ launch, amount: funder3Amount, funder: funder3.publicKey }) + .signers([funder3]) + .rpc(); + await launchpadClient + .fundIx({ launch, amount: funder4Amount, funder: funder4.publicKey }) + .signers([funder4]) + .rpc(); + } + + before(async function () { + launchpadClient = this.launchpad_v8; + + await this.createTokenAccount(MAINNET_USDC, funder1.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder2.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder3.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder4.publicKey); + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Mint USDC to funders (10x for oversubscription cases) + await this.transfer( + MAINNET_USDC, + this.payer, + funder1.publicKey, + funder1Amount.toNumber() * 10, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder2.publicKey, + funder2Amount.toNumber() * 10, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder3.publicKey, + funder3Amount.toNumber() * 10, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder4.publicKey, + funder4Amount.toNumber() * 10, + ); + }); + + it("can set funding record approval for full, partial, and zero amounts", async function () { + await fundLaunch(); + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Set funder1's approval to full amount + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundingRecord1 = launchpadClient.getFundingRecordAddress({ + launch, + funder: funder1.publicKey, + }); + + let fundingRecord1Account = + await launchpadClient.getFundingRecord(fundingRecord1); + assert.equal( + fundingRecord1Account.approvedAmount.toString(), + funder1Amount.toString(), + ); + + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalApprovedAmount.toString(), + funder1Amount.toString(), + ); + + // Update to partial amount (half) + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount.div(new BN(2)), + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + fundingRecord1Account = + await launchpadClient.getFundingRecord(fundingRecord1); + assert.equal( + fundingRecord1Account.approvedAmount.toString(), + funder1Amount.div(new BN(2)).toString(), + ); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalApprovedAmount.toString(), + funder1Amount.div(new BN(2)).toString(), + ); + + // Update to zero + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: new BN(0), + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + fundingRecord1Account = + await launchpadClient.getFundingRecord(fundingRecord1); + assert.equal(fundingRecord1Account.approvedAmount.toString(), "0"); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal(launchAccount.totalApprovedAmount.toString(), "0"); + }); + + it("correctly updates the launch account total approved amount", async function () { + await fundLaunch(); + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Approve funder1 + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundingRecord1 = launchpadClient.getFundingRecordAddress({ + launch, + funder: funder1.publicKey, + }); + const fundingRecord1Account = + await launchpadClient.getFundingRecord(fundingRecord1); + assert.equal( + fundingRecord1Account.approvedAmount.toString(), + funder1Amount.toString(), + ); + + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalApprovedAmount.toString(), + funder1Amount.toString(), + ); + + // Approve funder2 + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder2Amount, + funder: funder2.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundingRecord2 = launchpadClient.getFundingRecordAddress({ + launch, + funder: funder2.publicKey, + }); + const fundingRecord2Account = + await launchpadClient.getFundingRecord(fundingRecord2); + assert.equal( + fundingRecord2Account.approvedAmount.toString(), + funder2Amount.toString(), + ); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalApprovedAmount.toString(), + funder1Amount.add(funder2Amount).toString(), + ); + }); + + it("can't set funding record approval before the launch period ends", async function () { + await fundLaunch(); + + const callbacks = expectError("InvalidLaunchState", "Invalid launch state"); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + it("can't set funding record approval after the funding record approval period ends (2 days after launch is closed)", async function () { + await fundLaunch(); + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Advance exactly 2 days (the boundary) + await this.advanceBySeconds(60 * 60 * 24 * 2); + + const callbacks = expectError( + "FundingRecordApprovalPeriodOver", + "Funding record approval period is over", + ); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); + + // TODO: needs settle_launch to reach Complete state + it("can't set funding record approval after the launch is completed"); + + it("can't set funding record approval to an amount greater than the committed amount", async function () { + await fundLaunch(); + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + const callbacks = expectError( + "InsufficientFunds", + "Failed to set funding record approval to an amount greater than the committed amount", + ); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount.add(new BN(1)), + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index bf67e2d8e..8a9b583c6 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -41,15 +41,11 @@ > Reference: `launchpad_v8_spec.md` → instruction 4 -- [NEXT] 4.3 Write `setFundingRecordApproval` tests (tests #21–26) - - Tests #21–26: all set_funding_record_approval tests per spec - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 5: `settle_launch` > Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" -- [ ] 5.1 Implement `settle_launch` instruction (Rust) +- [NEXT] 5.1 Implement `settle_launch` instruction (Rust) - Create `src/instructions/settle_launch.rs` with `SettleLaunch` accounts struct, `validate()`, and `handle()` - Port from v7 `complete_launch` with key changes: mint_governor::mint_tokens CPI replaces token::set_authority, no mint authority transfer - Include StaticCompleteLaunchAccounts and MeteoraAccounts nested structs @@ -70,6 +66,10 @@ - Test #33: fails when launch is in refunding state - Verify: `anchor test --skip-build` (with `.only`) +- [ ] 5.4 Finish `setFundingRecordApproval` test #25 + - Fill in stub: "can't set funding record approval after the launch is completed" (needs Complete state via settle_launch) + - Verify: `anchor test --skip-build` (with `.only`) + ### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 From 22a197eca1039d585b3084bbe00288c285351b63 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 18:48:56 +0200 Subject: [PATCH 054/100] settle launch ix --- .../v08_launchpad/src/instructions/mod.rs | 2 + .../src/instructions/settle_launch.rs | 774 ++++++++++++++++++ programs/v08_launchpad/src/lib.rs | 5 + sdk/src/v0.7/types/launchpad_v8.ts | 554 +++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 554 +++++++++++++ vibes/tasks.md | 9 +- 6 files changed, 1890 insertions(+), 8 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/settle_launch.rs diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 7ec66a1e3..dcd34f74f 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -2,10 +2,12 @@ pub mod close_launch; pub mod fund; pub mod initialize_launch; pub mod set_funding_record_approval; +pub mod settle_launch; pub mod start_launch; pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; pub use set_funding_record_approval::*; +pub use settle_launch::*; pub use start_launch::*; diff --git a/programs/v08_launchpad/src/instructions/settle_launch.rs b/programs/v08_launchpad/src/instructions/settle_launch.rs new file mode 100644 index 000000000..0d8ba17e5 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/settle_launch.rs @@ -0,0 +1,774 @@ +use anchor_lang::{prelude::*, system_program}; +use anchor_spl::associated_token::AssociatedToken; +use anchor_spl::metadata::UpdateMetadataAccountsV2; +use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer}; +use anchor_spl::token_2022::Token2022; +use anchor_spl::token_interface; +use bid_wall::program::BidWall; +use damm_v2_cpi::constants::seeds::{ + POOL_AUTHORITY_PREFIX, POOL_PREFIX, POSITION_NFT_ACCOUNT_PREFIX, POSITION_PREFIX, + TOKEN_VAULT_PREFIX, +}; +use damm_v2_cpi::constants::MAX_SQRT_PRICE; +use damm_v2_cpi::BaseFeeParameters; + +use mint_governor::{ + cpi::{accounts::MintTokens, mint_tokens}, + program::MintGovernor as MintGovernorProgram, + MintTokensArgs, +}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchCloseEvent, LaunchSettledEvent}; +use crate::state::{Launch, LaunchState}; +use crate::{ + metadao_multisig_vault, PRICE_SCALE, PROPOSAL_MIN_STAKE_TOKENS, TOKENS_TO_DAMM_V2_LIQUIDITY, + TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED, TOKENS_TO_FUTARCHY_LIQUIDITY, TOKENS_TO_PARTICIPANTS, + TOKEN_SCALE, +}; +use anchor_spl::metadata::{ + mpl_token_metadata::ID as MPL_TOKEN_METADATA_PROGRAM_ID, update_metadata_accounts_v2, Metadata, +}; + +use futarchy::program::Futarchy; +use futarchy::{InitialSpendingLimit, InitializeDaoParams, ProvideLiquidityParams}; + +use damm_v2_cpi::program::DammV2Cpi; + +/// Static accounts for settling a launch, used to reduce code duplication +/// and conserve stack space. +#[derive(Accounts)] +pub struct StaticCompleteLaunchAccounts<'info> { + pub futarchy_program: Program<'info, Futarchy>, + pub token_metadata_program: Program<'info, Metadata>, + /// CHECK: checked by futarchy program + pub futarchy_event_authority: UncheckedAccount<'info>, + pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, + /// CHECK: checked by squads multisig program + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_PROGRAM_CONFIG], bump, seeds::program = squads_program)] + pub squads_program_config: UncheckedAccount<'info>, + /// CHECK: checked by squads multisig program + #[account(mut)] + pub squads_program_config_treasury: UncheckedAccount<'info>, + pub bid_wall_program: Program<'info, BidWall>, + /// CHECK: checked by bid wall program + pub bid_wall_event_authority: UncheckedAccount<'info>, +} + +pub fn max_key(left: &Pubkey, right: &Pubkey) -> [u8; 32] { + std::cmp::max(left, right).to_bytes() +} + +pub fn min_key(left: &Pubkey, right: &Pubkey) -> [u8; 32] { + std::cmp::min(left, right).to_bytes() +} + +#[derive(Accounts)] +pub struct MeteoraAccounts<'info> { + pub damm_v2_program: Program<'info, DammV2Cpi>, + /// CHECK: checked by damm v2 program, there should only be one config that works for us + pub config: UncheckedAccount<'info>, + + pub token_2022_program: Program<'info, Token2022>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [POSITION_NFT_ACCOUNT_PREFIX.as_ref(), position_nft_mint.key().as_ref()], bump, seeds::program = damm_v2_program)] + pub position_nft_account: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [ + POOL_PREFIX.as_ref(), + config.key().as_ref(), + &max_key(&base_mint.key(), "e_mint.key()), + &min_key(&base_mint.key(), "e_mint.key()), + ], bump, seeds::program = damm_v2_program)] + pub pool: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [POSITION_PREFIX.as_ref(), position_nft_mint.key().as_ref()], bump, seeds::program = damm_v2_program)] + pub position: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [b"position_nft_mint", base_mint.key().as_ref()], bump)] + pub position_nft_mint: UncheckedAccount<'info>, + + /// CHECK: checked by root struct + pub base_mint: UncheckedAccount<'info>, + /// CHECK: checked by root struct + pub quote_mint: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [ + TOKEN_VAULT_PREFIX.as_ref(), + base_mint.key().as_ref(), + pool.key().as_ref(), + ], bump, seeds::program = damm_v2_program)] + pub token_a_vault: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(mut, seeds = [ + TOKEN_VAULT_PREFIX.as_ref(), + quote_mint.key().as_ref(), + pool.key().as_ref(), + ], bump, seeds::program = damm_v2_program)] + pub token_b_vault: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(seeds = [b"damm_pool_creator_authority"], bump)] + pub pool_creator_authority: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + #[account(seeds = [POOL_AUTHORITY_PREFIX.as_ref()], bump, seeds::program = damm_v2_program)] + pub pool_authority: UncheckedAccount<'info>, + + /// CHECK: checked by damm v2 program + pub damm_v2_event_authority: UncheckedAccount<'info>, +} + +#[derive(Accounts)] +pub struct MintGovernorAccounts<'info> { + #[account(mut)] + pub mint_governor: Box>, + + #[account( + mut, + has_one = mint_governor, + )] + pub mint_authority: Box>, + + pub mint_governor_program: Program<'info, MintGovernorProgram>, + + /// CHECK: checked by mint_governor program + pub mint_governor_event_authority: UncheckedAccount<'info>, +} + +#[event_cpi] +#[derive(Accounts)] +pub struct SettleLaunch<'info> { + #[account( + mut, + has_one = launch_quote_vault, + has_one = launch_base_vault, + has_one = launch_signer, + has_one = base_mint, + has_one = quote_mint, + )] + pub launch: Box>, + + pub launch_authority: Option>, + + /// CHECK: Token metadata + #[account( + mut, + seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), base_mint.key().as_ref()], + seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, + bump + )] + pub token_metadata: UncheckedAccount<'info>, + + #[account(mut)] + pub payer: Signer<'info>, + + /// CHECK: just a signer + #[account(mut)] + pub launch_signer: UncheckedAccount<'info>, + + #[account( + mut, + associated_token::mint = quote_mint, + associated_token::authority = launch_signer, + )] + pub launch_quote_vault: Box>, + + #[account( + mut, + associated_token::mint = base_mint, + associated_token::authority = launch_signer, + )] + pub launch_base_vault: Box>, + + #[account( + init_if_needed, + payer = payer, + associated_token::mint = quote_mint, + associated_token::authority = squads_multisig_vault, + )] + pub treasury_quote_account: Box>, + + #[account(mut, address = meteora_accounts.base_mint.key())] + pub base_mint: Box>, + + #[account(address = meteora_accounts.quote_mint.key())] + pub quote_mint: Box>, + + /// CHECK: init by futarchy program + #[account(mut, seeds = [b"amm_position", dao.key().as_ref(), squads_multisig_vault.key().as_ref()], bump, seeds::program = static_accounts.futarchy_program)] + pub dao_owned_lp_position: UncheckedAccount<'info>, + + /// CHECK: checked by futarchy program + #[account(mut)] + pub futarchy_amm_base_vault: UncheckedAccount<'info>, + + /// CHECK: checked by futarchy program + #[account(mut)] + pub futarchy_amm_quote_vault: UncheckedAccount<'info>, + + /// CHECK: this is the DAO account, init by futarchy program + #[account(mut)] + pub dao: UncheckedAccount<'info>, + + /// CHECK: checked by futarchy program + #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = static_accounts.squads_program)] + pub squads_multisig: UncheckedAccount<'info>, + /// CHECK: just a signer + #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], bump, seeds::program = static_accounts.squads_program)] + pub squads_multisig_vault: UncheckedAccount<'info>, + /// CHECK: initialized by squads + #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = static_accounts.squads_program)] + pub spending_limit: UncheckedAccount<'info>, + + /// CHECK: checked by bid wall program + #[account(mut)] + pub bid_wall: UncheckedAccount<'info>, + /// CHECK: checked by bid wall program + #[account(mut)] + pub bid_wall_quote_token_account: UncheckedAccount<'info>, + + /// CHECK: The fee recipient of bid wall fees, a fixed address + #[account(address = metadao_multisig_vault::id())] + pub fee_recipient: AccountInfo<'info>, + + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub static_accounts: StaticCompleteLaunchAccounts<'info>, + pub meteora_accounts: MeteoraAccounts<'info>, + pub mint_governor_accounts: MintGovernorAccounts<'info>, +} + +impl SettleLaunch<'_> { + pub fn validate(&self) -> Result<()> { + let clock = Clock::get()?; + + require!( + self.launch.state == LaunchState::Closed, + LaunchpadError::InvalidLaunchState + ); + + // The mint_governor is in a nested struct, so we can't use has_one on the launch account. + // Verify it matches the one stored on the launch. + require_keys_eq!( + self.mint_governor_accounts.mint_governor.key(), + self.launch.mint_governor, + LaunchpadError::InvalidMintAuthority + ); + + // The mint_authority's authorized_minter must be the launch_signer so it can + // sign the mint_tokens CPI via PDA seeds. + require_keys_eq!( + self.mint_governor_accounts.mint_authority.authorized_minter, + self.launch_signer.key(), + LaunchpadError::InvalidMintAuthority + ); + + // if the launch was closed within 2 days, the launch authority must be the one + // to settle the launch + let two_days_after_close = self.launch.unix_timestamp_closed.unwrap() + 60 * 60 * 24 * 2; + if two_days_after_close > clock.unix_timestamp { + if self.launch_authority.is_none() { + msg!("Launch authority must settle launch until unix timestamp {}. Current time is {}.", two_days_after_close, clock.unix_timestamp); + return Err(LaunchpadError::LaunchAuthorityNotSet.into()); + } + } + + if self.launch_authority.is_some() { + require!( + self.launch_authority.as_ref().unwrap().is_signer, + LaunchpadError::LaunchAuthorityNotSet + ); + + require_keys_eq!( + self.launch_authority.as_ref().unwrap().key(), + self.launch.launch_authority, + LaunchpadError::LaunchAuthorityNotSet + ); + + // If the launch authority is settling the launch, the total approved amount must be + // greater than or equal to the minimum raise amount + require_gte!( + self.launch.total_approved_amount, + self.launch.minimum_raise_amount, + LaunchpadError::TotalApprovedAmountTooLow + ); + } + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch_total_approved_amount = ctx.accounts.launch.total_approved_amount; + + let clock = Clock::get()?; + + // If the launch authority doesn't approve enough funding, the launch will go into refunding state + if launch_total_approved_amount < ctx.accounts.launch.minimum_raise_amount { + let launch = &mut ctx.accounts.launch; + + launch.state = LaunchState::Refunding; + launch.seq_num += 1; + + emit_cpi!(LaunchCloseEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + new_state: launch.state, + }); + + return Ok(()); + }; + + let launch_key = ctx.accounts.launch.key(); + let launch_signer_seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[ctx.accounts.launch.launch_signer_pda_bump], + ]; + let launch_signer = &[&launch_signer_seeds[..]]; + + // Mint all needed tokens via MintGovernor + let tokens_to_mint = TOKENS_TO_PARTICIPANTS + + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + + ctx.accounts.launch.additional_tokens_amount; + + ctx.accounts.mint_tokens(tokens_to_mint, launch_signer)?; + + let price_1e12 = ((launch_total_approved_amount as u128) * PRICE_SCALE) + / (TOKENS_TO_PARTICIPANTS as u128); + + // We first determine how much USDC to allocate to the LP pool, with the rest going to the DAO + let usdc_to_lp = launch_total_approved_amount.saturating_div(5); + let usdc_to_dao = launch_total_approved_amount.saturating_sub(usdc_to_lp); + + // We only activate the bid wall if the launch has one configured. + // Otherwise, we allocate the entire amount after LP allocation to the DAO treasury. + let (usdc_to_dao_treasury, usdc_to_bid_wall) = if ctx.accounts.launch.has_bid_wall { + let usdc_to_dao_treasury = usdc_to_dao.min(ctx.accounts.launch.minimum_raise_amount); + let usdc_to_bid_wall = usdc_to_dao.saturating_sub(usdc_to_dao_treasury); + (usdc_to_dao_treasury, usdc_to_bid_wall) + } else { + (usdc_to_dao, 0) + }; + + ctx.accounts.initialize_dao(launch_signer, price_1e12)?; + + if usdc_to_bid_wall > 0 { + ctx.accounts + .initialize_bid_wall(usdc_to_bid_wall, usdc_to_lp, launch_signer)?; + } + + ctx.accounts.provide_futarchy_amm_liquidity( + usdc_to_lp, + TOKENS_TO_FUTARCHY_LIQUIDITY, + launch_signer, + )?; + + ctx.accounts.provide_single_sided_meteora_liquidity( + launch_total_approved_amount, + ctx.bumps.meteora_accounts.position_nft_mint, + ctx.bumps.meteora_accounts.pool_creator_authority, + launch_signer_seeds, + )?; + + ctx.accounts + .send_usdc_to_dao(usdc_to_dao_treasury, launch_signer)?; + + ctx.accounts + .transfer_metadata_authority_to_dao(launch_signer)?; + + let launch = &mut ctx.accounts.launch; + + launch.dao = Some(ctx.accounts.dao.key()); + launch.dao_vault = Some(ctx.accounts.squads_multisig_vault.key()); + launch.state = LaunchState::Complete; + launch.unix_timestamp_completed = Some(clock.unix_timestamp); + launch.seq_num += 1; + + emit_cpi!(LaunchSettledEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + final_state: launch.state, + total_committed: launch.total_committed_amount, + total_approved_amount: launch.total_approved_amount, + dao: launch.dao, + dao_treasury: launch.dao_vault, + bid_wall: if usdc_to_bid_wall > 0 { + Some(ctx.accounts.bid_wall.key()) + } else { + None + }, + bid_wall_amount: usdc_to_bid_wall, + mint_governor: ctx.accounts.mint_governor_accounts.mint_governor.key(), + tokens_minted: tokens_to_mint, + }); + + let refundable_usdc = launch.total_committed_amount - launch_total_approved_amount; + + ctx.accounts.verify_position_nft()?; + ctx.accounts.verify_vaults(refundable_usdc)?; + + Ok(()) + } + + fn mint_tokens(&self, amount: u64, launch_signer: &[&[&[u8]]]) -> Result<()> { + mint_tokens( + CpiContext::new_with_signer( + self.mint_governor_accounts + .mint_governor_program + .to_account_info(), + MintTokens { + mint_governor: self.mint_governor_accounts.mint_governor.to_account_info(), + mint_authority: self.mint_governor_accounts.mint_authority.to_account_info(), + mint: self.base_mint.to_account_info(), + destination_ata: self.launch_base_vault.to_account_info(), + authorized_minter: self.launch_signer.to_account_info(), + token_program: self.token_program.to_account_info(), + event_authority: self + .mint_governor_accounts + .mint_governor_event_authority + .to_account_info(), + program: self + .mint_governor_accounts + .mint_governor_program + .to_account_info(), + }, + launch_signer, + ), + MintTokensArgs { amount }, + ) + } + + #[inline(never)] + fn initialize_dao(&self, launch_signer: &[&[&[u8]]], launch_price_1e12: u128) -> Result<()> { + futarchy::cpi::initialize_dao( + CpiContext::new_with_signer( + self.static_accounts.futarchy_program.to_account_info(), + futarchy::cpi::accounts::InitializeDao { + dao: self.dao.to_account_info(), + dao_creator: self.launch_signer.to_account_info(), + payer: self.payer.to_account_info(), + system_program: self.system_program.to_account_info(), + base_mint: self.base_mint.to_account_info(), + quote_mint: self.quote_mint.to_account_info(), + event_authority: self + .static_accounts + .futarchy_event_authority + .to_account_info(), + program: self.static_accounts.futarchy_program.to_account_info(), + squads_multisig: self.squads_multisig.to_account_info(), + squads_multisig_vault: self.squads_multisig_vault.to_account_info(), + squads_program: self.static_accounts.squads_program.to_account_info(), + squads_program_config: self + .static_accounts + .squads_program_config + .to_account_info(), + squads_program_config_treasury: self + .static_accounts + .squads_program_config_treasury + .to_account_info(), + spending_limit: self.spending_limit.to_account_info(), + futarchy_amm_base_vault: self.futarchy_amm_base_vault.to_account_info(), + futarchy_amm_quote_vault: self.futarchy_amm_quote_vault.to_account_info(), + associated_token_program: self.associated_token_program.to_account_info(), + token_program: self.token_program.to_account_info(), + }, + launch_signer, + ), + InitializeDaoParams { + twap_initial_observation: launch_price_1e12, + twap_max_observation_change_per_update: launch_price_1e12 / 20, + min_quote_futarchic_liquidity: 1, + min_base_futarchic_liquidity: 1, + pass_threshold_bps: 300, + base_to_stake: PROPOSAL_MIN_STAKE_TOKENS, + seconds_per_proposal: 3 * 24 * 60 * 60, + twap_start_delay_seconds: 24 * 60 * 60, + nonce: 0, + initial_spending_limit: Some(InitialSpendingLimit { + amount_per_month: self.launch.monthly_spending_limit_amount, + members: self.launch.monthly_spending_limit_members.clone(), + }), + team_sponsored_pass_threshold_bps: -300, + team_address: self.launch.team_address, + }, + ) + } + + fn initialize_bid_wall( + &self, + usdc_to_bid_wall: u64, + usdc_to_lp: u64, + launch_signer: &[&[&[u8]]], + ) -> Result<()> { + bid_wall::cpi::initialize_bid_wall( + CpiContext::new_with_signer( + self.static_accounts.bid_wall_program.to_account_info(), + bid_wall::cpi::accounts::InitializeBidWall { + bid_wall: self.bid_wall.to_account_info(), + payer: self.payer.to_account_info(), + fee_recipient: self.fee_recipient.to_account_info(), + creator: self.launch_signer.to_account_info(), + authority: self.squads_multisig_vault.to_account_info(), + bid_wall_quote_token_account: self + .bid_wall_quote_token_account + .to_account_info(), + creator_quote_token_account: self.launch_quote_vault.to_account_info(), + dao_treasury: self.squads_multisig_vault.to_account_info(), + base_mint: self.base_mint.to_account_info(), + quote_mint: self.quote_mint.to_account_info(), + token_program: self.token_program.to_account_info(), + associated_token_program: self.associated_token_program.to_account_info(), + system_program: self.system_program.to_account_info(), + event_authority: self + .static_accounts + .bid_wall_event_authority + .to_account_info(), + program: self.static_accounts.bid_wall_program.to_account_info(), + }, + launch_signer, + ), + bid_wall::instructions::InitializeBidWallArgs { + amount: usdc_to_bid_wall, + nonce: 0, + initial_amm_quote_reserves: usdc_to_lp, + duration_seconds: 3 * 30 * 24 * 60 * 60, // 3 months + }, + ) + } + + #[inline(never)] + fn provide_futarchy_amm_liquidity( + &self, + usdc_to_lp: u64, + tokens_to_lp: u64, + launch_signer: &[&[&[u8]]], + ) -> Result<()> { + futarchy::cpi::provide_liquidity( + CpiContext::new_with_signer( + self.static_accounts.futarchy_program.to_account_info(), + futarchy::cpi::accounts::ProvideLiquidity { + dao: self.dao.to_account_info(), + liquidity_provider: self.launch_signer.to_account_info(), + liquidity_provider_base_account: self.launch_base_vault.to_account_info(), + liquidity_provider_quote_account: self.launch_quote_vault.to_account_info(), + payer: self.payer.to_account_info(), + system_program: self.system_program.to_account_info(), + amm_base_vault: self.futarchy_amm_base_vault.to_account_info(), + amm_quote_vault: self.futarchy_amm_quote_vault.to_account_info(), + amm_position: self.dao_owned_lp_position.to_account_info(), + token_program: self.token_program.to_account_info(), + program: self.static_accounts.futarchy_program.to_account_info(), + event_authority: self + .static_accounts + .futarchy_event_authority + .to_account_info(), + }, + launch_signer, + ), + ProvideLiquidityParams { + max_base_amount: tokens_to_lp, + quote_amount: usdc_to_lp, + min_liquidity: 0, + position_authority: self.squads_multisig_vault.key(), + }, + ) + } + + fn provide_single_sided_meteora_liquidity( + &self, + final_raise_amount: u64, + position_nft_mint_bump: u8, + pool_creator_authority_bump: u8, + launch_signer_seeds: &[&[u8]], + ) -> Result<()> { + system_program::transfer( + CpiContext::new( + self.system_program.to_account_info(), + system_program::Transfer { + from: self.payer.to_account_info(), + to: self.launch_signer.to_account_info(), + }, + ), + 5e7 as u64, + )?; + + let base_mint_key = self.base_mint.key(); + let position_nft_mint_signer_seeds = &[ + b"position_nft_mint".as_ref(), + base_mint_key.as_ref(), + &[position_nft_mint_bump], + ]; + + let pool_creator_authority_signer_seeds = &[ + b"damm_pool_creator_authority".as_ref(), + &[pool_creator_authority_bump], + ]; + + let pool_init_signer = &[ + &launch_signer_seeds[..], + &position_nft_mint_signer_seeds[..], + &pool_creator_authority_signer_seeds[..], + ]; + + require_eq!( + self.base_mint.decimals, + 6, + LaunchpadError::InvariantViolated + ); + require_eq!( + self.quote_mint.decimals, + 6, + LaunchpadError::InvariantViolated + ); + + let float_price = final_raise_amount as f64 / TOKENS_TO_PARTICIPANTS as f64; + let sqrt_price = (float_price.sqrt() * 2_f64.powf(64.0)) as u128; + + let liquidity = ((MAX_SQRT_PRICE * TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED as u128) + / (MAX_SQRT_PRICE - sqrt_price)) + * TOKEN_SCALE as u128 + * sqrt_price; + + damm_v2_cpi::cpi::initialize_pool_with_dynamic_config( + CpiContext::new_with_signer( + self.meteora_accounts.damm_v2_program.to_account_info(), + damm_v2_cpi::cpi::accounts::InitializePoolWithDynamicConfigCtx { + creator: self.squads_multisig_vault.to_account_info(), + position_nft_mint: self.meteora_accounts.position_nft_mint.to_account_info(), + position_nft_account: self + .meteora_accounts + .position_nft_account + .to_account_info(), + payer: self.launch_signer.to_account_info(), + pool_creator_authority: self + .meteora_accounts + .pool_creator_authority + .to_account_info(), + config: self.meteora_accounts.config.to_account_info(), + pool_authority: self.meteora_accounts.pool_authority.to_account_info(), + token_a_vault: self.meteora_accounts.token_a_vault.to_account_info(), + token_b_vault: self.meteora_accounts.token_b_vault.to_account_info(), + payer_token_a: self.launch_base_vault.to_account_info(), + payer_token_b: self.launch_quote_vault.to_account_info(), + token_a_program: self.token_program.to_account_info(), + token_b_program: self.token_program.to_account_info(), + token_2022_program: self.meteora_accounts.token_2022_program.to_account_info(), + system_program: self.system_program.to_account_info(), + pool: self.meteora_accounts.pool.to_account_info(), + position: self.meteora_accounts.position.to_account_info(), + token_a_mint: self.base_mint.to_account_info(), + token_b_mint: self.quote_mint.to_account_info(), + event_authority: self + .meteora_accounts + .damm_v2_event_authority + .to_account_info(), + program: self.meteora_accounts.damm_v2_program.to_account_info(), + }, + pool_init_signer, + ), + damm_v2_cpi::InitializeCustomizablePoolParameters { + pool_fees: damm_v2_cpi::PoolFeeParameters { + base_fee: BaseFeeParameters { + cliff_fee_numerator: 5000000, + number_of_period: 0, + period_frequency: 0, + reduction_factor: 0, + fee_scheduler_mode: 0, + }, + padding: [0; 3], + dynamic_fee: None, + }, + activation_point: None, + activation_type: 0, + collect_fee_mode: 0, + sqrt_min_price: sqrt_price, + sqrt_max_price: MAX_SQRT_PRICE, + has_alpha_vault: false, + liquidity, + sqrt_price, + }, + ) + } + + fn transfer_metadata_authority_to_dao(&self, launch_signer: &[&[&[u8]]]) -> Result<()> { + update_metadata_accounts_v2( + CpiContext::new_with_signer( + self.static_accounts + .token_metadata_program + .to_account_info(), + UpdateMetadataAccountsV2 { + metadata: self.token_metadata.to_account_info(), + update_authority: self.launch_signer.to_account_info(), + }, + launch_signer, + ), + Some(self.squads_multisig_vault.key()), + None, + None, + None, + ) + } + + fn send_usdc_to_dao(&self, usdc_to_send: u64, launch_signer: &[&[&[u8]]]) -> Result<()> { + token::transfer( + CpiContext::new_with_signer( + self.token_program.to_account_info(), + Transfer { + from: self.launch_quote_vault.to_account_info(), + to: self.treasury_quote_account.to_account_info(), + authority: self.launch_signer.to_account_info(), + }, + launch_signer, + ), + usdc_to_send, + ) + } + + #[inline(never)] + fn verify_vaults(&mut self, refundable_usdc: u64) -> Result<()> { + self.launch_base_vault.reload()?; + self.launch_quote_vault.reload()?; + + require_gte!( + self.launch_base_vault.amount, + TOKENS_TO_PARTICIPANTS + + self.launch.additional_tokens_amount + + self.launch.performance_package_token_amount, + LaunchpadError::InvariantViolated + ); + require_gte!( + self.launch_quote_vault.amount, + refundable_usdc, + LaunchpadError::InvariantViolated + ); + + Ok(()) + } + + #[inline(never)] + fn verify_position_nft(&self) -> Result<()> { + let position_nft_account = token_interface::TokenAccount::try_deserialize( + &mut &self.meteora_accounts.position_nft_account.data.borrow()[..], + )?; + require_eq!( + position_nft_account.amount, + 1, + LaunchpadError::InvariantViolated + ); + require_keys_eq!( + position_nft_account.owner, + self.squads_multisig_vault.key(), + LaunchpadError::InvariantViolated + ); + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 72a4fee8a..7e9c908c1 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -98,4 +98,9 @@ pub mod launchpad_v8 { ) -> Result<()> { SetFundingRecordApproval::handle(ctx, approved_amount) } + + #[access_control(ctx.accounts.validate())] + pub fn settle_launch(ctx: Context) -> Result<()> { + SettleLaunch::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index f4e04fbfc..97bec21a3 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -273,6 +273,283 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "settleLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + isOptional: true; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "daoOwnedLpPosition"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "futarchyProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "futarchyEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallProgram"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "meteoraAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "config"; + isMut: false; + isSigner: false; + }, + { + name: "token2022Program"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: true; + isSigner: false; + }, + { + name: "pool"; + isMut: true; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "positionNftMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolCreatorAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "mintGovernorAccounts"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1584,6 +1861,283 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "settleLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + isOptional: true, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "daoOwnedLpPosition", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "futarchyProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "futarchyEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "bidWallProgram", + isMut: false, + isSigner: false, + }, + { + name: "bidWallEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "meteoraAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "config", + isMut: false, + isSigner: false, + }, + { + name: "token2022Program", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: true, + isSigner: false, + }, + { + name: "pool", + isMut: true, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "positionNftMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "poolCreatorAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "mintGovernorAccounts", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index f4e04fbfc..97bec21a3 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -273,6 +273,283 @@ export type LaunchpadV8 = { }, ]; }, + { + name: "settleLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + isOptional: true; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "daoOwnedLpPosition"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "bidWall"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallQuoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "feeRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "futarchyProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "futarchyEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "bidWallProgram"; + isMut: false; + isSigner: false; + }, + { + name: "bidWallEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "meteoraAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "config"; + isMut: false; + isSigner: false; + }, + { + name: "token2022Program"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: true; + isSigner: false; + }, + { + name: "pool"; + isMut: true; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "positionNftMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolCreatorAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "mintGovernorAccounts"; + accounts: [ + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "mintAuthority"; + isMut: true; + isSigner: false; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -1584,6 +1861,283 @@ export const IDL: LaunchpadV8 = { }, ], }, + { + name: "settleLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + isOptional: true, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "daoOwnedLpPosition", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "bidWall", + isMut: true, + isSigner: false, + }, + { + name: "bidWallQuoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "feeRecipient", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "futarchyProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "futarchyEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "bidWallProgram", + isMut: false, + isSigner: false, + }, + { + name: "bidWallEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "meteoraAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "config", + isMut: false, + isSigner: false, + }, + { + name: "token2022Program", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: true, + isSigner: false, + }, + { + name: "pool", + isMut: true, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "positionNftMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "poolCreatorAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "mintGovernorAccounts", + accounts: [ + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "mintAuthority", + isMut: true, + isSigner: false, + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 8a9b583c6..04c170d91 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -45,14 +45,7 @@ > Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" -- [NEXT] 5.1 Implement `settle_launch` instruction (Rust) - - Create `src/instructions/settle_launch.rs` with `SettleLaunch` accounts struct, `validate()`, and `handle()` - - Port from v7 `complete_launch` with key changes: mint_governor::mint_tokens CPI replaces token::set_authority, no mint authority transfer - - Include StaticCompleteLaunchAccounts and MeteoraAccounts nested structs - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 5.2 Add `settleLaunchIx` to SDK2 client +- [NEXT] 5.2 Add `settleLaunchIx` to SDK2 client - Add the instruction builder method per spec (includes MintGovernor + Meteora + DAO account derivation) - Verify: `cd sdk2 && npx tsc --noEmit` From 40f48f320b75e0afd37f44b9ebc632c1ae58a7e1 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 10 Apr 2026 18:57:28 +0200 Subject: [PATCH 055/100] settle launch sdk --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 241 ++++++++++++++++++++- vibes/tasks.md | 6 +- 2 files changed, 241 insertions(+), 6 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index af074a22c..69497bced 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -1,14 +1,23 @@ import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { PublicKey, AccountInfo } from "@solana/web3.js"; +import { PublicKey, AccountInfo, ComputeBudgetProgram } from "@solana/web3.js"; import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, + TOKEN_2022_PROGRAM_ID, } from "@solana/spl-token"; import BN from "bn.js"; +import * as multisig from "@sqds/multisig"; import { LAUNCHPAD_V0_8_PROGRAM_ID, MPL_TOKEN_METADATA_PROGRAM_ID, MAINNET_USDC, + SQUADS_PROGRAM_ID, + SQUADS_PROGRAM_CONFIG, + SQUADS_PROGRAM_CONFIG_TREASURY, + SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, + DAMM_V2_PROGRAM_ID, + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + METADAO_MULTISIG_VAULT, } from "../../constants.js"; import { getFundingRecordAddr, @@ -384,4 +393,234 @@ export class LaunchpadClient { launchAuthority, }); } + + settleLaunchIx({ + launch, + baseMint, + quoteMint = MAINNET_USDC, + launchAuthority, + isDevnet = false, + meteoraConfig = LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + feeRecipient = METADAO_MULTISIG_VAULT, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + quoteMint?: PublicKey; + launchAuthority: PublicKey | null; + isDevnet?: boolean; + meteoraConfig?: PublicKey; + feeRecipient?: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const launchBaseVault = getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ); + + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [futarchyEventAuthority] = getEventAuthorityAddr( + this.autocratClient.getProgramId(), + ); + + const [tokenMetadata] = getMetadataAddr(baseMint); + + const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); + const [multisigVault] = multisig.getVaultPda({ + multisigPda, + index: 0, + }); + + const [spendingLimit] = multisig.getSpendingLimitPda({ + multisigPda, + createKey: dao, + }); + + const treasuryQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + multisigVault, + true, + ); + + const [ammPosition] = PublicKey.findProgramAddressSync( + [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], + this.autocratClient.getProgramId(), + ); + + // MintGovernor PDAs + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + const [mintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: launchSigner, + }); + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + + // Meteora PDAs + const [positionNftMint] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_mint"), baseMint.toBuffer()], + this.launchpad.programId, + ); + + const [positionNftAccount] = PublicKey.findProgramAddressSync( + [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + function getFirstKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + if (Buffer.compare(buf1, buf2) === 1) { + return buf1; + } + return buf2; + } + + function getSecondKey(key1: PublicKey, key2: PublicKey) { + const buf1 = key1.toBuffer(); + const buf2 = key2.toBuffer(); + if (Buffer.compare(buf1, buf2) === 1) { + return buf2; + } + return buf1; + } + + const [pool] = PublicKey.findProgramAddressSync( + [ + Buffer.from("pool"), + meteoraConfig.toBuffer(), + getFirstKey(baseMint, quoteMint), + getSecondKey(baseMint, quoteMint), + ], + DAMM_V2_PROGRAM_ID, + ); + + const [position] = PublicKey.findProgramAddressSync( + [Buffer.from("position"), positionNftMint.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenAVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [tokenBVault] = PublicKey.findProgramAddressSync( + [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], + DAMM_V2_PROGRAM_ID, + ); + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + this.launchpad.programId, + ); + + const [poolAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("pool_authority")], + DAMM_V2_PROGRAM_ID, + ); + + const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); + + // Bid wall PDAs + const bidWall = this.bidWall.getBidWallAddress({ + baseMint, + creator: launchSigner, + nonce: new BN(0), + }); + const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( + quoteMint, + bidWall, + true, + ); + + return this.launchpad.methods + .settleLaunch() + .accounts({ + launch, + launchSigner, + launchQuoteVault, + launchBaseVault, + launchAuthority, + dao, + treasuryQuoteAccount, + quoteMint, + baseMint, + tokenMetadata, + payer, + daoOwnedLpPosition: ammPosition, + futarchyAmmQuoteVault: getAssociatedTokenAddressSync( + quoteMint, + dao, + true, + ), + futarchyAmmBaseVault: getAssociatedTokenAddressSync( + baseMint, + dao, + true, + ), + staticAccounts: { + futarchyProgram: this.autocratClient.getProgramId(), + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + futarchyEventAuthority, + squadsProgram: SQUADS_PROGRAM_ID, + squadsProgramConfig: SQUADS_PROGRAM_CONFIG, + squadsProgramConfigTreasury: isDevnet + ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET + : SQUADS_PROGRAM_CONFIG_TREASURY, + bidWallProgram: this.bidWall.programId, + bidWallEventAuthority: this.bidWall.getEventAuthorityAddress(), + }, + squadsMultisig: multisigPda, + squadsMultisigVault: multisigVault, + spendingLimit, + bidWall, + bidWallQuoteTokenAccount, + feeRecipient, + meteoraAccounts: { + dammV2Program: DAMM_V2_PROGRAM_ID, + positionNftMint, + baseMint, + quoteMint, + config: meteoraConfig, + token2022Program: TOKEN_2022_PROGRAM_ID, + positionNftAccount, + pool, + poolCreatorAuthority, + position, + tokenAVault, + tokenBVault, + poolAuthority, + dammV2EventAuthority, + }, + mintGovernorAccounts: { + mintGovernor, + mintAuthority, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + }, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), + ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), + ]); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index 04c170d91..04f7cbf29 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -45,11 +45,7 @@ > Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" -- [NEXT] 5.2 Add `settleLaunchIx` to SDK2 client - - Add the instruction builder method per spec (includes MintGovernor + Meteora + DAO account derivation) - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 5.3 Write `settleLaunch` tests (tests #27–33) +- [NEXT] 5.3 Write `settleLaunch` tests (tests #27–33) - Test #27: happy path — tokens minted via MintGovernor, DAO created, liquidity, metadata transfer, USDC distribution, MintGovernor admin still launch_signer - Test #28: sends all USDC to treasury when hasBidWall is false - Test #29: initializes bid wall when hasBidWall is true and funding exceeds 1.25x From e275470add15063f27cb38f80991caad95efec18 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 01:52:42 +0200 Subject: [PATCH 056/100] settle launch ix tests + finalization --- programs/v08_launchpad/src/error.rs | 2 + .../src/instructions/initialize_launch.rs | 24 +- .../src/instructions/settle_launch.rs | 102 +-- sdk/src/v0.7/types/launchpad_v8.ts | 60 +- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 29 +- sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 60 +- tests/launchpad_v8/main.test.ts | 2 + .../unit/initializeLaunch.test.ts | 6 +- tests/launchpad_v8/unit/settleLaunch.test.ts | 679 ++++++++++++++++++ tests/utils.ts | 24 +- 10 files changed, 771 insertions(+), 217 deletions(-) create mode 100644 tests/launchpad_v8/unit/settleLaunch.test.ts diff --git a/programs/v08_launchpad/src/error.rs b/programs/v08_launchpad/src/error.rs index 881a619b3..43bccd9e1 100644 --- a/programs/v08_launchpad/src/error.rs +++ b/programs/v08_launchpad/src/error.rs @@ -66,4 +66,6 @@ pub enum LaunchpadError { ExtendDurationExceedsMax, #[msg("Mint authority does not match expected")] InvalidMintAuthority, + #[msg("Invalid Meteora account")] + InvalidMeteoraAccount, } diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs index 953999fde..0cccedaea 100644 --- a/programs/v08_launchpad/src/instructions/initialize_launch.rs +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; use anchor_spl::associated_token::AssociatedToken; -use anchor_spl::token::{Mint, Token, TokenAccount}; +use anchor_spl::token::{self, Mint, MintTo, Token, TokenAccount}; use mint_governor::{ cpi::{ @@ -296,6 +296,28 @@ impl InitializeLaunch<'_> { None, )?; + // Mint fixed token amounts into base vault while launch_signer is still the direct authority. + // These tokens will be distributed during settlement (participants, futarchy AMM, Meteora LP). + // Minting is done here rather than in settle_launch to stay within CPI limits during settlement, + // which already performs multiple nested CPIs (initialize_dao, meteora, bid wall). + let tokens_to_mint = TOKENS_TO_PARTICIPANTS + + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + + args.additional_tokens_amount; + + token::mint_to( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + MintTo { + mint: ctx.accounts.base_mint.to_account_info(), + to: ctx.accounts.base_vault.to_account_info(), + authority: ctx.accounts.launch_signer.to_account_info(), + }, + signer, + ), + tokens_to_mint, + )?; + // Set up MintGovernor: create governor, add launch_signer as minter, transfer mint authority initialize_mint_governor(CpiContext::new_with_signer( ctx.accounts.mint_governor_program.to_account_info(), diff --git a/programs/v08_launchpad/src/instructions/settle_launch.rs b/programs/v08_launchpad/src/instructions/settle_launch.rs index 0d8ba17e5..d7b31a089 100644 --- a/programs/v08_launchpad/src/instructions/settle_launch.rs +++ b/programs/v08_launchpad/src/instructions/settle_launch.rs @@ -12,12 +12,6 @@ use damm_v2_cpi::constants::seeds::{ use damm_v2_cpi::constants::MAX_SQRT_PRICE; use damm_v2_cpi::BaseFeeParameters; -use mint_governor::{ - cpi::{accounts::MintTokens, mint_tokens}, - program::MintGovernor as MintGovernorProgram, - MintTokensArgs, -}; - use crate::error::LaunchpadError; use crate::events::{CommonFields, LaunchCloseEvent, LaunchSettledEvent}; use crate::state::{Launch, LaunchState}; @@ -72,7 +66,10 @@ pub struct MeteoraAccounts<'info> { pub token_2022_program: Program<'info, Token2022>, /// CHECK: checked by damm v2 program - #[account(mut, seeds = [POSITION_NFT_ACCOUNT_PREFIX.as_ref(), position_nft_mint.key().as_ref()], bump, seeds::program = damm_v2_program)] + #[account(mut,seeds = [ + POSITION_NFT_ACCOUNT_PREFIX.as_ref(), + position_nft_mint.key().as_ref() + ], bump, seeds::program = damm_v2_program)] pub position_nft_account: UncheckedAccount<'info>, /// CHECK: checked by damm v2 program @@ -85,11 +82,16 @@ pub struct MeteoraAccounts<'info> { pub pool: UncheckedAccount<'info>, /// CHECK: checked by damm v2 program - #[account(mut, seeds = [POSITION_PREFIX.as_ref(), position_nft_mint.key().as_ref()], bump, seeds::program = damm_v2_program)] + #[account(mut, seeds = [ + POSITION_PREFIX.as_ref(), + position_nft_mint.key().as_ref() + ], bump, seeds::program = damm_v2_program)] pub position: UncheckedAccount<'info>, /// CHECK: checked by damm v2 program - #[account(mut, seeds = [b"position_nft_mint", base_mint.key().as_ref()], bump)] + #[account(mut, seeds = [ + b"position_nft_mint", + base_mint.key().as_ref()], bump)] pub position_nft_mint: UncheckedAccount<'info>, /// CHECK: checked by root struct @@ -125,23 +127,6 @@ pub struct MeteoraAccounts<'info> { pub damm_v2_event_authority: UncheckedAccount<'info>, } -#[derive(Accounts)] -pub struct MintGovernorAccounts<'info> { - #[account(mut)] - pub mint_governor: Box>, - - #[account( - mut, - has_one = mint_governor, - )] - pub mint_authority: Box>, - - pub mint_governor_program: Program<'info, MintGovernorProgram>, - - /// CHECK: checked by mint_governor program - pub mint_governor_event_authority: UncheckedAccount<'info>, -} - #[event_cpi] #[derive(Accounts)] pub struct SettleLaunch<'info> { @@ -243,7 +228,6 @@ pub struct SettleLaunch<'info> { pub associated_token_program: Program<'info, AssociatedToken>, pub static_accounts: StaticCompleteLaunchAccounts<'info>, pub meteora_accounts: MeteoraAccounts<'info>, - pub mint_governor_accounts: MintGovernorAccounts<'info>, } impl SettleLaunch<'_> { @@ -255,22 +239,6 @@ impl SettleLaunch<'_> { LaunchpadError::InvalidLaunchState ); - // The mint_governor is in a nested struct, so we can't use has_one on the launch account. - // Verify it matches the one stored on the launch. - require_keys_eq!( - self.mint_governor_accounts.mint_governor.key(), - self.launch.mint_governor, - LaunchpadError::InvalidMintAuthority - ); - - // The mint_authority's authorized_minter must be the launch_signer so it can - // sign the mint_tokens CPI via PDA seeds. - require_keys_eq!( - self.mint_governor_accounts.mint_authority.authorized_minter, - self.launch_signer.key(), - LaunchpadError::InvalidMintAuthority - ); - // if the launch was closed within 2 days, the launch authority must be the one // to settle the launch let two_days_after_close = self.launch.unix_timestamp_closed.unwrap() + 60 * 60 * 24 * 2; @@ -334,13 +302,8 @@ impl SettleLaunch<'_> { ]; let launch_signer = &[&launch_signer_seeds[..]]; - // Mint all needed tokens via MintGovernor - let tokens_to_mint = TOKENS_TO_PARTICIPANTS - + TOKENS_TO_FUTARCHY_LIQUIDITY - + TOKENS_TO_DAMM_V2_LIQUIDITY - + ctx.accounts.launch.additional_tokens_amount; - - ctx.accounts.mint_tokens(tokens_to_mint, launch_signer)?; + // Tokens were already minted into launch_base_vault during initialize_launch + // (moved there to stay within CPI depth limits during settlement). let price_1e12 = ((launch_total_approved_amount as u128) * PRICE_SCALE) / (TOKENS_TO_PARTICIPANTS as u128); @@ -407,8 +370,11 @@ impl SettleLaunch<'_> { None }, bid_wall_amount: usdc_to_bid_wall, - mint_governor: ctx.accounts.mint_governor_accounts.mint_governor.key(), - tokens_minted: tokens_to_mint, + mint_governor: launch.mint_governor, + tokens_minted: TOKENS_TO_PARTICIPANTS + + TOKENS_TO_FUTARCHY_LIQUIDITY + + TOKENS_TO_DAMM_V2_LIQUIDITY + + launch.additional_tokens_amount, }); let refundable_usdc = launch.total_committed_amount - launch_total_approved_amount; @@ -419,34 +385,6 @@ impl SettleLaunch<'_> { Ok(()) } - fn mint_tokens(&self, amount: u64, launch_signer: &[&[&[u8]]]) -> Result<()> { - mint_tokens( - CpiContext::new_with_signer( - self.mint_governor_accounts - .mint_governor_program - .to_account_info(), - MintTokens { - mint_governor: self.mint_governor_accounts.mint_governor.to_account_info(), - mint_authority: self.mint_governor_accounts.mint_authority.to_account_info(), - mint: self.base_mint.to_account_info(), - destination_ata: self.launch_base_vault.to_account_info(), - authorized_minter: self.launch_signer.to_account_info(), - token_program: self.token_program.to_account_info(), - event_authority: self - .mint_governor_accounts - .mint_governor_event_authority - .to_account_info(), - program: self - .mint_governor_accounts - .mint_governor_program - .to_account_info(), - }, - launch_signer, - ), - MintTokensArgs { amount }, - ) - } - #[inline(never)] fn initialize_dao(&self, launch_signer: &[&[&[u8]]], launch_price_1e12: u128) -> Result<()> { futarchy::cpi::initialize_dao( @@ -740,9 +678,7 @@ impl SettleLaunch<'_> { require_gte!( self.launch_base_vault.amount, - TOKENS_TO_PARTICIPANTS - + self.launch.additional_tokens_amount - + self.launch.performance_package_token_amount, + TOKENS_TO_PARTICIPANTS + self.launch.additional_tokens_amount, LaunchpadError::InvariantViolated ); require_gte!( diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 97bec21a3..af7967486 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -512,31 +512,6 @@ export type LaunchpadV8 = { }, ]; }, - { - name: "mintGovernorAccounts"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "mintGovernorProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, { name: "eventAuthority"; isMut: false; @@ -1583,6 +1558,11 @@ export type LaunchpadV8 = { name: "InvalidMintAuthority"; msg: "Mint authority does not match expected"; }, + { + code: 6032; + name: "InvalidMeteoraAccount"; + msg: "Invalid Meteora account"; + }, ]; }; @@ -2100,31 +2080,6 @@ export const IDL: LaunchpadV8 = { }, ], }, - { - name: "mintGovernorAccounts", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "mintGovernorProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, { name: "eventAuthority", isMut: false, @@ -3171,5 +3126,10 @@ export const IDL: LaunchpadV8 = { name: "InvalidMintAuthority", msg: "Mint authority does not match expected", }, + { + code: 6032, + name: "InvalidMeteoraAccount", + msg: "Invalid Meteora account", + }, ], }; diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 69497bced..ae8503a3a 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -459,21 +459,6 @@ export class LaunchpadClient { this.autocratClient.getProgramId(), ); - // MintGovernor PDAs - const [mintGovernor] = getMintGovernorAddr({ - programId: this.mintGovernorClient.programId, - mint: baseMint, - createKey: launchSigner, - }); - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter: launchSigner, - }); - const [mintGovernorEventAuthority] = getEventAuthorityAddr( - this.mintGovernorClient.programId, - ); - // Meteora PDAs const [positionNftMint] = PublicKey.findProgramAddressSync( [Buffer.from("position_nft_mint"), baseMint.toBuffer()], @@ -597,26 +582,20 @@ export class LaunchpadClient { feeRecipient, meteoraAccounts: { dammV2Program: DAMM_V2_PROGRAM_ID, - positionNftMint, - baseMint, - quoteMint, config: meteoraConfig, token2022Program: TOKEN_2022_PROGRAM_ID, positionNftAccount, pool, - poolCreatorAuthority, position, + positionNftMint, + baseMint, + quoteMint, tokenAVault, tokenBVault, + poolCreatorAuthority, poolAuthority, dammV2EventAuthority, }, - mintGovernorAccounts: { - mintGovernor, - mintAuthority, - mintGovernorProgram: this.mintGovernorClient.programId, - mintGovernorEventAuthority, - }, }) .preInstructions([ ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 97bec21a3..af7967486 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -512,31 +512,6 @@ export type LaunchpadV8 = { }, ]; }, - { - name: "mintGovernorAccounts"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "mintGovernorProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, { name: "eventAuthority"; isMut: false; @@ -1583,6 +1558,11 @@ export type LaunchpadV8 = { name: "InvalidMintAuthority"; msg: "Mint authority does not match expected"; }, + { + code: 6032; + name: "InvalidMeteoraAccount"; + msg: "Invalid Meteora account"; + }, ]; }; @@ -2100,31 +2080,6 @@ export const IDL: LaunchpadV8 = { }, ], }, - { - name: "mintGovernorAccounts", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "mintGovernorProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, { name: "eventAuthority", isMut: false, @@ -3171,5 +3126,10 @@ export const IDL: LaunchpadV8 = { name: "InvalidMintAuthority", msg: "Mint authority does not match expected", }, + { + code: 6032, + name: "InvalidMeteoraAccount", + msg: "Invalid Meteora account", + }, ], }; diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index 7b47a4c8e..cabb88c69 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -10,6 +10,7 @@ import startLaunch from "./unit/startLaunch.test.js"; import fund from "./unit/fund.test.js"; import closeLaunch from "./unit/closeLaunch.test.js"; import setFundingRecordApproval from "./unit/setFundingRecordApproval.test.js"; +import settleLaunch from "./unit/settleLaunch.test.js"; export default function suite() { before(async function () { @@ -74,4 +75,5 @@ export default function suite() { describe("#fund", fund); describe("#close_launch", closeLaunch); describe("#set_funding_record_approval", setFundingRecordApproval); + describe("#settle_launch", settleLaunch); } diff --git a/tests/launchpad_v8/unit/initializeLaunch.test.ts b/tests/launchpad_v8/unit/initializeLaunch.test.ts index b85578be4..1b1abb141 100644 --- a/tests/launchpad_v8/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v8/unit/initializeLaunch.test.ts @@ -153,10 +153,10 @@ export default function suite() { const mintInfo = await this.getMint(META); assert.ok(mintInfo.mintAuthority.equals(expectedMintGovernor)); - // Zero supply, zero base vault balance - assert.equal(mintInfo.supply.toString(), "0"); + // Tokens are minted during initialize_launch (before governor takes over) + assert.equal(mintInfo.supply.toString(), expectedMaxTotal.toString()); const baseVaultBalance = await this.getTokenBalance(META, launchSigner); - assert.equal(baseVaultBalance.toString(), "0"); + assert.equal(baseVaultBalance.toString(), expectedMaxTotal.toString()); }); it("fails when monthly spending limit members contains duplicates", async function () { diff --git a/tests/launchpad_v8/unit/settleLaunch.test.ts b/tests/launchpad_v8/unit/settleLaunch.test.ts new file mode 100644 index 000000000..d37210fa9 --- /dev/null +++ b/tests/launchpad_v8/unit/settleLaunch.test.ts @@ -0,0 +1,679 @@ +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, + ComputeBudgetProgram, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { getMetadataAddr, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import BN from "bn.js"; +import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; +import { + fromWeb3JsPublicKey, + toWeb3JsPublicKey, +} from "@metaplex-foundation/umi-web3js-adapters"; +import { initializeMintWithSeeds } from "../utils.js"; +import { createLookupTableForTransaction } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const minRaise = new BN(100_000 * 10 ** 6); // 100k USDC + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + const funder1 = Keypair.generate(); + const funder2 = Keypair.generate(); + + before(async function () { + launchpadClient = this.launchpad_v8; + + await this.createTokenAccount(MAINNET_USDC, funder1.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder2.publicKey); + }); + + async function settleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey | null; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + await context.banksClient.processTransaction(tx); + } + + async function trySettleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey | null; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + return context.banksClient.tryProcessTransaction(tx); + } + + async function setupFundCloseApprove( + context: any, + client: LaunchpadClient, + opts: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: Keypair; + fundAmount: BN; + approveAmount?: BN; + hasBidWall?: boolean; + }, + ) { + // Fund + await client + .fundIx({ + launch: opts.launch, + amount: opts.fundAmount, + payer: context.payer.publicKey, + }) + .rpc(); + + // Advance past launch period + await context.advanceBySeconds(secondsForLaunch + 1); + + // Close + await client.closeLaunchIx({ launch: opts.launch }).rpc(); + + // Approve + const approveAmount = + opts.approveAmount !== undefined ? opts.approveAmount : opts.fundAmount; + await client + .setFundingRecordApprovalIx({ + launch: opts.launch, + approvedAmount: approveAmount, + funder: context.payer.publicKey, + launchAuthority: opts.launchAuthority.publicKey, + }) + .signers([opts.launchAuthority]) + .rpc(); + } + + describe("happy path", function () { + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + }); + + it("settles launch with DAO creation, token minting, liquidity, metadata transfer, and USDC distribution", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); // 150k USDC + + const [tokenMetadata] = getMetadataAddr(META); + + // Verify metadata authority is launch_signer before settle + let rawStoredMetadata = await this.banksClient.getAccount(tokenMetadata); + let storedMetadata = deserializeMetadata({ + ...rawStoredMetadata, + publicKey: fromWeb3JsPublicKey(tokenMetadata), + owner: fromWeb3JsPublicKey(rawStoredMetadata.owner), + lamports: { + basisPoints: BigInt(rawStoredMetadata.lamports), + identifier: "SOL", + decimals: 9, + }, + rentEpoch: rawStoredMetadata.rentEpoch + ? BigInt(rawStoredMetadata.rentEpoch) + : undefined, + }); + assert.ok( + toWeb3JsPublicKey(storedMetadata.updateAuthority).equals(launchSigner), + ); + + await setupFundCloseApprove(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + approveAmount: fundAmount, + }); + + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + // Verify launch state + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + assert.isNotNull(launchAccount.dao); + assert.isNotNull(launchAccount.daoVault); + assert.isNotNull(launchAccount.unixTimestampCompleted); + + // Verify USDC distribution: 80% to treasury + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal( + treasuryUSDCBalance.toString(), + fundAmount.muln(8).divn(10).toString(), + ); + + // Verify token supply: 10M + 2M + 900k = 12,900,000 + // (performance package tokens are minted separately) + const mint = await this.getMint(META); + const expectedSupply = (10_000_000 + 2_000_000 + 900_000) * 10 ** 6; + assert.equal(Number(mint.supply), expectedSupply); + + // Verify metadata authority transferred to dao_vault + rawStoredMetadata = await this.banksClient.getAccount(tokenMetadata); + storedMetadata = deserializeMetadata({ + ...rawStoredMetadata, + publicKey: fromWeb3JsPublicKey(tokenMetadata), + owner: fromWeb3JsPublicKey(rawStoredMetadata.owner), + lamports: { + basisPoints: BigInt(rawStoredMetadata.lamports), + identifier: "SOL", + decimals: 9, + }, + rentEpoch: rawStoredMetadata.rentEpoch + ? BigInt(rawStoredMetadata.rentEpoch) + : undefined, + }); + assert.ok( + toWeb3JsPublicKey(storedMetadata.updateAuthority).equals( + launchAccount.daoVault, + ), + ); + + // Verify MintGovernor admin is still launch_signer (not yet transferred to DAO) + const mintGovernorAddr = launchpadClient.getMintGovernorAddress({ + baseMint: META, + launchSigner, + }); + const mintGovernorAccount = + await launchpadClient.mintGovernorClient.fetchMintGovernor( + mintGovernorAddr, + ); + assert.ok(mintGovernorAccount.admin.equals(launchSigner)); + }); + }); + + describe("USDC allocation", function () { + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + }); + + it("sends all USDC to treasury when hasBidWall is false", async function () { + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: false, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + const fundAmount = new BN(200_000 * 10 ** 6); // 200k USDC (2x minimum) + + await setupFundCloseApprove(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + + // usdc_to_lp = 200k / 5 = 40k + // usdc_to_dao = 200k - 40k = 160k (all goes to treasury, no bid wall) + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal( + treasuryUSDCBalance.toString(), + fundAmount.muln(4).divn(5).toString(), + ); + }); + + it("initializes bid wall when hasBidWall is true and funding exceeds 1.25x", async function () { + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: true, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Fund 200k (2x minimum of 100k, well above 1.25x threshold) + const fundAmount = new BN(200_000 * 10 ** 6); + + await setupFundCloseApprove(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + // usdc_to_lp = 200k / 5 = 40k + // usdc_to_dao = 200k - 40k = 160k + // usdc_to_dao_treasury = min(160k, 100k) = 100k + // usdc_to_bid_wall = 160k - 100k = 60k + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal(treasuryUSDCBalance.toString(), minRaise.toString()); + + // Verify bid wall was initialized with USDC + const bidWallAddr = launchpadClient.bidWall.getBidWallAddress({ + baseMint: META, + creator: launchSigner, + nonce: new BN(0), + }); + const bidWallAccount = + await launchpadClient.bidWall.fetchBidWall(bidWallAddr); + assert.isNotNull(bidWallAccount); + }); + + it("does not initialize bid wall when funding equals minimum raise", async function () { + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: true, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Fund exactly minimum raise + await setupFundCloseApprove(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount: minRaise, + }); + + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + // usdc_to_lp = 100k / 5 = 20k + // usdc_to_dao = 100k - 20k = 80k + // usdc_to_dao_treasury = min(80k, 100k) = 80k + // usdc_to_bid_wall = 80k - 80k = 0 (no bid wall) + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal( + treasuryUSDCBalance.toString(), + minRaise.muln(4).divn(5).toString(), + ); + + // Bid wall should not be initialized + const bidWallAddr = launchpadClient.bidWall.getBidWallAddress({ + baseMint: META, + creator: launchSigner, + nonce: new BN(0), + }); + const bidWallRawAccount = await this.banksClient.getAccount(bidWallAddr); + assert.isNull(bidWallRawAccount); + }); + + it("does not initialize bid wall at exactly 1.25x boundary", async function () { + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + hasBidWall: true, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Fund exactly 1.25x minimum = 125k + const fundAmount = minRaise.muln(5).divn(4); + + await setupFundCloseApprove(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + // usdc_to_lp = 125k / 5 = 25k + // usdc_to_dao = 125k - 25k = 100k + // usdc_to_dao_treasury = min(100k, 100k) = 100k + // usdc_to_bid_wall = 100k - 100k = 0 (no bid wall) + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal(treasuryUSDCBalance.toString(), minRaise.toString()); + + // Bid wall should not be initialized + const bidWallAddr = launchpadClient.bidWall.getBidWallAddress({ + baseMint: META, + creator: launchSigner, + nonce: new BN(0), + }); + const bidWallRawAccount = await this.banksClient.getAccount(bidWallAddr); + assert.isNull(bidWallRawAccount); + }); + }); + + describe("refunding", function () { + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + }); + + it("transitions to refunding when total approved amount is below minimum raise", async function () { + // Fund enough to get past close_launch (>= minimum raise) + const fundAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Approve only a small portion (below minimum raise) + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: new BN(50_000 * 10 ** 6), // 50k, below 100k minimum + funder: this.payer.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Wait past 2-day approval window so launch authority doesn't need to sign + await this.advanceBySeconds(60 * 60 * 24 * 2 + 1); + + await settleViaLut(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority: null, + }); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { refunding: {} }); + assert.isNull(launchAccount.dao); + assert.isNull(launchAccount.daoVault); + assert.isNull(launchAccount.unixTimestampCompleted); + + // Tokens were minted during initialize_launch, supply is 12.9M + // (no additional tokens minted during settlement for refunding launches) + const mint = await this.getMint(META); + const expectedSupply = (10_000_000 + 2_000_000 + 900_000) * 10 ** 6; + assert.equal(Number(mint.supply), expectedSupply); + }); + + it("fails when launch is in refunding state", async function () { + // Fund below minimum so close_launch sets Refunding + const fundAmount = new BN(100 * 10 ** 6); // 100 USDC, way below 100k minimum + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Launch is now in Refunding state (set by close_launch) + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { refunding: {} }); + + // Try to settle — should fail + const result = await trySettleViaLut(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority: null, + }); + + assert.isTrue( + result.meta.logMessages.some((log: string) => + log.includes("InvalidLaunchState"), + ), + ); + }); + }); +} diff --git a/tests/utils.ts b/tests/utils.ts index 938662f3a..4aab18f1c 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -97,16 +97,30 @@ export async function createLookupTableForTransaction( recentSlot: slot - 1n, }); - // Extract all unique accounts from the transaction - const accountsToAdd = transaction.instructions.map((instruction) => + // Extract all unique accounts from the transaction (deduplicate by base58) + const accountsToAdd = transaction.instructions.flatMap((instruction) => instruction.keys.map((key) => key.pubkey), ); - const uniqueAccounts = [...new Set(accountsToAdd.flat())] as PublicKey[]; + const seen = new Set(); + const uniqueAccounts: PublicKey[] = []; + for (const key of accountsToAdd) { + const b58 = key.toBase58(); + if (!seen.has(b58)) { + seen.add(b58); + uniqueAccounts.push(key); + } + } console.log("uniqueAccounts", uniqueAccounts.length); // Add any additional addresses - const allAddresses = [...uniqueAccounts, ...additionalAddresses]; - const finalUniqueAddresses = [...new Set(allAddresses)] as PublicKey[]; + for (const key of additionalAddresses) { + const b58 = key.toBase58(); + if (!seen.has(b58)) { + seen.add(b58); + uniqueAccounts.push(key); + } + } + const finalUniqueAddresses = uniqueAccounts; // Create the lookup table const createLutTx = new Transaction().add(createTableIx); From aab6f52e9e1ad6428a9b17089a4a075d21814ada Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:03:01 +0200 Subject: [PATCH 057/100] return of the set funding record approval test --- .../unit/setFundingRecordApproval.test.ts | 97 ++++++++++++++++++- vibes/tasks.md | 16 +-- 2 files changed, 94 insertions(+), 19 deletions(-) diff --git a/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts b/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts index 851396a3e..7211962da 100644 --- a/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts +++ b/tests/launchpad_v8/unit/setFundingRecordApproval.test.ts @@ -1,4 +1,9 @@ -import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; import { assert } from "chai"; import { LaunchpadClient, @@ -7,7 +12,7 @@ import { import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { expectError } from "../../utils.js"; +import { expectError, createLookupTableForTransaction } from "../../utils.js"; export default function suite() { let launchpadClient: LaunchpadClient; @@ -290,8 +295,92 @@ export default function suite() { .then(callbacks[0], callbacks[1]); }); - // TODO: needs settle_launch to reach Complete state - it("can't set funding record approval after the launch is completed"); + it("can't set funding record approval after the launch is completed", async function () { + await fundLaunch(); + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Approve all funders + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder2Amount, + funder: funder2.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder3Amount, + funder: funder3.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder4Amount, + funder: funder4.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Settle launch to reach Complete state + const settleTx = await launchpadClient + .settleLaunchIx({ + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, this); + + const message = new TransactionMessage({ + payerKey: this.payer.publicKey, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([this.payer, launchAuthority]); + + await this.banksClient.processTransaction(tx); + + // Verify launch is now Complete + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + // Try to set funding record approval after completion + const callbacks = expectError("InvalidLaunchState", "Invalid launch state"); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount: funder1Amount, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc() + .then(callbacks[0], callbacks[1]); + }); it("can't set funding record approval to an amount greater than the committed amount", async function () { await fundLaunch(); diff --git a/vibes/tasks.md b/vibes/tasks.md index 04f7cbf29..0135c3653 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -45,25 +45,11 @@ > Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" -- [NEXT] 5.3 Write `settleLaunch` tests (tests #27–33) - - Test #27: happy path — tokens minted via MintGovernor, DAO created, liquidity, metadata transfer, USDC distribution, MintGovernor admin still launch_signer - - Test #28: sends all USDC to treasury when hasBidWall is false - - Test #29: initializes bid wall when hasBidWall is true and funding exceeds 1.25x - - Test #30: no bid wall when funding equals minimum raise - - Test #31: no bid wall at exactly 1.25x boundary - - Test #32: Refunding path — no tokens minted, no DAO - - Test #33: fails when launch is in refunding state - - Verify: `anchor test --skip-build` (with `.only`) - -- [ ] 5.4 Finish `setFundingRecordApproval` test #25 - - Fill in stub: "can't set funding record approval after the launch is completed" (needs Complete state via settle_launch) - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [ ] 6.1 Implement `claim` instruction (Rust) +- [NEXT] 6.1 Implement `claim` instruction (Rust) - Create `src/instructions/claim.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 963793ffba764dde394a3859283432c331e94317 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:11:36 +0200 Subject: [PATCH 058/100] claim ix --- .../v08_launchpad/src/instructions/claim.rs | 111 +++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 5 + sdk/src/v0.7/types/launchpad_v8.ts | 112 ++++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 112 ++++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 343 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/claim.rs diff --git a/programs/v08_launchpad/src/instructions/claim.rs b/programs/v08_launchpad/src/instructions/claim.rs new file mode 100644 index 000000000..ffb571f8a --- /dev/null +++ b/programs/v08_launchpad/src/instructions/claim.rs @@ -0,0 +1,111 @@ +use anchor_lang::prelude::*; +use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchClaimEvent}; +use crate::state::{FundingRecord, Launch, LaunchState}; +use crate::TOKENS_TO_PARTICIPANTS; + +#[event_cpi] +#[derive(Accounts)] +pub struct Claim<'info> { + #[account( + mut, + has_one = launch_signer, + has_one = base_mint, + has_one = launch_base_vault, + )] + pub launch: Account<'info, Launch>, + + #[account( + mut, + has_one = launch, + has_one = funder, + seeds = [b"funding_record", launch.key().as_ref(), funder.key().as_ref()], + bump = funding_record.pda_bump + )] + pub funding_record: Account<'info, FundingRecord>, + + /// CHECK: just a signer + pub launch_signer: UncheckedAccount<'info>, + + pub base_mint: Account<'info, Mint>, + + #[account(mut)] + pub launch_base_vault: Account<'info, TokenAccount>, + + /// CHECK: not used, just for constraints + pub funder: UncheckedAccount<'info>, + + #[account( + mut, + associated_token::mint = base_mint, + associated_token::authority = funder + )] + pub funder_token_account: Account<'info, TokenAccount>, + + pub token_program: Program<'info, Token>, +} + +impl Claim<'_> { + pub fn validate(&self) -> Result<()> { + require!( + self.launch.state == LaunchState::Complete, + LaunchpadError::InvalidLaunchState + ); + + require!( + !self.funding_record.is_tokens_claimed, + LaunchpadError::TokensAlreadyClaimed + ); + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch = &mut ctx.accounts.launch; + let funding_record = &mut ctx.accounts.funding_record; + let launch_key = launch.key(); + + let token_amount = (funding_record.approved_amount as u128) + .checked_mul(TOKENS_TO_PARTICIPANTS as u128) + .unwrap() + .checked_div(launch.total_approved_amount as u128) + .unwrap() as u64; + + let seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[launch.launch_signer_pda_bump], + ]; + let signer = &[&seeds[..]]; + + funding_record.is_tokens_claimed = true; + + token::transfer( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + Transfer { + from: ctx.accounts.launch_base_vault.to_account_info(), + to: ctx.accounts.funder_token_account.to_account_info(), + authority: ctx.accounts.launch_signer.to_account_info(), + }, + signer, + ), + token_amount, + )?; + + launch.seq_num += 1; + + let clock = Clock::get()?; + emit_cpi!(LaunchClaimEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + funder: ctx.accounts.funder.key(), + tokens_claimed: token_amount, + funding_record: funding_record.key(), + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index dcd34f74f..34323c8dc 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,3 +1,4 @@ +pub mod claim; pub mod close_launch; pub mod fund; pub mod initialize_launch; @@ -5,6 +6,7 @@ pub mod set_funding_record_approval; pub mod settle_launch; pub mod start_launch; +pub use claim::*; pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 7e9c908c1..6e99ce390 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -103,4 +103,9 @@ pub mod launchpad_v8 { pub fn settle_launch(ctx: Context) -> Result<()> { SettleLaunch::handle(ctx) } + + #[access_control(ctx.accounts.validate())] + pub fn claim(ctx: Context) -> Result<()> { + Claim::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index af7967486..c82df4a91 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -525,6 +525,62 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2093,6 +2149,62 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index af7967486..c82df4a91 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -525,6 +525,62 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2093,6 +2149,62 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 0135c3653..ba8f8297b 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,12 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.1 Implement `claim` instruction (Rust) - - Create `src/instructions/claim.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 6.2 Implement `refund` instruction (Rust) +- [NEXT] 6.2 Implement `refund` instruction (Rust) - Create `src/instructions/refund.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From cafbb444590714d514cf2e5f1c84111d4c7f8e71 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:16:28 +0200 Subject: [PATCH 059/100] refund ix --- .../v08_launchpad/src/instructions/mod.rs | 2 + .../v08_launchpad/src/instructions/refund.rs | 106 ++++++++++++++++++ programs/v08_launchpad/src/lib.rs | 5 + sdk/src/v0.7/types/launchpad_v8.ts | 102 +++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 102 +++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 318 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/refund.rs diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 34323c8dc..7b01d1027 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -2,6 +2,7 @@ pub mod claim; pub mod close_launch; pub mod fund; pub mod initialize_launch; +pub mod refund; pub mod set_funding_record_approval; pub mod settle_launch; pub mod start_launch; @@ -10,6 +11,7 @@ pub use claim::*; pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; +pub use refund::*; pub use set_funding_record_approval::*; pub use settle_launch::*; pub use start_launch::*; diff --git a/programs/v08_launchpad/src/instructions/refund.rs b/programs/v08_launchpad/src/instructions/refund.rs new file mode 100644 index 000000000..6e5fbb40c --- /dev/null +++ b/programs/v08_launchpad/src/instructions/refund.rs @@ -0,0 +1,106 @@ +use anchor_lang::prelude::*; +use anchor_spl::token::{self, Token, TokenAccount, Transfer}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchRefundedEvent}; +use crate::state::{FundingRecord, Launch, LaunchState}; + +#[event_cpi] +#[derive(Accounts)] +pub struct Refund<'info> { + #[account( + mut, + has_one = launch_quote_vault, + has_one = launch_signer, + )] + pub launch: Account<'info, Launch>, + + #[account( + mut, + has_one = launch, + has_one = funder, + seeds = [b"funding_record", launch.key().as_ref(), funder.key().as_ref()], + bump = funding_record.pda_bump + )] + pub funding_record: Account<'info, FundingRecord>, + + #[account(mut)] + pub launch_quote_vault: Account<'info, TokenAccount>, + + /// CHECK: just a signer + pub launch_signer: UncheckedAccount<'info>, + + /// CHECK: not used, just for constraints + pub funder: UncheckedAccount<'info>, + + #[account(mut, associated_token::mint = launch.quote_mint, associated_token::authority = funder)] + pub funder_quote_account: Account<'info, TokenAccount>, + + pub token_program: Program<'info, Token>, +} + +impl Refund<'_> { + pub fn validate(&self) -> Result<()> { + require!( + self.launch.state == LaunchState::Refunding + || self.launch.state == LaunchState::Complete, + LaunchpadError::LaunchNotRefunding + ); + + require!( + !self.funding_record.is_usdc_refunded, + LaunchpadError::MoneyAlreadyRefunded + ); + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch = &mut ctx.accounts.launch; + let launch_key = launch.key(); + let funding_record = &mut ctx.accounts.funding_record; + + let amount_to_refund = match launch.state { + LaunchState::Refunding => funding_record.committed_amount, + LaunchState::Complete => { + funding_record.committed_amount - funding_record.approved_amount + } + _ => unreachable!(), + }; + + let seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[launch.launch_signer_pda_bump], + ]; + let signer = &[&seeds[..]]; + + funding_record.is_usdc_refunded = true; + + token::transfer( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + Transfer { + from: ctx.accounts.launch_quote_vault.to_account_info(), + to: ctx.accounts.funder_quote_account.to_account_info(), + authority: ctx.accounts.launch_signer.to_account_info(), + }, + signer, + ), + amount_to_refund, + )?; + + launch.seq_num += 1; + + let clock = Clock::get()?; + emit_cpi!(LaunchRefundedEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: ctx.accounts.launch.key(), + funder: ctx.accounts.funder.key(), + usdc_refunded: amount_to_refund, + funding_record: ctx.accounts.funding_record.key(), + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index 6e99ce390..e9c488673 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -108,4 +108,9 @@ pub mod launchpad_v8 { pub fn claim(ctx: Context) -> Result<()> { Claim::handle(ctx) } + + #[access_control(ctx.accounts.validate())] + pub fn refund(ctx: Context) -> Result<()> { + Refund::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index c82df4a91..7540add29 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -581,6 +581,57 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2205,6 +2256,57 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index c82df4a91..7540add29 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -581,6 +581,57 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2205,6 +2256,57 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index ba8f8297b..c5f46098c 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,12 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.2 Implement `refund` instruction (Rust) - - Create `src/instructions/refund.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 6.3 Implement `claim_additional_token_allocation` instruction (Rust) +- [NEXT] 6.3 Implement `claim_additional_token_allocation` instruction (Rust) - Create `src/instructions/claim_additional_token_allocation.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 4412403281e991e7668fd101637181636444ee97 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:21:52 +0200 Subject: [PATCH 060/100] claim additional tokens ix --- .../claim_additional_token_allocation.rs | 112 +++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 7 + sdk/src/v0.7/types/launchpad_v8.ts | 132 ++++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 132 ++++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 386 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/claim_additional_token_allocation.rs diff --git a/programs/v08_launchpad/src/instructions/claim_additional_token_allocation.rs b/programs/v08_launchpad/src/instructions/claim_additional_token_allocation.rs new file mode 100644 index 000000000..b6e9ef2c3 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/claim_additional_token_allocation.rs @@ -0,0 +1,112 @@ +use anchor_lang::prelude::*; +use anchor_spl::associated_token::AssociatedToken; +use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchClaimAdditionalTokenAllocationEvent}; +use crate::state::{Launch, LaunchState}; + +#[event_cpi] +#[derive(Accounts)] +pub struct ClaimAdditionalTokenAllocation<'info> { + #[account( + mut, + has_one = launch_base_vault, + has_one = launch_signer, + has_one = base_mint, + )] + pub launch: Account<'info, Launch>, + + #[account(mut)] + pub payer: Signer<'info>, + + /// CHECK: just a signer + pub launch_signer: UncheckedAccount<'info>, + + #[account(mut)] + pub launch_base_vault: Account<'info, TokenAccount>, + + pub base_mint: Account<'info, Mint>, + + /// CHECK: explicitly checked in validate + pub additional_tokens_recipient: AccountInfo<'info>, + + #[account( + init_if_needed, + payer = payer, + associated_token::mint = base_mint, + associated_token::authority = additional_tokens_recipient, + )] + pub additional_tokens_recipient_token_account: Account<'info, TokenAccount>, + + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, +} + +impl ClaimAdditionalTokenAllocation<'_> { + pub fn validate(&self) -> Result<()> { + require!( + self.launch.state == LaunchState::Complete, + LaunchpadError::InvalidLaunchState + ); + + require!( + !self.launch.additional_tokens_claimed, + LaunchpadError::AdditionalTokensAlreadyClaimed + ); + + require!( + self.launch.additional_tokens_recipient.is_some(), + LaunchpadError::NoAdditionalTokensRecipientSet + ); + + require_keys_eq!( + self.additional_tokens_recipient.key(), + self.launch.additional_tokens_recipient.unwrap(), + LaunchpadError::InvalidAdditionalTokensRecipient + ); + + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch_key = ctx.accounts.launch.key(); + let seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[ctx.accounts.launch.launch_signer_pda_bump], + ]; + let signer = &[&seeds[..]]; + + token::transfer( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + Transfer { + from: ctx.accounts.launch_base_vault.to_account_info(), + to: ctx + .accounts + .additional_tokens_recipient_token_account + .to_account_info(), + authority: ctx.accounts.launch_signer.to_account_info(), + }, + signer, + ), + ctx.accounts.launch.additional_tokens_amount, + )?; + + ctx.accounts.launch.additional_tokens_claimed = true; + ctx.accounts.launch.seq_num += 1; + + let clock = Clock::get()?; + + emit_cpi!(LaunchClaimAdditionalTokenAllocationEvent { + common: CommonFields::new(&clock, ctx.accounts.launch.seq_num), + launch: ctx.accounts.launch.key(), + additional_tokens_amount: ctx.accounts.launch.additional_tokens_amount, + additional_tokens_recipient: ctx.accounts.additional_tokens_recipient.key(), + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 7b01d1027..a8b541362 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,4 +1,5 @@ pub mod claim; +pub mod claim_additional_token_allocation; pub mod close_launch; pub mod fund; pub mod initialize_launch; @@ -8,6 +9,7 @@ pub mod settle_launch; pub mod start_launch; pub use claim::*; +pub use claim_additional_token_allocation::*; pub use close_launch::*; pub use fund::*; pub use initialize_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index e9c488673..be3fbb438 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -113,4 +113,11 @@ pub mod launchpad_v8 { pub fn refund(ctx: Context) -> Result<()> { Refund::handle(ctx) } + + #[access_control(ctx.accounts.validate())] + pub fn claim_additional_token_allocation( + ctx: Context, + ) -> Result<()> { + ClaimAdditionalTokenAllocation::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 7540add29..7eb7d5894 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -632,6 +632,72 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "claimAdditionalTokenAllocation"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipientTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2307,6 +2373,72 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "claimAdditionalTokenAllocation", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipientTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 7540add29..7eb7d5894 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -632,6 +632,72 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "claimAdditionalTokenAllocation"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipient"; + isMut: false; + isSigner: false; + }, + { + name: "additionalTokensRecipientTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2307,6 +2373,72 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "claimAdditionalTokenAllocation", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipient", + isMut: false, + isSigner: false, + }, + { + name: "additionalTokensRecipientTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index c5f46098c..ba7dff16c 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,12 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.3 Implement `claim_additional_token_allocation` instruction (Rust) - - Create `src/instructions/claim_additional_token_allocation.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 6.4 Add `claimIx`, `refundIx`, `claimAdditionalTokenAllocationIx` to SDK2 client +- [NEXT] 6.4 Add `claimIx`, `refundIx`, `claimAdditionalTokenAllocationIx` to SDK2 client - Port from v7 SDK2 client - Verify: `cd sdk2 && npx tsc --noEmit` From 891801c18ae8ed5c6a5e198ee55693ed9f06e2b6 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:26:49 +0200 Subject: [PATCH 061/100] claim refund and claim addtional ixs --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 114 +++++++++++++++++++++ vibes/tasks.md | 6 +- 2 files changed, 115 insertions(+), 5 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index ae8503a3a..dbdfe2cb7 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -602,4 +602,118 @@ export class LaunchpadClient { ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), ]); } + + claimIx({ + launch, + baseMint, + funder = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + funder?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + return this.launchpad.methods + .claim() + .accounts({ + launch, + fundingRecord, + launchSigner, + baseMint, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + funder, + funderTokenAccount: getAssociatedTokenAddressSync( + baseMint, + funder, + true, + ), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + getAssociatedTokenAddressSync(baseMint, funder, true), + funder, + baseMint, + ), + ]); + } + + refundIx({ + launch, + funder = this.provider.publicKey, + quoteMint = MAINNET_USDC, + }: { + launch: PublicKey; + funder?: PublicKey; + quoteMint?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + const [fundingRecord] = getFundingRecordAddr( + this.launchpad.programId, + launch, + funder, + ); + + const launchQuoteVault = getAssociatedTokenAddressSync( + quoteMint, + launchSigner, + true, + ); + const funderQuoteAccount = getAssociatedTokenAddressSync( + quoteMint, + funder, + true, + ); + + return this.launchpad.methods.refund().accounts({ + launch, + fundingRecord, + launchQuoteVault, + launchSigner, + funder, + funderQuoteAccount, + }); + } + + claimAdditionalTokenAllocationIx({ + launch, + baseMint, + additionalTokensRecipient, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + additionalTokensRecipient: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + return this.launchpad.methods.claimAdditionalTokenAllocation().accounts({ + launch, + payer, + launchSigner, + launchBaseVault: getAssociatedTokenAddressSync( + baseMint, + launchSigner, + true, + ), + baseMint, + additionalTokensRecipient, + additionalTokensRecipientTokenAccount: getAssociatedTokenAddressSync( + baseMint, + additionalTokensRecipient, + true, + ), + }); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index ba7dff16c..b5644ea2c 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,11 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.4 Add `claimIx`, `refundIx`, `claimAdditionalTokenAllocationIx` to SDK2 client - - Port from v7 SDK2 client - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 6.5 Write `claim` tests (tests #37–38) +- [NEXT] 6.5 Write `claim` tests (tests #37–38) - Test #37: "successfully claims tokens after launch completion" - Test #38: "fails when launch is not complete" - Verify: `anchor test --skip-build` (with `.only`) From 4d3bb1df7613008fb94895090b5cd072e2a661f0 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:32:52 +0200 Subject: [PATCH 062/100] claim tests --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/claim.test.ts | 202 ++++++++++++++++++++++++++ vibes/tasks.md | 7 +- 3 files changed, 205 insertions(+), 6 deletions(-) create mode 100644 tests/launchpad_v8/unit/claim.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index cabb88c69..2a5ce4368 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -11,6 +11,7 @@ import fund from "./unit/fund.test.js"; import closeLaunch from "./unit/closeLaunch.test.js"; import setFundingRecordApproval from "./unit/setFundingRecordApproval.test.js"; import settleLaunch from "./unit/settleLaunch.test.js"; +import claim from "./unit/claim.test.js"; export default function suite() { before(async function () { @@ -76,4 +77,5 @@ export default function suite() { describe("#close_launch", closeLaunch); describe("#set_funding_record_approval", setFundingRecordApproval); describe("#settle_launch", settleLaunch); + describe("#claim", claim); } diff --git a/tests/launchpad_v8/unit/claim.test.ts b/tests/launchpad_v8/unit/claim.test.ts new file mode 100644 index 000000000..086671b9a --- /dev/null +++ b/tests/launchpad_v8/unit/claim.test.ts @@ -0,0 +1,202 @@ +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { + LaunchpadClient, + getFundingRecordAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { createLookupTableForTransaction } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + async function settleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + await context.banksClient.processTransaction(tx); + } + + async function setupFundCloseApproveSettle( + context: any, + client: LaunchpadClient, + opts: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: Keypair; + fundAmount: BN; + }, + ) { + // Fund + await client + .fundIx({ + launch: opts.launch, + amount: opts.fundAmount, + payer: context.payer.publicKey, + }) + .rpc(); + + // Advance past launch period + await context.advanceBySeconds(secondsForLaunch + 1); + + // Close + await client.closeLaunchIx({ launch: opts.launch }).rpc(); + + // Approve + await client + .setFundingRecordApprovalIx({ + launch: opts.launch, + approvedAmount: opts.fundAmount, + funder: context.payer.publicKey, + launchAuthority: opts.launchAuthority.publicKey, + }) + .signers([opts.launchAuthority]) + .rpc(); + + // Settle + await settleViaLut( + context, + client, + { + launch: opts.launch, + baseMint: opts.baseMint, + launchAuthority: opts.launchAuthority.publicKey, + }, + [opts.launchAuthority], + ); + } + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Create funder's base token ATA + await this.createTokenAccount(META, this.payer.publicKey); + }); + + it("successfully claims tokens after launch completion", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); // 150k USDC + + await setupFundCloseApproveSettle(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + // Verify launch is complete + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + // Initial token balance should be 0 + const initialBalance = await this.getTokenBalance( + META, + this.payer.publicKey, + ); + assert.equal(initialBalance.toString(), "0"); + + // Claim + await launchpadClient.claimIx({ launch, baseMint: META }).rpc(); + + // Sole funder gets all TOKENS_TO_PARTICIPANTS (10M tokens) + const finalBalance = await this.getTokenBalance(META, this.payer.publicKey); + const expectedTokens = new BN(10_000_000 * 10 ** 6); + assert.equal(finalBalance.toString(), expectedTokens.toString()); + + // Verify funding record state + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal(fundingRecordAccount.isTokensClaimed, true); + assert.equal(fundingRecordAccount.isUsdcRefunded, false); + assert.ok(fundingRecordAccount.funder.equals(this.payer.publicKey)); + assert.ok(fundingRecordAccount.launch.equals(launch)); + }); + + it("fails when launch is not complete", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); + + // Fund but don't close/approve/settle + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + try { + await launchpadClient.claimIx({ launch, baseMint: META }).rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "InvalidLaunchState"); + } + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index b5644ea2c..fb8b07758 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,12 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.5 Write `claim` tests (tests #37–38) - - Test #37: "successfully claims tokens after launch completion" - - Test #38: "fails when launch is not complete" - - Verify: `anchor test --skip-build` (with `.only`) - -- [ ] 6.6 Write `refund` tests (tests #39–41) +- [NEXT] 6.6 Write `refund` tests (tests #39–41) - Test #39: "allows refunds when launch is in refunding state" - Test #40: "works for oversubscribed launches" - Test #41: "fails when launch is not in refunding or complete state" From 19a14475133e7c72e9dd9bb1e99fd1a584ed9eea Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:38:46 +0200 Subject: [PATCH 063/100] refund tests --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/refund.test.ts | 233 +++++++++++++++++++++++++ vibes/tasks.md | 8 +- 3 files changed, 236 insertions(+), 7 deletions(-) create mode 100644 tests/launchpad_v8/unit/refund.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index 2a5ce4368..e4bd32541 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -12,6 +12,7 @@ import closeLaunch from "./unit/closeLaunch.test.js"; import setFundingRecordApproval from "./unit/setFundingRecordApproval.test.js"; import settleLaunch from "./unit/settleLaunch.test.js"; import claim from "./unit/claim.test.js"; +import refund from "./unit/refund.test.js"; export default function suite() { before(async function () { @@ -78,4 +79,5 @@ export default function suite() { describe("#set_funding_record_approval", setFundingRecordApproval); describe("#settle_launch", settleLaunch); describe("#claim", claim); + describe("#refund", refund); } diff --git a/tests/launchpad_v8/unit/refund.test.ts b/tests/launchpad_v8/unit/refund.test.ts new file mode 100644 index 000000000..f6d51c1e3 --- /dev/null +++ b/tests/launchpad_v8/unit/refund.test.ts @@ -0,0 +1,233 @@ +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { + LaunchpadClient, + getFundingRecordAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { createLookupTableForTransaction } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + async function settleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey | null; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + await context.banksClient.processTransaction(tx); + } + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await this.createTokenAccount(META, this.payer.publicKey); + }); + + it("allows refunds when launch is in refunding state", async function () { + // Fund below minimum raise so close_launch sets Refunding + const fundAmount = new BN(50_000 * 10 ** 6); // 50k USDC (below 100k minimum) + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + // Advance past launch period and close + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Verify launch is in Refunding state + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { refunding: {} }); + + const initialUsdcBalance = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + + // Refund + await launchpadClient.refundIx({ launch }).rpc(); + + const finalUsdcBalance = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + + // Full committed amount refunded + assert.equal( + (finalUsdcBalance - initialUsdcBalance).toString(), + fundAmount.toString(), + ); + + // Verify funding record + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal(fundingRecordAccount.isUsdcRefunded, true); + }); + + it("works for oversubscribed launches", async function () { + // Fund more than minimum + const fundAmount = new BN(200_000 * 10 ** 6); // 200k USDC + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + // Advance past launch period and close + await this.advanceBySeconds(secondsForLaunch + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + // Approve only 150k of the 200k + const approvedAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + approvedAmount, + funder: this.payer.publicKey, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + // Settle — transitions to Complete + await settleViaLut( + this, + launchpadClient, + { + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }, + [launchAuthority], + ); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + + const initialUsdcBalance = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + + // Refund — should get committed - approved = 50k + await launchpadClient.refundIx({ launch }).rpc(); + + const finalUsdcBalance = await this.getTokenBalance( + MAINNET_USDC, + this.payer.publicKey, + ); + + const expectedRefund = fundAmount.sub(approvedAmount); // 200k - 150k = 50k + assert.equal( + (finalUsdcBalance - initialUsdcBalance).toString(), + expectedRefund.toString(), + ); + + // Verify funding record + const [fundingRecord] = getFundingRecordAddr( + launchpadClient.getProgramId(), + launch, + this.payer.publicKey, + ); + const fundingRecordAccount = + await launchpadClient.fetchFundingRecord(fundingRecord); + assert.equal(fundingRecordAccount.isUsdcRefunded, true); + }); + + it("fails when launch is not in refunding or complete state", async function () { + // Fund but don't close — launch is still in Funding state + const fundAmount = new BN(150_000 * 10 ** 6); + + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + try { + await launchpadClient.refundIx({ launch }).rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "LaunchNotRefunding"); + } + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index fb8b07758..bdaec8f32 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,13 +49,7 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.6 Write `refund` tests (tests #39–41) - - Test #39: "allows refunds when launch is in refunding state" - - Test #40: "works for oversubscribed launches" - - Test #41: "fails when launch is not in refunding or complete state" - - Verify: `anchor test --skip-build` (with `.only`) - -- [ ] 6.7 Write `claimAdditionalTokenAllocation` tests (tests #42–43) +- [NEXT] 6.7 Write `claimAdditionalTokenAllocation` tests (tests #42–43) - Test #42: "sets and claims additional token allocation successfully, and only once" - Test #43: "fails to claim additional token allocation if the launch doesn't have one" - Verify: `anchor test --skip-build` (with `.only`) From 1a27284c4d76c701f9e9fe0fe89a4e12efefb29e Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:46:35 +0200 Subject: [PATCH 064/100] claim additional tokens tests --- tests/launchpad_v8/main.test.ts | 5 + .../claimAdditionalTokenAllocation.test.ts | 245 ++++++++++++++++++ vibes/tasks.md | 7 +- 3 files changed, 251 insertions(+), 6 deletions(-) create mode 100644 tests/launchpad_v8/unit/claimAdditionalTokenAllocation.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index e4bd32541..d407ae9ba 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -13,6 +13,7 @@ import setFundingRecordApproval from "./unit/setFundingRecordApproval.test.js"; import settleLaunch from "./unit/settleLaunch.test.js"; import claim from "./unit/claim.test.js"; import refund from "./unit/refund.test.js"; +import claimAdditionalTokenAllocation from "./unit/claimAdditionalTokenAllocation.test.js"; export default function suite() { before(async function () { @@ -80,4 +81,8 @@ export default function suite() { describe("#settle_launch", settleLaunch); describe("#claim", claim); describe("#refund", refund); + describe( + "#claim_additional_token_allocation", + claimAdditionalTokenAllocation, + ); } diff --git a/tests/launchpad_v8/unit/claimAdditionalTokenAllocation.test.ts b/tests/launchpad_v8/unit/claimAdditionalTokenAllocation.test.ts new file mode 100644 index 000000000..912897a18 --- /dev/null +++ b/tests/launchpad_v8/unit/claimAdditionalTokenAllocation.test.ts @@ -0,0 +1,245 @@ +import { + ComputeBudgetProgram, + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { createLookupTableForTransaction } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + async function settleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + await context.banksClient.processTransaction(tx); + } + + async function setupFundCloseApproveSettle( + context: any, + client: LaunchpadClient, + opts: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: Keypair; + fundAmount: BN; + }, + ) { + await client + .fundIx({ + launch: opts.launch, + amount: opts.fundAmount, + payer: context.payer.publicKey, + }) + .rpc(); + + await context.advanceBySeconds(secondsForLaunch + 1); + + await client.closeLaunchIx({ launch: opts.launch }).rpc(); + + await client + .setFundingRecordApprovalIx({ + launch: opts.launch, + approvedAmount: opts.fundAmount, + funder: context.payer.publicKey, + launchAuthority: opts.launchAuthority.publicKey, + }) + .signers([opts.launchAuthority]) + .rpc(); + + await settleViaLut( + context, + client, + { + launch: opts.launch, + baseMint: opts.baseMint, + launchAuthority: opts.launchAuthority.publicKey, + }, + [opts.launchAuthority], + ); + } + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + }); + + it("sets and claims additional token allocation successfully, and only once", async function () { + const additionalTokensRecipient = new Keypair(); + const additionalTokensAmount = new BN(1_000_000 * 10 ** 6); // 1M tokens + + // Initialize with additional tokens recipient and amount + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: new BN(100_000 * 10 ** 6), + secondsForLaunch, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount: new BN(10_000 * 10 ** 6), + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount: new BN(5_000_000 * 10 ** 6), + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + additionalTokensAmount, + hasBidWall: false, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await this.createTokenAccount(META, this.payer.publicKey); + + await setupFundCloseApproveSettle(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount: new BN(150_000 * 10 ** 6), + }); + + // Verify launch is complete with additional tokens unclaimed + const launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + assert.equal(launchAccount.additionalTokensClaimed, false); + + // Claim additional tokens + await launchpadClient + .claimAdditionalTokenAllocationIx({ + launch, + baseMint: META, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + }) + .rpc(); + + // Verify tokens transferred to recipient + const recipientBalance = await this.getTokenBalance( + META, + additionalTokensRecipient.publicKey, + ); + assert.equal( + recipientBalance.toString(), + additionalTokensAmount.toString(), + ); + + // Verify state updated + const updatedLaunch = await launchpadClient.fetchLaunch(launch); + assert.equal(updatedLaunch.additionalTokensClaimed, true); + + // Try to claim again — should fail + try { + await launchpadClient + .claimAdditionalTokenAllocationIx({ + launch, + baseMint: META, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "AdditionalTokensAlreadyClaimed"); + } + }); + + it("fails to claim additional token allocation if the launch doesn't have one", async function () { + // Standard launch without additional tokens + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + await this.createTokenAccount(META, this.payer.publicKey); + + await setupFundCloseApproveSettle(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount: new BN(150_000 * 10 ** 6), + }); + + try { + await launchpadClient + .claimAdditionalTokenAllocationIx({ + launch, + baseMint: META, + additionalTokensRecipient: this.payer.publicKey, + }) + .rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "NoAdditionalTokensRecipientSet"); + } + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index bdaec8f32..5c59bd16b 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -49,16 +49,11 @@ > Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 -- [NEXT] 6.7 Write `claimAdditionalTokenAllocation` tests (tests #42–43) - - Test #42: "sets and claims additional token allocation successfully, and only once" - - Test #43: "fails to claim additional token allocation if the launch doesn't have one" - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 7: `finalize_launch` > Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" -- [ ] 7.1 Implement `finalize_launch` instruction (Rust) +- [NEXT] 7.1 Implement `finalize_launch` instruction (Rust) - Create `src/instructions/finalize_launch.rs` with `FinalizeLaunch` accounts struct, `validate()`, and `handle()` - Handler: compute tranches, CPI add_mint_authority (PP v2 PDA), CPI initialize_performance_package, CPI update_mint_governor_admin - Wire into `lib.rs` and `instructions/mod.rs` From 558fcb503bdcec87d6de923b7ae2b9a5a8bb620f Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:54:29 +0200 Subject: [PATCH 065/100] finalize launch ix --- .../src/instructions/finalize_launch.rs | 243 ++++++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 5 + sdk/src/v0.7/types/launchpad_v8.ts | 228 ++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 228 ++++++++++++++++ vibes/tasks.md | 8 +- 6 files changed, 707 insertions(+), 7 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/finalize_launch.rs diff --git a/programs/v08_launchpad/src/instructions/finalize_launch.rs b/programs/v08_launchpad/src/instructions/finalize_launch.rs new file mode 100644 index 000000000..96ecf238b --- /dev/null +++ b/programs/v08_launchpad/src/instructions/finalize_launch.rs @@ -0,0 +1,243 @@ +use anchor_lang::prelude::*; +use anchor_spl::token::{Mint, Token}; + +use mint_governor::{ + cpi::{ + accounts::{AddMintAuthority, UpdateMintGovernorAdmin}, + add_mint_authority, update_mint_governor_admin, + }, + program::MintGovernor as MintGovernorProgram, + state::MintGovernor, + AddMintAuthorityArgs, +}; + +use performance_package_v2::{ + cpi::{ + accounts::InitializePerformancePackage as InitializePerformancePackageCpi, + initialize_performance_package, + }, + program::PerformancePackageV2, + InitializePerformancePackageArgs, OracleReader, RewardFunction, ThresholdTranche, +}; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchFinalizedEvent}; +use crate::state::{Launch, LaunchState}; +use crate::{ + PP_NUM_TRANCHES, PP_PRICE_MULTIPLIERS, PP_TWAP_MIN_DURATION, PRICE_SCALE, + TOKENS_TO_PARTICIPANTS, +}; + +#[event_cpi] +#[derive(Accounts)] +pub struct FinalizeLaunch<'info> { + #[account( + mut, + has_one = launch_signer, + has_one = base_mint, + has_one = mint_governor, + has_one = performance_package_grantee, + constraint = launch.dao == Some(dao.key()) @ LaunchpadError::InvalidDao, + )] + pub launch: Box>, + + #[account(mut)] + pub payer: Signer<'info>, + + /// CHECK: validated via has_one on launch + pub launch_signer: UncheckedAccount<'info>, + + #[account(address = launch.base_mint)] + pub base_mint: Account<'info, Mint>, + + // DAO / Squads + /// CHECK: validated via constraint on launch.dao + pub dao: UncheckedAccount<'info>, + + /// CHECK: PDA derived from squads program + #[account( + seeds = [ + squads_multisig_program::SEED_PREFIX, + squads_multisig_program::SEED_MULTISIG, + dao.key().as_ref(), + ], + seeds::program = squads_program, + bump, + )] + pub squads_multisig: UncheckedAccount<'info>, + + /// CHECK: PDA derived from squads program + #[account( + seeds = [ + squads_multisig_program::SEED_PREFIX, + squads_multisig.key().as_ref(), + squads_multisig_program::SEED_VAULT, + 0_u8.to_le_bytes().as_ref(), + ], + seeds::program = squads_program, + bump, + )] + pub squads_multisig_vault: UncheckedAccount<'info>, + + /// CHECK: validated via has_one on launch + pub performance_package_grantee: UncheckedAccount<'info>, + + // MintGovernor + #[account(mut)] + pub mint_governor: Account<'info, MintGovernor>, + + /// MintAuthority for PP v2 PDA — initialized via CPI + /// PDA: seeds = [b"mint_authority", mint_governor, performance_package] + /// CHECK: initialized via CPI + #[account(mut)] + pub pp_mint_authority: UncheckedAccount<'info>, + + // Performance Package v2 + /// PP v2 account — initialized via CPI + /// PDA: seeds = [b"performance_package", launch_signer (create_key)] + /// CHECK: initialized via CPI + #[account(mut)] + pub performance_package: UncheckedAccount<'info>, + + // Programs + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub squads_program: Program<'info, squads_multisig_program::program::SquadsMultisigProgram>, + pub mint_governor_program: Program<'info, MintGovernorProgram>, + /// CHECK: checked by mint_governor program + pub mint_governor_event_authority: UncheckedAccount<'info>, + pub performance_package_v2_program: Program<'info, PerformancePackageV2>, + /// CHECK: checked by performance_package_v2 program + pub performance_package_v2_event_authority: UncheckedAccount<'info>, +} + +impl FinalizeLaunch<'_> { + pub fn validate(&self) -> Result<()> { + require!( + self.launch.state == LaunchState::Complete, + LaunchpadError::InvalidLaunchState + ); + require!( + !self.launch.is_performance_package_initialized, + LaunchpadError::PerformancePackageAlreadyInitialized + ); + Ok(()) + } + + pub fn handle(ctx: Context) -> Result<()> { + let launch_key = ctx.accounts.launch.key(); + let launch_signer_seeds = &[ + b"launch_signer", + launch_key.as_ref(), + &[ctx.accounts.launch.launch_signer_pda_bump], + ]; + let signer = &[&launch_signer_seeds[..]]; + + let launch_price = (ctx.accounts.launch.total_approved_amount as u128 * PRICE_SCALE) + / (TOKENS_TO_PARTICIPANTS as u128); + + // Build threshold tranches for PP v2 + let pp_token_amount = ctx.accounts.launch.performance_package_token_amount; + let mut tranches = Vec::with_capacity(PP_NUM_TRANCHES); + for (i, multiplier) in PP_PRICE_MULTIPLIERS.iter().enumerate() { + tranches.push(ThresholdTranche { + threshold: launch_price * multiplier, + cumulative_amount: pp_token_amount * (i as u64 + 1) / PP_NUM_TRANCHES as u64, + }); + } + + // CPI → mint_governor::add_mint_authority + add_mint_authority( + CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + AddMintAuthority { + mint_governor: ctx.accounts.mint_governor.to_account_info(), + mint_authority: ctx.accounts.pp_mint_authority.to_account_info(), + admin: ctx.accounts.launch_signer.to_account_info(), + authorized_minter: ctx.accounts.performance_package.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ), + AddMintAuthorityArgs { + max_total: Some(pp_token_amount), + }, + )?; + + // CPI → performance_package_v2::initialize_performance_package + let min_unlock_timestamp = ctx.accounts.launch.unix_timestamp_completed.unwrap() + + (ctx.accounts.launch.months_until_insiders_can_unlock as i64) * 30 * 24 * 60 * 60; + + initialize_performance_package( + CpiContext::new_with_signer( + ctx.accounts + .performance_package_v2_program + .to_account_info(), + InitializePerformancePackageCpi { + performance_package: ctx.accounts.performance_package.to_account_info(), + mint: ctx.accounts.base_mint.to_account_info(), + mint_governor: ctx.accounts.mint_governor.to_account_info(), + mint_authority: ctx.accounts.pp_mint_authority.to_account_info(), + create_key: ctx.accounts.launch_signer.to_account_info(), + authority: ctx.accounts.squads_multisig_vault.to_account_info(), + recipient: ctx.accounts.performance_package_grantee.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + event_authority: ctx + .accounts + .performance_package_v2_event_authority + .to_account_info(), + program: ctx + .accounts + .performance_package_v2_program + .to_account_info(), + }, + signer, + ), + InitializePerformancePackageArgs { + oracle_reader: OracleReader::FutarchyTwap { + amm: ctx.accounts.dao.key(), + min_duration: PP_TWAP_MIN_DURATION, + start_value: 0, + start_time: 0, + end_value: 0, + end_time: 0, + }, + reward_function: RewardFunction::Threshold { tranches }, + min_unlock_timestamp, + }, + )?; + + // CPI → mint_governor::update_mint_governor_admin + update_mint_governor_admin(CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + UpdateMintGovernorAdmin { + mint_governor: ctx.accounts.mint_governor.to_account_info(), + admin: ctx.accounts.launch_signer.to_account_info(), + new_admin: ctx.accounts.squads_multisig_vault.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ))?; + + let launch = &mut ctx.accounts.launch; + launch.is_performance_package_initialized = true; + launch.seq_num += 1; + + let clock = Clock::get()?; + emit_cpi!(LaunchFinalizedEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + performance_package: ctx.accounts.performance_package.key(), + mint_governor: ctx.accounts.mint_governor.key(), + mint_governor_new_admin: ctx.accounts.squads_multisig_vault.key(), + pp_mint_authority: ctx.accounts.pp_mint_authority.key(), + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index a8b541362..35ef6e97e 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,6 +1,7 @@ pub mod claim; pub mod claim_additional_token_allocation; pub mod close_launch; +pub mod finalize_launch; pub mod fund; pub mod initialize_launch; pub mod refund; @@ -11,6 +12,7 @@ pub mod start_launch; pub use claim::*; pub use claim_additional_token_allocation::*; pub use close_launch::*; +pub use finalize_launch::*; pub use fund::*; pub use initialize_launch::*; pub use refund::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index be3fbb438..ff7d6bad1 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -120,4 +120,9 @@ pub mod launchpad_v8 { ) -> Result<()> { ClaimAdditionalTokenAllocation::handle(ctx) } + + #[access_control(ctx.accounts.validate())] + pub fn finalize_launch(ctx: Context) -> Result<()> { + FinalizeLaunch::handle(ctx) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 7eb7d5894..58d7ac69d 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -698,6 +698,120 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "finalizeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageGrantee"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "ppMintAuthority"; + isMut: true; + isSigner: false; + docs: [ + "MintAuthority for PP v2 PDA — initialized via CPI", + 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', + ]; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + docs: [ + "PP v2 account — initialized via CPI", + 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', + ]; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageV2EventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2439,6 +2553,120 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "finalizeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageGrantee", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "ppMintAuthority", + isMut: true, + isSigner: false, + docs: [ + "MintAuthority for PP v2 PDA — initialized via CPI", + 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', + ], + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + docs: [ + "PP v2 account — initialized via CPI", + 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', + ], + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageV2Program", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageV2EventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 7eb7d5894..58d7ac69d 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -698,6 +698,120 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "finalizeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageGrantee"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernor"; + isMut: true; + isSigner: false; + }, + { + name: "ppMintAuthority"; + isMut: true; + isSigner: false; + docs: [ + "MintAuthority for PP v2 PDA — initialized via CPI", + 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', + ]; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + docs: [ + "PP v2 account — initialized via CPI", + 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', + ]; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorProgram"; + isMut: false; + isSigner: false; + }, + { + name: "mintGovernorEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "performancePackageV2EventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, ]; accounts: [ { @@ -2439,6 +2553,120 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "finalizeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageGrantee", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernor", + isMut: true, + isSigner: false, + }, + { + name: "ppMintAuthority", + isMut: true, + isSigner: false, + docs: [ + "MintAuthority for PP v2 PDA — initialized via CPI", + 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', + ], + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + docs: [ + "PP v2 account — initialized via CPI", + 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', + ], + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorProgram", + isMut: false, + isSigner: false, + }, + { + name: "mintGovernorEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageV2Program", + isMut: false, + isSigner: false, + }, + { + name: "performancePackageV2EventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, ], accounts: [ { diff --git a/vibes/tasks.md b/vibes/tasks.md index 5c59bd16b..135f227e7 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -53,13 +53,7 @@ > Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" -- [NEXT] 7.1 Implement `finalize_launch` instruction (Rust) - - Create `src/instructions/finalize_launch.rs` with `FinalizeLaunch` accounts struct, `validate()`, and `handle()` - - Handler: compute tranches, CPI add_mint_authority (PP v2 PDA), CPI initialize_performance_package, CPI update_mint_governor_admin - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 7.2 Add `finalizeLaunchIx` to SDK2 client +- [NEXT] 7.2 Add `finalizeLaunchIx` to SDK2 client - Add the instruction builder method per spec - Verify: `cd sdk2 && npx tsc --noEmit` From a6b3497ef2730cada5eb09dbecef1348b3db9022 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 02:59:02 +0200 Subject: [PATCH 066/100] finalize launch ix --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 72 ++++++++++++++++++++++ vibes/tasks.md | 6 +- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index dbdfe2cb7..143814b5f 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -685,6 +685,78 @@ export class LaunchpadClient { }); } + finalizeLaunchIx({ + launch, + baseMint, + performancePackageGrantee, + payer = this.provider.publicKey, + }: { + launch: PublicKey; + baseMint: PublicKey; + performancePackageGrantee: PublicKey; + payer?: PublicKey; + }) { + const launchSigner = this.getLaunchSignerAddress({ launch }); + + const [dao] = getDaoAddr({ + nonce: new BN(0), + daoCreator: launchSigner, + }); + + const [squadsMultisig] = multisig.getMultisigPda({ createKey: dao }); + const [squadsMultisigVault] = multisig.getVaultPda({ + multisigPda: squadsMultisig, + index: 0, + }); + + const [mintGovernor] = getMintGovernorAddr({ + programId: this.mintGovernorClient.programId, + mint: baseMint, + createKey: launchSigner, + }); + + const performancePackage = getPerformancePackageV2Addr({ + createKey: launchSigner, + })[0]; + + const [ppMintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: performancePackage, + }); + + const [mintGovernorEventAuthority] = getEventAuthorityAddr( + this.mintGovernorClient.programId, + ); + const [performancePackageV2EventAuthority] = getEventAuthorityAddr( + this.performancePackageV2.programId, + ); + + return this.launchpad.methods + .finalizeLaunch() + .accounts({ + launch, + payer, + launchSigner, + baseMint, + dao, + squadsMultisig, + squadsMultisigVault, + performancePackageGrantee, + mintGovernor, + ppMintAuthority, + performancePackage, + squadsProgram: SQUADS_PROGRAM_ID, + mintGovernorProgram: this.mintGovernorClient.programId, + mintGovernorEventAuthority, + performancePackageV2Program: this.performancePackageV2.programId, + performancePackageV2EventAuthority, + }) + .preInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 }), + ]); + } + claimAdditionalTokenAllocationIx({ launch, baseMint, diff --git a/vibes/tasks.md b/vibes/tasks.md index 135f227e7..6c14ed27c 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -53,11 +53,7 @@ > Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" -- [NEXT] 7.2 Add `finalizeLaunchIx` to SDK2 client - - Add the instruction builder method per spec - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 7.3 Write `finalizeLaunch` tests (tests #34–36) +- [NEXT] 7.3 Write `finalizeLaunch` tests (tests #34–36) - Test #34: happy path — PP v2 setup (tranches, oracle, recipient, authority), MintGovernor admin transferred to DAO - Test #35: "fails when launch state is not Complete" - Test #36: "can finalize only once" From d424b1925438676ecc11263f5c87ac4687b81fbf Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:06:02 +0200 Subject: [PATCH 067/100] finalize launch tests --- tests/launchpad_v8/main.test.ts | 2 + .../launchpad_v8/unit/finalizeLaunch.test.ts | 276 ++++++++++++++++++ vibes/tasks.md | 8 +- 3 files changed, 279 insertions(+), 7 deletions(-) create mode 100644 tests/launchpad_v8/unit/finalizeLaunch.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index d407ae9ba..ed9a0cba7 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -14,6 +14,7 @@ import settleLaunch from "./unit/settleLaunch.test.js"; import claim from "./unit/claim.test.js"; import refund from "./unit/refund.test.js"; import claimAdditionalTokenAllocation from "./unit/claimAdditionalTokenAllocation.test.js"; +import finalizeLaunch from "./unit/finalizeLaunch.test.js"; export default function suite() { before(async function () { @@ -85,4 +86,5 @@ export default function suite() { "#claim_additional_token_allocation", claimAdditionalTokenAllocation, ); + describe("#finalize_launch", finalizeLaunch); } diff --git a/tests/launchpad_v8/unit/finalizeLaunch.test.ts b/tests/launchpad_v8/unit/finalizeLaunch.test.ts new file mode 100644 index 000000000..00ddc7c50 --- /dev/null +++ b/tests/launchpad_v8/unit/finalizeLaunch.test.ts @@ -0,0 +1,276 @@ +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, + ComputeBudgetProgram, +} from "@solana/web3.js"; +import * as multisig from "@sqds/multisig"; +import { assert } from "chai"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { createLookupTableForTransaction } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + const secondsForLaunch = 60 * 60 * 24 * 4; // 4 days + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + async function settleViaLut( + context: any, + client: LaunchpadClient, + params: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: PublicKey; + }, + additionalSigners: Keypair[] = [], + ) { + const settleTx = await client + .settleLaunchIx({ + launch: params.launch, + baseMint: params.baseMint, + launchAuthority: params.launchAuthority, + }) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, context); + + const message = new TransactionMessage({ + payerKey: context.payer.publicKey, + recentBlockhash: (await context.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const tx = new VersionedTransaction(message); + tx.sign([context.payer, ...additionalSigners]); + + await context.banksClient.processTransaction(tx); + } + + async function setupFundCloseApproveSettle( + context: any, + client: LaunchpadClient, + opts: { + launch: PublicKey; + baseMint: PublicKey; + launchAuthority: Keypair; + fundAmount: BN; + }, + ) { + // Fund + await client + .fundIx({ + launch: opts.launch, + amount: opts.fundAmount, + payer: context.payer.publicKey, + }) + .rpc(); + + // Advance past launch period + await context.advanceBySeconds(secondsForLaunch + 1); + + // Close + await client.closeLaunchIx({ launch: opts.launch }).rpc(); + + // Approve + await client + .setFundingRecordApprovalIx({ + launch: opts.launch, + approvedAmount: opts.fundAmount, + funder: context.payer.publicKey, + launchAuthority: opts.launchAuthority.publicKey, + }) + .signers([opts.launchAuthority]) + .rpc(); + + // Settle + await settleViaLut( + context, + client, + { + launch: opts.launch, + baseMint: opts.baseMint, + launchAuthority: opts.launchAuthority.publicKey, + }, + [opts.launchAuthority], + ); + } + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + }); + + it("finalizes launch with PP v2 setup and MintGovernor admin transfer to DAO", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); // 150k USDC + + await setupFundCloseApproveSettle(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + // Verify launch is Complete before finalize + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + assert.equal(launchAccount.isPerformancePackageInitialized, false); + + // Finalize + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: launchAccount.performancePackageGrantee, + }) + .rpc(); + + // Reload launch state + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal(launchAccount.isPerformancePackageInitialized, true); + + // Derive expected addresses + const mintGovernorAddr = launchpadClient.getMintGovernorAddress({ + baseMint: META, + launchSigner, + }); + const daoAddr = launchpadClient.getLaunchDaoAddress({ launch }); + const [squadsMultisig] = multisig.getMultisigPda({ createKey: daoAddr }); + const [squadsMultisigVault] = multisig.getVaultPda({ + multisigPda: squadsMultisig, + index: 0, + }); + + // Verify MintGovernor admin transferred to DAO (squads_multisig_vault) + const mintGovernorAccount = + await launchpadClient.mintGovernorClient.fetchMintGovernor( + mintGovernorAddr, + ); + assert.ok(mintGovernorAccount.admin.equals(squadsMultisigVault)); + + // Verify PP v2 MintAuthority was created for the performance package + const performancePackageAddr = + launchpadClient.getLaunchPerformancePackageAddress({ launch }); + const ppMintAuthorityAddr = launchpadClient.getMintAuthorityAddress({ + mintGovernor: mintGovernorAddr, + authorizedMinter: performancePackageAddr, + }); + const ppMintAuthorityAccount = + await launchpadClient.mintGovernorClient.fetchMintAuthority( + ppMintAuthorityAddr, + ); + assert.ok( + ppMintAuthorityAccount.authorizedMinter.equals(performancePackageAddr), + ); + // max_total = performance_package_token_amount (5M tokens) + const expectedPPMaxTotal = new BN(5_000_000 * 10 ** 6); + assert.equal( + ppMintAuthorityAccount.maxTotal.toString(), + expectedPPMaxTotal.toString(), + ); + + // Verify PP v2 account was initialized + const ppAccount = + await launchpadClient.performancePackageV2.fetchPerformancePackage( + performancePackageAddr, + ); + assert.isNotNull(ppAccount); + + // PP authority should be squads_multisig_vault (DAO controls it) + assert.ok(ppAccount.authority.equals(squadsMultisigVault)); + + // PP recipient should be the performance_package_grantee + assert.ok( + ppAccount.recipient.equals(launchAccount.performancePackageGrantee), + ); + }); + + it("fails when launch state is not Complete", async function () { + // Launch is in Live state — don't fund/close/settle + // The DAO constraint fires before validate() since launch.dao is None + try { + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: this.payer.publicKey, + }) + .rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "InvalidDao"); + } + }); + + it("can finalize only once", async function () { + const fundAmount = new BN(150_000 * 10 ** 6); + + await setupFundCloseApproveSettle(this, launchpadClient, { + launch, + baseMint: META, + launchAuthority, + fundAmount, + }); + + const launchAccount = await launchpadClient.fetchLaunch(launch); + + // First finalize succeeds + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: launchAccount.performancePackageGrantee, + }) + .rpc(); + + // Second finalize fails + try { + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: launchAccount.performancePackageGrantee, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 }), + ]) + .rpc(); + assert.fail("Should have thrown error"); + } catch (e) { + assert.include(e.message, "PerformancePackageAlreadyInitialized"); + } + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index 6c14ed27c..fc4d904f6 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -53,17 +53,11 @@ > Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" -- [NEXT] 7.3 Write `finalizeLaunch` tests (tests #34–36) - - Test #34: happy path — PP v2 setup (tranches, oracle, recipient, authority), MintGovernor admin transferred to DAO - - Test #35: "fails when launch state is not Complete" - - Test #36: "can finalize only once" - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 8: `extend_launch` > Reference: `launchpad_v8_spec.md` → instruction 11 -- [ ] 8.1 Implement `extend_launch` instruction (Rust) +- [NEXT] 8.1 Implement `extend_launch` instruction (Rust) - Create `src/instructions/extend_launch.rs` — port from v7 - Wire into `lib.rs` and `instructions/mod.rs` - Verify: `./rebuild.sh` From 5a8529774d0b9c1c40fd0b94df490f1247882204 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:10:06 +0200 Subject: [PATCH 068/100] extend launch ix --- .../src/instructions/extend_launch.rs | 69 ++++++++++++++ .../v08_launchpad/src/instructions/mod.rs | 2 + programs/v08_launchpad/src/lib.rs | 5 ++ sdk/src/v0.7/types/launchpad_v8.ts | 90 +++++++++++++++++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 90 +++++++++++++++++++ vibes/tasks.md | 7 +- 6 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 programs/v08_launchpad/src/instructions/extend_launch.rs diff --git a/programs/v08_launchpad/src/instructions/extend_launch.rs b/programs/v08_launchpad/src/instructions/extend_launch.rs new file mode 100644 index 000000000..6e4f891f9 --- /dev/null +++ b/programs/v08_launchpad/src/instructions/extend_launch.rs @@ -0,0 +1,69 @@ +use anchor_lang::prelude::*; + +use crate::error::LaunchpadError; +use crate::events::{CommonFields, LaunchExtendedEvent}; +use crate::state::{Launch, LaunchState}; + +#[cfg(feature = "production")] +use crate::metadao_multisig_vault; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct ExtendLaunchArgs { + pub duration_seconds: u32, +} + +#[event_cpi] +#[derive(Accounts)] +pub struct ExtendLaunch<'info> { + #[account(mut)] + pub launch: Account<'info, Launch>, + + pub admin: Signer<'info>, +} + +impl ExtendLaunch<'_> { + pub fn validate(&self, args: &ExtendLaunchArgs) -> Result<()> { + #[cfg(feature = "production")] + require_keys_eq!(self.admin.key(), metadao_multisig_vault::ID); + + require!( + self.launch.state == LaunchState::Live, + LaunchpadError::InvalidLaunchState + ); + + require_gt!(args.duration_seconds, 0, LaunchpadError::InvalidAmount); + + require!( + self.launch + .seconds_for_launch + .checked_add(args.duration_seconds) + .is_some(), + LaunchpadError::ExtendDurationExceedsMax + ); + + Ok(()) + } + + pub fn handle(ctx: Context, args: ExtendLaunchArgs) -> Result<()> { + let launch = &mut ctx.accounts.launch; + let clock = Clock::get()?; + + let old_seconds_for_launch = launch.seconds_for_launch; + + launch.seconds_for_launch = launch + .seconds_for_launch + .checked_add(args.duration_seconds) + .unwrap(); + + launch.seq_num += 1; + + emit_cpi!(LaunchExtendedEvent { + common: CommonFields::new(&clock, launch.seq_num), + launch: launch.key(), + old_seconds_for_launch, + new_seconds_for_launch: launch.seconds_for_launch, + }); + + Ok(()) + } +} diff --git a/programs/v08_launchpad/src/instructions/mod.rs b/programs/v08_launchpad/src/instructions/mod.rs index 35ef6e97e..854175d2f 100644 --- a/programs/v08_launchpad/src/instructions/mod.rs +++ b/programs/v08_launchpad/src/instructions/mod.rs @@ -1,6 +1,7 @@ pub mod claim; pub mod claim_additional_token_allocation; pub mod close_launch; +pub mod extend_launch; pub mod finalize_launch; pub mod fund; pub mod initialize_launch; @@ -12,6 +13,7 @@ pub mod start_launch; pub use claim::*; pub use claim_additional_token_allocation::*; pub use close_launch::*; +pub use extend_launch::*; pub use finalize_launch::*; pub use fund::*; pub use initialize_launch::*; diff --git a/programs/v08_launchpad/src/lib.rs b/programs/v08_launchpad/src/lib.rs index ff7d6bad1..273f4bca9 100644 --- a/programs/v08_launchpad/src/lib.rs +++ b/programs/v08_launchpad/src/lib.rs @@ -125,4 +125,9 @@ pub mod launchpad_v8 { pub fn finalize_launch(ctx: Context) -> Result<()> { FinalizeLaunch::handle(ctx) } + + #[access_control(ctx.accounts.validate(&args))] + pub fn extend_launch(ctx: Context, args: ExtendLaunchArgs) -> Result<()> { + ExtendLaunch::handle(ctx, args) + } } diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 58d7ac69d..1b016e0eb 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -812,6 +812,39 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "extendLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ExtendLaunchArgs"; + }; + }, + ]; + }, ]; accounts: [ { @@ -1111,6 +1144,18 @@ export type LaunchpadV8 = { ]; }; }, + { + name: "ExtendLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "durationSeconds"; + type: "u32"; + }, + ]; + }; + }, { name: "InitializeLaunchArgs"; type: { @@ -2667,6 +2712,39 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "extendLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ExtendLaunchArgs", + }, + }, + ], + }, ], accounts: [ { @@ -2966,6 +3044,18 @@ export const IDL: LaunchpadV8 = { ], }, }, + { + name: "ExtendLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "durationSeconds", + type: "u32", + }, + ], + }, + }, { name: "InitializeLaunchArgs", type: { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 58d7ac69d..1b016e0eb 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -812,6 +812,39 @@ export type LaunchpadV8 = { ]; args: []; }, + { + name: "extendLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "ExtendLaunchArgs"; + }; + }, + ]; + }, ]; accounts: [ { @@ -1111,6 +1144,18 @@ export type LaunchpadV8 = { ]; }; }, + { + name: "ExtendLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "durationSeconds"; + type: "u32"; + }, + ]; + }; + }, { name: "InitializeLaunchArgs"; type: { @@ -2667,6 +2712,39 @@ export const IDL: LaunchpadV8 = { ], args: [], }, + { + name: "extendLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "ExtendLaunchArgs", + }, + }, + ], + }, ], accounts: [ { @@ -2966,6 +3044,18 @@ export const IDL: LaunchpadV8 = { ], }, }, + { + name: "ExtendLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "durationSeconds", + type: "u32", + }, + ], + }, + }, { name: "InitializeLaunchArgs", type: { diff --git a/vibes/tasks.md b/vibes/tasks.md index fc4d904f6..86f122233 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -57,12 +57,7 @@ > Reference: `launchpad_v8_spec.md` → instruction 11 -- [NEXT] 8.1 Implement `extend_launch` instruction (Rust) - - Create `src/instructions/extend_launch.rs` — port from v7 - - Wire into `lib.rs` and `instructions/mod.rs` - - Verify: `./rebuild.sh` - -- [ ] 8.2 Add `extendLaunchIx` to SDK2 client +- [NEXT] 8.2 Add `extendLaunchIx` to SDK2 client - Port from v7 SDK2 client - Verify: `cd sdk2 && npx tsc --noEmit` From 4e302bcb191b0361121ce82192843c46213df1e6 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:15:40 +0200 Subject: [PATCH 069/100] exten launch sdk --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 15 +++++++++++++++ vibes/tasks.md | 6 +----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 143814b5f..192d967b8 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -788,4 +788,19 @@ export class LaunchpadClient { ), }); } + + extendLaunchIx({ + launch, + durationSeconds, + admin = METADAO_MULTISIG_VAULT, + }: { + launch: PublicKey; + durationSeconds: number; + admin?: PublicKey; + }) { + return this.launchpad.methods.extendLaunch({ durationSeconds }).accounts({ + launch, + admin, + }); + } } diff --git a/vibes/tasks.md b/vibes/tasks.md index 86f122233..697497465 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -57,11 +57,7 @@ > Reference: `launchpad_v8_spec.md` → instruction 11 -- [NEXT] 8.2 Add `extendLaunchIx` to SDK2 client - - Port from v7 SDK2 client - - Verify: `cd sdk2 && npx tsc --noEmit` - -- [ ] 8.3 Write `extendLaunch` tests (tests #44–46) +- [NEXT] 8.3 Write `extendLaunch` tests (tests #44–46) - Test #44: "successfully extends a live launch" - Test #45: "funders can still fund after original deadline if extended" - Test #46: "close_launch respects new extended deadline" From 4a99d9576651195b9367b0d9ff586c81f930aaf6 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:20:58 +0200 Subject: [PATCH 070/100] extend launch tests --- tests/launchpad_v8/main.test.ts | 2 + tests/launchpad_v8/unit/extendLaunch.test.ts | 146 +++++++++++++++++++ vibes/tasks.md | 8 +- 3 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 tests/launchpad_v8/unit/extendLaunch.test.ts diff --git a/tests/launchpad_v8/main.test.ts b/tests/launchpad_v8/main.test.ts index ed9a0cba7..40082d339 100644 --- a/tests/launchpad_v8/main.test.ts +++ b/tests/launchpad_v8/main.test.ts @@ -15,6 +15,7 @@ import claim from "./unit/claim.test.js"; import refund from "./unit/refund.test.js"; import claimAdditionalTokenAllocation from "./unit/claimAdditionalTokenAllocation.test.js"; import finalizeLaunch from "./unit/finalizeLaunch.test.js"; +import extendLaunch from "./unit/extendLaunch.test.js"; export default function suite() { before(async function () { @@ -87,4 +88,5 @@ export default function suite() { claimAdditionalTokenAllocation, ); describe("#finalize_launch", finalizeLaunch); + describe("#extend_launch", extendLaunch); } diff --git a/tests/launchpad_v8/unit/extendLaunch.test.ts b/tests/launchpad_v8/unit/extendLaunch.test.ts new file mode 100644 index 000000000..35e4b5788 --- /dev/null +++ b/tests/launchpad_v8/unit/extendLaunch.test.ts @@ -0,0 +1,146 @@ +import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; +import { assert } from "chai"; +import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import { BN } from "bn.js"; +import { initializeMintWithSeeds } from "../utils.js"; +import { expectError } from "../../utils.js"; + +export default function suite() { + let launchpadClient: LaunchpadClient; + let META: PublicKey; + let launch: PublicKey; + let launchSigner: PublicKey; + let launchAuthority: Keypair; + + before(async function () { + launchpadClient = this.launchpad_v8; + }); + + beforeEach(async function () { + const result = await initializeMintWithSeeds( + this.banksClient, + this.launchpad_v8, + this.payer, + ); + + META = result.tokenMint; + launch = result.launch; + launchSigner = result.launchSigner; + launchAuthority = new Keypair(); + + await this.setupBasicLaunch({ + baseMint: META, + founders: [this.payer.publicKey], + launchAuthority: launchAuthority.publicKey, + }); + + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + }); + + it("successfully extends a live launch", async function () { + const launchBefore = await launchpadClient.fetchLaunch(launch); + const originalSeconds = launchBefore.secondsForLaunch; + + const extensionSeconds = 60 * 60 * 24; // 1 day + + await launchpadClient + .extendLaunchIx({ + launch, + durationSeconds: extensionSeconds, + admin: this.payer.publicKey, + }) + .rpc(); + + const launchAfter = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAfter.secondsForLaunch, + originalSeconds + extensionSeconds, + ); + }); + + it("funders can still fund after original deadline if extended", async function () { + const launchAccount = await launchpadClient.fetchLaunch(launch); + const originalSeconds = launchAccount.secondsForLaunch; + + const extensionSeconds = 60 * 60 * 24 * 2; // 2 days + + await launchpadClient + .extendLaunchIx({ + launch, + durationSeconds: extensionSeconds, + admin: this.payer.publicKey, + }) + .rpc(); + + // Advance past the original deadline but before the new one + await this.advanceBySeconds(originalSeconds + 100); + + const fundAmount = new BN(100 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + const updatedLaunch = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(updatedLaunch.state, { live: {} }); + }); + + it("close_launch respects new extended deadline", async function () { + const launchAccount = await launchpadClient.fetchLaunch(launch); + const originalSeconds = launchAccount.secondsForLaunch; + + const extensionSeconds = 60 * 60 * 24 * 2; // 2 days + + await launchpadClient + .extendLaunchIx({ + launch, + durationSeconds: extensionSeconds, + admin: this.payer.publicKey, + }) + .rpc(); + + const fundAmount = new BN(150_000 * 10 ** 6); + await launchpadClient + .fundIx({ + launch, + amount: fundAmount, + payer: this.payer.publicKey, + }) + .rpc(); + + // Advance past original deadline but before new deadline — close should fail + await this.advanceBySeconds(originalSeconds + 100); + + const callbacks = expectError( + "LaunchPeriodNotOver", + "Should have rejected closing before extended deadline", + ); + + await launchpadClient + .closeLaunchIx({ launch }) + .rpc() + .then(callbacks[0], callbacks[1]); + + // Advance past the new extended deadline — close should succeed + await this.advanceBySeconds(extensionSeconds); + + await launchpadClient + .closeLaunchIx({ launch }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_001 }), + ]) + .rpc(); + + const updatedLaunch = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(updatedLaunch.state, { closed: {} }); + }); +} diff --git a/vibes/tasks.md b/vibes/tasks.md index 697497465..b2e6ba08a 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -57,17 +57,11 @@ > Reference: `launchpad_v8_spec.md` → instruction 11 -- [NEXT] 8.3 Write `extendLaunch` tests (tests #44–46) - - Test #44: "successfully extends a live launch" - - Test #45: "funders can still fund after original deadline if extended" - - Test #46: "close_launch respects new extended deadline" - - Verify: `anchor test --skip-build` (with `.only`) - ### Phase 9: Integration + Full Suite > Reference: `launchpad_v8_spec.md` → "Integration Test" -- [ ] 9.1 Write integration test +- [NEXT] 9.1 Write integration test - Create `tests/integration/launchpad_v8_full_lifecycle.test.ts` - Full lifecycle: init → start → fund (multiple funders) → close → approve → settle → finalize → claim → refund → claim_additional - Verify: `anchor test --skip-build` (with `.only` on integration suite) From 1ce54c1a8d05ac1c0175fa0dda71624594576cc2 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:29:03 +0200 Subject: [PATCH 071/100] launchpad v8 integration test --- .../launchpad_v8_full_lifecycle.test.ts | 437 ++++++++++++++++++ tests/main.test.ts | 2 + vibes/tasks.md | 7 +- 3 files changed, 440 insertions(+), 6 deletions(-) create mode 100644 tests/integration/launchpad_v8_full_lifecycle.test.ts diff --git a/tests/integration/launchpad_v8_full_lifecycle.test.ts b/tests/integration/launchpad_v8_full_lifecycle.test.ts new file mode 100644 index 000000000..ec9b710d3 --- /dev/null +++ b/tests/integration/launchpad_v8_full_lifecycle.test.ts @@ -0,0 +1,437 @@ +import { + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { + MAINNET_USDC, + LAUNCHPAD_V0_8_PROGRAM_ID, + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/futarchy-v2"; +import { + LaunchpadClient, + getFundingRecordAddr, +} from "@metadaoproject/futarchy-v2/launchpad/v0.8"; +import * as multisig from "@sqds/multisig"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../launchpad_v8/utils.js"; +import { createLookupTableForTransaction } from "../utils.js"; + +export default async function suite() { + before(async function () { + const dynamicConfig = await this.banksClient.getAccount( + new PublicKey("4mPQ4VuvvtYL3CeMPt14Uj1CLpBWcVdJoLoTH9ea4Kod"), + ); + + // discriminator + vault config authority + const poolCreatorAuthorityOffset = 8 + 32; + // discriminator + vault config authority + pool creator authority + pool fees config + activation type + collect fee mode + const configTypeOffset = 8 + 32 + 32 + 128 + 1 + 1; + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + LAUNCHPAD_V0_8_PROGRAM_ID, + ); + + dynamicConfig.data.set( + poolCreatorAuthority.toBuffer(), + poolCreatorAuthorityOffset, + ); + dynamicConfig.data.set([1], configTypeOffset); + + this.context.setAccount( + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); + }); + + it("full lifecycle: init → start → fund → close → approve → settle → finalize → claim → refund → claim_additional", async function () { + const launchpadClient: LaunchpadClient = this.launchpad_v8; + + // Create funders and authorities + const funder1 = Keypair.generate(); + const funder2 = Keypair.generate(); + const funder3 = Keypair.generate(); + const launchAuthority = Keypair.generate(); + const additionalTokensRecipient = Keypair.generate(); + + const minRaise = new BN(300_000 * 10 ** 6); // 300k USDC + const launchPeriod = 60 * 60 * 24 * 2; // 2 days + const monthlySpendingLimitAmount = new BN(25_000 * 10 ** 6); + const performancePackageTokenAmount = new BN(5_000_000 * 10 ** 6); // 5M tokens + const additionalTokensAmount = new BN(1_000_000 * 10 ** 6); // 1M tokens + + // ===================== + // Setup: Create mint and derive addresses + // ===================== + const result = await initializeMintWithSeeds( + this.banksClient, + launchpadClient, + this.payer, + ); + + const META = result.tokenMint; + const launch = result.launch; + const launchSigner = result.launchSigner; + + // Setup USDC accounts for funders + await this.createTokenAccount(MAINNET_USDC, funder1.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder2.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder3.publicKey); + + await this.transfer( + MAINNET_USDC, + this.payer, + funder1.publicKey, + 500_000_000000, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder2.publicKey, + 200_000_000000, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder3.publicKey, + 400_000_000000, + ); + + // ===================== + // 1. initialize_launch + // ===================== + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: launchPeriod, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: this.payer.publicKey, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock: 24, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + additionalTokensAmount, + hasBidWall: false, + }) + .rpc(); + + // Verify: tokens minted at init, MintGovernor setup + // Supply = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens + // = 10M + 2M + 900k + 1M = 13.9M + let mint = await this.getMint(META); + const expectedInitSupply = + (10_000_000 + 2_000_000 + 900_000 + 1_000_000) * 10 ** 6; + assert.equal(Number(mint.supply), expectedInitSupply); + + let launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { initialized: {} }); + + const mintGovernorAddr = launchpadClient.getMintGovernorAddress({ + baseMint: META, + launchSigner, + }); + const mintGovernorAccount = + await launchpadClient.mintGovernorClient.fetchMintGovernor( + mintGovernorAddr, + ); + assert.ok(mintGovernorAccount.admin.equals(launchSigner)); + + // ===================== + // 2. start_launch + // ===================== + await launchpadClient + .startLaunchIx({ + launch, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .rpc(); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { live: {} }); + + // ===================== + // 3. fund (multiple funders) + // ===================== + // Funder1: 500k USDC + await launchpadClient + .fundIx({ + launch, + amount: new BN(500_000_000000), + funder: funder1.publicKey, + }) + .signers([funder1]) + .rpc(); + + // Funder2 (payer): 200k USDC + await launchpadClient + .fundIx({ + launch, + amount: new BN(200_000_000000), + funder: funder2.publicKey, + }) + .signers([funder2]) + .rpc(); + + // Funder3: 400k USDC + await launchpadClient + .fundIx({ + launch, + amount: new BN(400_000_000000), + funder: funder3.publicKey, + }) + .signers([funder3]) + .rpc(); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal( + launchAccount.totalCommittedAmount.toString(), + new BN(1_100_000_000000).toString(), + ); + + // ===================== + // 4. close_launch + // ===================== + await this.advanceBySeconds(launchPeriod + 1); + + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { closed: {} }); + + // ===================== + // 5. set_funding_record_approval (each funder, partial approvals) + // ===================== + // Approve 250k of funder1's 500k + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(250_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + + // Approve 100k of funder2's 200k + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder2.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(100_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + + // Approve 150k of funder3's 400k + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder3.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(150_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + + // Total approved: 250k + 100k + 150k = 500k (above 300k minimum) + + // ===================== + // 6. settle_launch → verify minting, DAO creation + // ===================== + const settleTx = await launchpadClient + .settleLaunchIx({ + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, this); + + const settleMessage = new TransactionMessage({ + payerKey: this.payer.publicKey, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const settleVersionedTx = new VersionedTransaction(settleMessage); + settleVersionedTx.sign([this.payer, launchAuthority]); + + await this.banksClient.processTransaction(settleVersionedTx); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.deepEqual(launchAccount.state, { complete: {} }); + assert.isNotNull(launchAccount.dao); + assert.isNotNull(launchAccount.daoVault); + assert.isNotNull(launchAccount.unixTimestampCompleted); + + // Supply unchanged from init (tokens were minted at initialize_launch) + mint = await this.getMint(META); + assert.equal(Number(mint.supply), expectedInitSupply); + + // Verify USDC distribution: 80% to treasury (no bid wall) + // Total approved = 500k, usdc_to_lp = 500k / 5 = 100k, usdc_to_dao = 400k + const treasuryUSDCBalance = await this.getTokenBalance( + MAINNET_USDC, + launchAccount.daoVault, + ); + assert.equal( + treasuryUSDCBalance.toString(), + new BN(400_000_000000).toString(), + ); + + // ===================== + // 7. finalize_launch → verify PP v2 setup, MintGovernor admin transfer + // ===================== + assert.equal(launchAccount.isPerformancePackageInitialized, false); + + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: launchAccount.performancePackageGrantee, + }) + .rpc(); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal(launchAccount.isPerformancePackageInitialized, true); + + // Verify MintGovernor admin transferred to DAO squads vault + const daoAddr = launchpadClient.getLaunchDaoAddress({ launch }); + const [squadsMultisig] = multisig.getMultisigPda({ createKey: daoAddr }); + const [squadsMultisigVault] = multisig.getVaultPda({ + multisigPda: squadsMultisig, + index: 0, + }); + + const updatedMintGovernor = + await launchpadClient.mintGovernorClient.fetchMintGovernor( + mintGovernorAddr, + ); + assert.ok(updatedMintGovernor.admin.equals(squadsMultisigVault)); + + // Verify PP v2 was initialized + const performancePackageAddr = + launchpadClient.getLaunchPerformancePackageAddress({ launch }); + const ppAccount = + await launchpadClient.performancePackageV2.fetchPerformancePackage( + performancePackageAddr, + ); + assert.isNotNull(ppAccount); + assert.ok(ppAccount.authority.equals(squadsMultisigVault)); + assert.ok( + ppAccount.recipient.equals(launchAccount.performancePackageGrantee), + ); + + // ===================== + // 8. claim (each funder) + // ===================== + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder1.publicKey }) + .rpc(); + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder2.publicKey }) + .rpc(); + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder3.publicKey }) + .rpc(); + + // Verify token distributions proportional to approved amounts + // Total approved = 500k, TOKENS_TO_PARTICIPANTS = 10M + // Funder1: 250k/500k * 10M = 5M tokens + // Funder2: 100k/500k * 10M = 2M tokens + // Funder3: 150k/500k * 10M = 3M tokens + const funder1Balance = await this.getTokenBalance(META, funder1.publicKey); + const funder2Balance = await this.getTokenBalance(META, funder2.publicKey); + const funder3Balance = await this.getTokenBalance(META, funder3.publicKey); + + assert.equal(funder1Balance, 5_000_000_000000n); + assert.equal(funder2Balance, 2_000_000_000000n); + assert.equal(funder3Balance, 3_000_000_000000n); + + // ===================== + // 9. refund (over-committed funders get back excess USDC) + // ===================== + const preRefundFunder1Quote = await this.getTokenBalance( + MAINNET_USDC, + funder1.publicKey, + ); + const preRefundFunder2Quote = await this.getTokenBalance( + MAINNET_USDC, + funder2.publicKey, + ); + const preRefundFunder3Quote = await this.getTokenBalance( + MAINNET_USDC, + funder3.publicKey, + ); + + await launchpadClient.refundIx({ launch, funder: funder1.publicKey }).rpc(); + await launchpadClient.refundIx({ launch, funder: funder2.publicKey }).rpc(); + await launchpadClient.refundIx({ launch, funder: funder3.publicKey }).rpc(); + + const postRefundFunder1Quote = await this.getTokenBalance( + MAINNET_USDC, + funder1.publicKey, + ); + const postRefundFunder2Quote = await this.getTokenBalance( + MAINNET_USDC, + funder2.publicKey, + ); + const postRefundFunder3Quote = await this.getTokenBalance( + MAINNET_USDC, + funder3.publicKey, + ); + + // Funder1: committed 500k, approved 250k → refund 250k + assert.equal( + postRefundFunder1Quote - preRefundFunder1Quote, + 250_000_000000n, + ); + // Funder2: committed 200k, approved 100k → refund 100k + assert.equal( + postRefundFunder2Quote - preRefundFunder2Quote, + 100_000_000000n, + ); + // Funder3: committed 400k, approved 150k → refund 250k + assert.equal( + postRefundFunder3Quote - preRefundFunder3Quote, + 250_000_000000n, + ); + + // ===================== + // 10. claim_additional_token_allocation + // ===================== + await launchpadClient + .claimAdditionalTokenAllocationIx({ + launch, + baseMint: META, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + }) + .rpc(); + + const additionalRecipientBalance = await this.getTokenBalance( + META, + additionalTokensRecipient.publicKey, + ); + assert.equal( + additionalRecipientBalance.toString(), + additionalTokensAmount.toString(), + ); + + launchAccount = await launchpadClient.fetchLaunch(launch); + assert.equal(launchAccount.additionalTokensClaimed, true); + }); +} diff --git a/tests/main.test.ts b/tests/main.test.ts index ecd21df5e..01c7a1029 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -80,6 +80,7 @@ const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( import mintAndSwap from "./integration/mintAndSwap.test.js"; import fullLaunch from "./integration/fullLaunch.test.js"; import fullLaunch_v7 from "./integration/fullLaunch_v7.test.js"; +import fullLaunch_v8 from "./integration/launchpad_v8_full_lifecycle.test.js"; import { BN } from "bn.js"; const ONE_BUCK_PRICE = PriceMath.getAmmPrice(1, 6, 6); @@ -759,4 +760,5 @@ describe("project-wide integration tests", function () { it.skip("mint and swap in a single transaction", mintAndSwap); describe("full launch v6", fullLaunch); describe("full launch v7", fullLaunch_v7); + describe("full launch v8", fullLaunch_v8); }); diff --git a/vibes/tasks.md b/vibes/tasks.md index b2e6ba08a..26bd0430c 100644 --- a/vibes/tasks.md +++ b/vibes/tasks.md @@ -61,12 +61,7 @@ > Reference: `launchpad_v8_spec.md` → "Integration Test" -- [NEXT] 9.1 Write integration test - - Create `tests/integration/launchpad_v8_full_lifecycle.test.ts` - - Full lifecycle: init → start → fund (multiple funders) → close → approve → settle → finalize → claim → refund → claim_additional - - Verify: `anchor test --skip-build` (with `.only` on integration suite) - -- [ ] 9.2 Run full test suite +- [NEXT] 9.2 Run full test suite - Remove all `.only` markers - Run `anchor test` (full build + all tests) - All 46 unit tests + integration test must pass From cce35a222632069f5daca0431ae930deef644bb4 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:32:01 +0200 Subject: [PATCH 072/100] kill vibes dir --- vibes/launchpad_v8_spec.md | 1819 ------------------------------------ 1 file changed, 1819 deletions(-) delete mode 100644 vibes/launchpad_v8_spec.md diff --git a/vibes/launchpad_v8_spec.md b/vibes/launchpad_v8_spec.md deleted file mode 100644 index 30c526f51..000000000 --- a/vibes/launchpad_v8_spec.md +++ /dev/null @@ -1,1819 +0,0 @@ -# Launchpad v8 — Implementation Spec - -> **Reference:** `vibes/launchpad_v8.md` for architectural rationale and design decisions. - ---- - -## Summary of Changes from v7 - -| Area | v7 | v8 | -|------|----|----| -| Token minting | All tokens minted upfront in `initialize_launch` | No minting at init; tokens minted on demand | -| Mint authority | Raw SPL authority transferred to DAO in `complete_launch` | MintGovernor PDA owns authority from init; admin transferred to DAO in `finalize_launch` | -| Performance package | v1 (pre-minted vault) | v2 (mint-on-demand via MintGovernor) | -| `complete_launch` | Transfers mint authority to DAO | Renamed → `settle_launch`; mints tokens via MintGovernor | -| `initialize_performance_package` | Initializes PP v1 with pre-minted tokens | Renamed → `finalize_launch`; initializes PP v2 + transfers MintGovernor admin | -| Migration instructions | `resize_launch`, `resize_funding_record` | Removed (fresh deploy, new program ID) | -| Program ID | `moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM` | `moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n` | - ---- - -## Constants - -```rust -pub const TOKEN_SCALE: u64 = 1_000_000; -pub const PRICE_SCALE: u128 = 1_000_000_000_000; -pub const TOKENS_TO_PARTICIPANTS: u64 = 10_000_000 * TOKEN_SCALE; -pub const TOKENS_TO_FUTARCHY_LIQUIDITY: u64 = 2_000_000 * TOKEN_SCALE; -pub const TOKENS_TO_DAMM_V2_LIQUIDITY: u64 = TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED * TOKEN_SCALE; -pub const TOKENS_TO_DAMM_V2_LIQUIDITY_UNSCALED: u64 = 900_000; -pub const PROPOSAL_MIN_STAKE_TOKENS: u64 = 1_500_000 * TOKEN_SCALE; - -// PP v2 tranche config -pub const PP_NUM_TRANCHES: usize = 5; -pub const PP_PRICE_MULTIPLIERS: [u128; 5] = [2, 4, 8, 16, 32]; - -// FutarchyTwap min_duration: 3 months -pub const PP_TWAP_MIN_DURATION: u32 = 3 * 30 * 24 * 60 * 60; // 7_776_000 seconds -``` - -All unchanged from v7 except PP constants (new). - ---- - -## State - -### `LaunchState` (unchanged) - -```rust -#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, InitSpace)] -pub enum LaunchState { - Initialized, - Live, - Closed, - Complete, - Refunding, -} -``` - -### `Launch` account - -Seeds: `[b"launch", base_mint.key()]` - -```rust -#[account] -pub struct Launch { - // -- Unchanged fields -- - pub pda_bump: u8, - pub minimum_raise_amount: u64, - pub monthly_spending_limit_amount: u64, - pub monthly_spending_limit_members: Vec, // max 10 - pub launch_authority: Pubkey, - pub launch_signer: Pubkey, - pub launch_signer_pda_bump: u8, - pub launch_quote_vault: Pubkey, - pub launch_base_vault: Pubkey, - pub base_mint: Pubkey, - pub quote_mint: Pubkey, - pub unix_timestamp_started: Option, - pub unix_timestamp_closed: Option, - pub total_committed_amount: u64, - pub state: LaunchState, - pub seq_num: u64, - pub seconds_for_launch: u32, - pub dao: Option, - pub dao_vault: Option, - pub performance_package_grantee: Pubkey, - pub performance_package_token_amount: u64, - pub months_until_insiders_can_unlock: u8, - pub team_address: Pubkey, - pub total_approved_amount: u64, - pub additional_tokens_amount: u64, - pub additional_tokens_recipient: Option, - pub additional_tokens_claimed: bool, - pub unix_timestamp_completed: Option, - pub is_performance_package_initialized: bool, - pub accumulator_activation_delay_seconds: u32, - pub has_bid_wall: bool, - - // -- New field -- - pub mint_governor: Pubkey, // Set at initialization -} -``` - -### `FundingRecord` account (unchanged) - -Seeds: `[b"funding_record", launch.key(), funder.key()]` - -```rust -#[account] -pub struct FundingRecord { - pub pda_bump: u8, - pub funder: Pubkey, - pub launch: Pubkey, - pub committed_amount: u64, - pub is_tokens_claimed: bool, - pub is_usdc_refunded: bool, - pub approved_amount: u64, - pub committed_amount_accumulator: u128, - pub last_accumulator_update: i64, -} -``` - -### `launch_signer` PDA (unchanged) - -Seeds: `[b"launch_signer", launch.key()]` - -Unchanged PDA used as the signing authority for the launch program. - ---- - -## Instructions - -### 1. `initialize_launch` — CHANGED - -**Changes from v7:** -- Remove `token::mint_to` — no tokens minted at init -- Add MintGovernor setup: init governor, add launch_signer as minter, transfer mint authority -- Store `mint_governor` pubkey in Launch state - -#### Args - -```rust -#[derive(AnchorSerialize, AnchorDeserialize, Clone)] -pub struct InitializeLaunchArgs { - pub minimum_raise_amount: u64, - pub monthly_spending_limit_amount: u64, - pub monthly_spending_limit_members: Vec, - pub seconds_for_launch: u32, - pub token_name: String, - pub token_symbol: String, - pub token_uri: String, - pub performance_package_grantee: Pubkey, - pub performance_package_token_amount: u64, - pub months_until_insiders_can_unlock: u8, - pub team_address: Pubkey, - pub additional_tokens_amount: u64, - pub accumulator_activation_delay_seconds: u32, - pub has_bid_wall: bool, -} -``` - -Unchanged from v7. - -#### Accounts - -```rust -#[derive(Accounts)] -#[instruction(args: InitializeLaunchArgs)] -pub struct InitializeLaunch<'info> { - // -- Same as v7 -- - #[account(init, payer = payer, space = 8 + Launch::INIT_SPACE, - seeds = [b"launch", base_mint.key().as_ref()], bump)] - pub launch: Account<'info, Launch>, - - #[account(mut, mint::decimals = 6, mint::authority = launch_signer)] - pub base_mint: Account<'info, Mint>, - - #[account(mut, seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), - base_mint.key().as_ref()], seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, bump)] - pub token_metadata: UncheckedAccount<'info>, - - #[account(seeds = [b"launch_signer", launch.key().as_ref()], bump)] - pub launch_signer: UncheckedAccount<'info>, - - #[account(init_if_needed, payer = payer, associated_token::mint = quote_mint, - associated_token::authority = launch_signer)] - pub quote_vault: Account<'info, TokenAccount>, - - #[account(init_if_needed, payer = payer, associated_token::mint = base_mint, - associated_token::authority = launch_signer)] - pub base_vault: Account<'info, TokenAccount>, - - #[account(mut)] - pub payer: Signer<'info>, - - pub launch_authority: UncheckedAccount<'info>, - - #[account(mint::decimals = 6, address = usdc_mint::id())] - pub quote_mint: Account<'info, Mint>, - - pub additional_tokens_recipient: Option>, - - // -- New: MintGovernor accounts -- - /// PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)] - /// Initialized via CPI to mint_governor::initialize_mint_governor - #[account(mut)] - pub mint_governor: UncheckedAccount<'info>, - - /// PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)] - /// Initialized via CPI to mint_governor::add_mint_authority - #[account(mut)] - pub mint_authority: UncheckedAccount<'info>, - - pub mint_governor_program: Program<'info, MintGovernorProgram>, - pub mint_governor_event_authority: UncheckedAccount<'info>, - - // -- Standard -- - pub rent: Sysvar<'info, Rent>, - pub token_program: Program<'info, Token>, - pub associated_token_program: Program<'info, AssociatedToken>, - pub system_program: Program<'info, System>, - pub token_metadata_program: Program<'info, Metadata>, -} -``` - -#### Validation - -Same as v7: -- `minimum_raise_amount > 0` -- `seconds_for_launch <= 14 days` -- `accumulator_activation_delay_seconds < seconds_for_launch` -- No freeze authority on `base_mint` -- `minimum_raise_amount >= monthly_spending_limit_amount * 6` -- `minimum_raise_amount >= futarchy::MIN_QUOTE_LIQUIDITY * 5` -- `monthly_spending_limit_amount != 0` -- `monthly_spending_limit_members.len()` in `1..=10`, no duplicates -- `months_until_insiders_can_unlock >= 12` -- `performance_package_token_amount >= 10` -- `base_mint.supply == 0` -- If `additional_tokens_amount > 0`, `additional_tokens_recipient` must be `Some` - -#### Handler - -``` -1. Initialize Launch account (state = Initialized, store all fields including mint_governor key) - -2. CPI → mpl_token_metadata::create_metadata_accounts_v3 - - mint_authority = launch_signer (still raw SPL authority at this point) - - update_authority = launch_signer - -3. CPI → mint_governor::initialize_mint_governor - - create_key = launch_signer - - admin = launch_signer - - mint = base_mint - -4. CPI → mint_governor::add_mint_authority - - admin = launch_signer - - authorized_minter = launch_signer - - max_total = Some(TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY - + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount) - -5. CPI → mint_governor::transfer_authority_to_governor - - current_authority = launch_signer - - mint = base_mint - → SPL mint authority moves from launch_signer → MintGovernor PDA - -6. NO token::mint_to (removed from v7) - -7. Emit LaunchInitializedEvent -``` - -After this instruction: -- MintGovernor PDA owns the SPL mint authority -- launch_signer is admin + authorized minter with a capped `max_total` -- Zero tokens exist -- base_vault ATA exists but is empty - ---- - -### 2. `start_launch` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct StartLaunch<'info> { - #[account(mut, has_one = launch_authority)] - pub launch: Account<'info, Launch>, - pub launch_authority: Signer<'info>, -} -``` - -Sets state `Initialized → Live`, records `unix_timestamp_started`. - ---- - -### 3. `fund` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct Fund<'info> { - #[account(mut, has_one = launch_quote_vault)] - pub launch: Account<'info, Launch>, - #[account(init_if_needed, payer = payer, space = 8 + FundingRecord::INIT_SPACE, - seeds = [b"funding_record", launch.key().as_ref(), funder.key().as_ref()], bump)] - pub funding_record: Account<'info, FundingRecord>, - #[account(mut)] - pub launch_quote_vault: Account<'info, TokenAccount>, - pub funder: Signer<'info>, - #[account(mut)] - pub payer: Signer<'info>, - #[account(mut, associated_token::mint = launch.quote_mint, associated_token::authority = funder)] - pub funder_quote_account: Account<'info, TokenAccount>, - pub token_program: Program<'info, Token>, - pub system_program: Program<'info, System>, -} -``` - -Transfers quote tokens from funder to vault. Updates accumulator. Emits `LaunchFundedEvent`. - ---- - -### 4. `set_funding_record_approval` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct SetFundingRecordApproval<'info> { - #[account(mut, has_one = launch_authority)] - pub launch: Account<'info, Launch>, - #[account(mut, has_one = launch)] - pub funding_record: Account<'info, FundingRecord>, - pub launch_authority: Signer<'info>, -} -``` - -Sets `approved_amount` on a funding record. Only callable while `Closed` and within 2 days of close. - ---- - -### 5. `close_launch` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct CloseLaunch<'info> { - #[account(mut)] - pub launch: Account<'info, Launch>, -} -``` - -Transitions `Live → Closed` (or `→ Refunding` if below minimum). - ---- - -### 6. `settle_launch` — CHANGED (renamed from `complete_launch`) - -**Changes from v7:** -- Renamed from `complete_launch` -- Remove `token::set_authority` (transfer mint authority to DAO) — MintGovernor admin stays as launch_signer -- Add `mint_governor::mint_tokens` — single mint of exact needed supply into base vault -- Everything else (DAO init, liquidity, Meteora, bid wall, metadata transfer, USDC transfer) stays the same - -> **Note:** The old `token::set_authority` was a direct CPI (depth 2). The new `mint_governor::mint_tokens` is depth 3 (launchpad → mint_governor → token::mint_to). Still well within the depth-4 limit. - -#### Accounts - -```rust -#[derive(Accounts)] -pub struct SettleLaunch<'info> { - // -- Same as v7 complete_launch -- - #[account(mut, has_one = launch_quote_vault, has_one = launch_base_vault, - has_one = launch_signer, has_one = base_mint, has_one = quote_mint, - has_one = mint_governor)] - pub launch: Box>, - - pub launch_authority: Option>, - - #[account(mut, seeds = [b"metadata", MPL_TOKEN_METADATA_PROGRAM_ID.as_ref(), - base_mint.key().as_ref()], seeds::program = MPL_TOKEN_METADATA_PROGRAM_ID, bump)] - pub token_metadata: UncheckedAccount<'info>, - - #[account(mut)] - pub payer: Signer<'info>, - - #[account(mut)] - pub launch_signer: UncheckedAccount<'info>, - - #[account(mut, associated_token::mint = quote_mint, associated_token::authority = launch_signer)] - pub launch_quote_vault: Box>, - - #[account(mut, associated_token::mint = base_mint, associated_token::authority = launch_signer)] - pub launch_base_vault: Box>, - - #[account(init_if_needed, payer = payer, associated_token::mint = quote_mint, - associated_token::authority = squads_multisig_vault)] - pub treasury_quote_account: Box>, - - #[account(mut, address = meteora_accounts.base_mint.key())] - pub base_mint: Box>, - - #[account(address = meteora_accounts.quote_mint.key())] - pub quote_mint: Box>, - - // DAO / Squads accounts (same as v7) - #[account(mut)] - pub dao: UncheckedAccount<'info>, - #[account(mut)] - pub squads_multisig: UncheckedAccount<'info>, - pub squads_multisig_vault: UncheckedAccount<'info>, - #[account(mut)] - pub spending_limit: UncheckedAccount<'info>, - - // Futarchy AMM (same as v7) - #[account(mut)] - pub dao_owned_lp_position: UncheckedAccount<'info>, - #[account(mut)] - pub futarchy_amm_base_vault: UncheckedAccount<'info>, - #[account(mut)] - pub futarchy_amm_quote_vault: UncheckedAccount<'info>, - - // Bid wall (same as v7) - #[account(mut)] - pub bid_wall: UncheckedAccount<'info>, - #[account(mut)] - pub bid_wall_quote_token_account: UncheckedAccount<'info>, - - pub fee_recipient: AccountInfo<'info>, - - // -- New: MintGovernor accounts -- - #[account(mut)] - pub mint_governor: Account<'info, MintGovernor>, - - #[account(mut, has_one = mint_governor, - constraint = mint_authority.authorized_minter == launch_signer.key() - @ LaunchpadError::InvalidMintAuthority)] - pub mint_authority: Account<'info, MintAuthority>, - - pub mint_governor_program: Program<'info, MintGovernorProgram>, - pub mint_governor_event_authority: UncheckedAccount<'info>, - - // Standard + nested (same as v7) - pub system_program: Program<'info, System>, - pub token_program: Program<'info, Token>, - pub associated_token_program: Program<'info, AssociatedToken>, - pub static_accounts: StaticCompleteLaunchAccounts<'info>, - pub meteora_accounts: MeteoraAccounts<'info>, -} -``` - -`StaticCompleteLaunchAccounts` and `MeteoraAccounts` — same as v7. - -#### Validation - -Same as v7: -- Launch state must be `Closed` -- If within 2 days of close → `launch_authority` must be present and match -- If `launch_authority` signs → `total_approved_amount >= minimum_raise_amount` - -#### Handler - -``` -1. If total_approved_amount < minimum_raise_amount → set state to Refunding, return early - -2. (NEW) CPI → mint_governor::mint_tokens - - authorized_minter = launch_signer (signs via PDA seeds) - - destination_ata = launch_base_vault - - amount = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY - + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount - -3. Calculate launch_price = (total_approved_amount * PRICE_SCALE) / TOKENS_TO_PARTICIPANTS - -4. Allocate USDC: 20% to futarchy AMM, remainder to DAO (minus optional bid wall) - -5. CPI → futarchy::initialize_dao (same as v7) - -6. If has_bid_wall → CPI → bid_wall::initialize_bid_wall (same as v7) - -7. CPI → futarchy::provide_liquidity (same as v7) - -8. CPI → damm_v2::initialize_pool_with_dynamic_config (same as v7) - -9. CPI → mpl_token_metadata::update_metadata_accounts_v2 - - Transfer metadata update_authority from launch_signer → squads_multisig_vault - -10. Transfer USDC from launch_quote_vault → treasury_quote_account (same as v7) - -11. (REMOVED) token::set_authority — no longer transferring raw mint authority - -12. Set state = Complete, unix_timestamp_completed, dao, dao_vault -13. Emit LaunchSettledEvent -``` - -**Key difference:** MintGovernor admin remains as `launch_signer` after this instruction. The admin transfer to the DAO happens in `finalize_launch`. - ---- - -### 7. `finalize_launch` — CHANGED (renamed from `initialize_performance_package`) - -**Complete rewrite — now targets PP v2 + MintGovernor admin transfer.** - -#### Accounts - -```rust -#[derive(Accounts)] -pub struct FinalizeLaunch<'info> { - #[account(mut, has_one = launch_signer, has_one = base_mint, has_one = mint_governor, - has_one = performance_package_grantee, - constraint = launch.dao == Some(dao.key()) @ LaunchpadError::InvalidDao)] - pub launch: Box>, - - #[account(mut)] - pub payer: Signer<'info>, - - pub launch_signer: UncheckedAccount<'info>, - - #[account(address = launch.base_mint)] - pub base_mint: Account<'info, Mint>, - - // DAO / Squads - pub dao: UncheckedAccount<'info>, - - // NOTE: seeds::program = squads_program is required here because these are - // cross-program PDAs derived from the Squads program, not the launchpad. - #[account(seeds = [squads_multisig_program::SEED_PREFIX, - squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], - seeds::program = squads_program, bump)] - pub squads_multisig: UncheckedAccount<'info>, - - #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), - squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], - seeds::program = squads_program, bump)] - pub squads_multisig_vault: UncheckedAccount<'info>, - - /// The performance package grantee — stored in launch state, passed here - /// for the PP v2 initialize CPI (recipient field). - pub performance_package_grantee: UncheckedAccount<'info>, - - // MintGovernor - #[account(mut)] - pub mint_governor: Account<'info, MintGovernor>, - - /// MintAuthority for PP v2 PDA — initialized via CPI - /// PDA: seeds = [b"mint_authority", mint_governor, performance_package] - #[account(mut)] - pub pp_mint_authority: UncheckedAccount<'info>, - - // Performance Package v2 - /// PP v2 account — initialized via CPI - /// PDA: seeds = [b"performance_package", launch_signer (create_key)] - #[account(mut)] - pub performance_package: UncheckedAccount<'info>, - - // Programs - pub system_program: Program<'info, System>, - pub token_program: Program<'info, Token>, - pub squads_program: Program<'info, SquadsMultisig>, - pub mint_governor_program: Program<'info, MintGovernorProgram>, - pub mint_governor_event_authority: UncheckedAccount<'info>, - pub performance_package_v2_program: Program<'info, PerformancePackageV2Program>, - pub performance_package_v2_event_authority: UncheckedAccount<'info>, -} -``` - -#### Validation - -```rust -fn validate(&self) -> Result<()> { - require!(self.launch.state == LaunchState::Complete, LaunchpadError::InvalidLaunchState); - require!(!self.launch.is_performance_package_initialized, - LaunchpadError::PerformancePackageAlreadyInitialized); - Ok(()) -} -``` - -#### Handler - -``` -1. Compute launch_price = (total_approved_amount * PRICE_SCALE) / TOKENS_TO_PARTICIPANTS - -2. Build threshold tranches for PP v2: - tranches = [ - { threshold: launch_price * 2, cumulative_amount: pp_token_amount * 1 / 5 }, - { threshold: launch_price * 4, cumulative_amount: pp_token_amount * 2 / 5 }, - { threshold: launch_price * 8, cumulative_amount: pp_token_amount * 3 / 5 }, - { threshold: launch_price * 16, cumulative_amount: pp_token_amount * 4 / 5 }, - { threshold: launch_price * 32, cumulative_amount: pp_token_amount }, - ] - -3. CPI → mint_governor::add_mint_authority - - admin = launch_signer (still admin at this point) - - authorized_minter = performance_package PDA - - max_total = Some(performance_package_token_amount) - -4. CPI → performance_package_v2::initialize_performance_package - - create_key = launch_signer - - mint = base_mint - - mint_governor = launch.mint_governor - - mint_authority = pp_mint_authority (created in step 3) - - authority = squads_multisig_vault (DAO controls the PP) - - recipient = launch.performance_package_grantee - - args = InitializePerformancePackageArgs { - oracle_reader: FutarchyTwap { amm: dao.key(), min_duration: PP_TWAP_MIN_DURATION }, - reward_function: Threshold { tranches }, - min_unlock_timestamp: unix_timestamp_completed - + (months_until_insiders_can_unlock as i64) * 30 * 24 * 60 * 60, - } - -5. CPI → mint_governor::update_mint_governor_admin - - admin = launch_signer - - new_admin = squads_multisig_vault - → Final handoff: DAO now controls MintGovernor - -6. Set is_performance_package_initialized = true -7. Emit LaunchFinalizedEvent -``` - ---- - -### 8. `claim` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct Claim<'info> { - #[account(mut, has_one = launch_signer, has_one = base_mint, has_one = launch_base_vault)] - pub launch: Account<'info, Launch>, - #[account(mut, has_one = launch, has_one = funder)] - pub funding_record: Account<'info, FundingRecord>, - pub launch_signer: UncheckedAccount<'info>, - pub base_mint: Account<'info, Mint>, - #[account(mut)] - pub launch_base_vault: Account<'info, TokenAccount>, - pub funder: UncheckedAccount<'info>, - #[account(mut, associated_token::mint = base_mint, associated_token::authority = funder)] - pub funder_token_account: Account<'info, TokenAccount>, - pub token_program: Program<'info, Token>, -} -``` - -Transfers `(approved_amount / total_approved_amount) * TOKENS_TO_PARTICIPANTS` tokens to funder. - ---- - -### 9. `refund` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct Refund<'info> { - #[account(mut, has_one = launch_quote_vault, has_one = launch_signer)] - pub launch: Account<'info, Launch>, - #[account(mut, has_one = launch, has_one = funder)] - pub funding_record: Account<'info, FundingRecord>, - #[account(mut)] - pub launch_quote_vault: Account<'info, TokenAccount>, - pub launch_signer: UncheckedAccount<'info>, - pub funder: UncheckedAccount<'info>, - #[account(mut, associated_token::mint = launch.quote_mint, associated_token::authority = funder)] - pub funder_quote_account: Account<'info, TokenAccount>, - pub token_program: Program<'info, Token>, -} -``` - -Refunds USDC. If `Refunding` → full amount. If `Complete` → `committed - approved`. - ---- - -### 10. `claim_additional_token_allocation` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct ClaimAdditionalTokenAllocation<'info> { - #[account(mut, has_one = launch_base_vault, has_one = launch_signer, has_one = base_mint)] - pub launch: Account<'info, Launch>, - #[account(mut)] - pub payer: Signer<'info>, - pub launch_signer: UncheckedAccount<'info>, - #[account(mut, associated_token::mint = base_mint, associated_token::authority = launch_signer)] - pub launch_base_vault: Account<'info, TokenAccount>, - pub base_mint: Account<'info, Mint>, - pub additional_tokens_recipient: AccountInfo<'info>, - #[account(init_if_needed, payer = payer, associated_token::mint = base_mint, - associated_token::authority = additional_tokens_recipient)] - pub additional_tokens_recipient_token_account: Account<'info, TokenAccount>, - pub system_program: Program<'info, System>, - pub token_program: Program<'info, Token>, - pub associated_token_program: Program<'info, AssociatedToken>, -} -``` - -Transfers `additional_tokens_amount` to recipient. - ---- - -### 11. `extend_launch` — UNCHANGED - -```rust -#[derive(Accounts)] -pub struct ExtendLaunch<'info> { - #[account(mut)] - pub launch: Account<'info, Launch>, - pub admin: Signer<'info>, -} -``` - -Admin (metadao_multisig_vault in production) extends `seconds_for_launch`. - ---- - -## Events - -All events use CPI events (`#[event_cpi]` / `emit_cpi!`). - -### Common fields - -```rust -#[derive(AnchorSerialize, AnchorDeserialize, Clone)] -pub struct CommonFields { - pub slot: u64, - pub unix_timestamp: i64, - pub launch_seq_num: u64, -} -``` - -### `LaunchInitializedEvent` — CHANGED - -```rust -#[event] -pub struct LaunchInitializedEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub minimum_raise_amount: u64, - pub launch_authority: Pubkey, - pub launch_signer: Pubkey, - pub launch_signer_pda_bump: u8, - pub launch_usdc_vault: Pubkey, - pub launch_token_vault: Pubkey, - pub performance_package_grantee: Pubkey, - pub performance_package_token_amount: u64, - pub months_until_insiders_can_unlock: u8, - pub monthly_spending_limit_amount: u64, - pub monthly_spending_limit_members: Vec, - pub base_mint: Pubkey, - pub quote_mint: Pubkey, - pub pda_bump: u8, - pub seconds_for_launch: u32, - pub additional_tokens_amount: u64, - pub additional_tokens_recipient: Option, - pub accumulator_activation_delay_seconds: u32, - pub has_bid_wall: bool, - pub mint_governor: Pubkey, // NEW -} -``` - -### `LaunchStartedEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchStartedEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub launch_authority: Pubkey, - pub slot_started: u64, -} -``` - -### `LaunchFundedEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchFundedEvent { - pub common: CommonFields, - pub funding_record: Pubkey, - pub launch: Pubkey, - pub funder: Pubkey, - pub amount: u64, - pub total_committed_by_funder: u64, - pub total_committed: u64, - pub committed_amount_accumulator: u128, -} -``` - -### `FundingRecordApprovalSetEvent` — UNCHANGED - -```rust -#[event] -pub struct FundingRecordApprovalSetEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub funding_record: Pubkey, - pub funder: Pubkey, - pub approved_amount: u64, - pub total_approved: u64, -} -``` - -### `LaunchCloseEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchCloseEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub new_state: LaunchState, -} -``` - -### `LaunchSettledEvent` — CHANGED (renamed from `LaunchCompletedEvent`) - -```rust -#[event] -pub struct LaunchSettledEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub final_state: LaunchState, - pub total_committed: u64, - pub dao: Option, - pub dao_treasury: Option, - pub total_approved_amount: u64, - pub bid_wall: Option, - pub bid_wall_amount: u64, - pub mint_governor: Pubkey, // NEW - pub tokens_minted: u64, // NEW — total tokens minted in this tx -} -``` - -### `LaunchFinalizedEvent` — CHANGED (renamed from `LaunchPerformancePackageInitializedEvent`) - -```rust -#[event] -pub struct LaunchFinalizedEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub performance_package: Pubkey, - pub mint_governor: Pubkey, // NEW - pub mint_governor_new_admin: Pubkey, // NEW — the DAO vault - pub pp_mint_authority: Pubkey, // NEW -} -``` - -### `LaunchRefundedEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchRefundedEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub funder: Pubkey, - pub usdc_refunded: u64, - pub funding_record: Pubkey, -} -``` - -### `LaunchClaimEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchClaimEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub funder: Pubkey, - pub tokens_claimed: u64, - pub funding_record: Pubkey, -} -``` - -### `LaunchClaimAdditionalTokenAllocationEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchClaimAdditionalTokenAllocationEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub additional_tokens_amount: u64, - pub additional_tokens_recipient: Pubkey, -} -``` - -### `LaunchExtendedEvent` — UNCHANGED - -```rust -#[event] -pub struct LaunchExtendedEvent { - pub common: CommonFields, - pub launch: Pubkey, - pub old_seconds_for_launch: u32, - pub new_seconds_for_launch: u32, -} -``` - ---- - -## Errors - -```rust -#[error_code] -pub enum LaunchpadError { - #[msg("Invalid amount")] - InvalidAmount, - #[msg("Supply must be zero")] - SupplyNonZero, - #[msg("Launch period must be between 1 hour and 2 weeks")] - InvalidSecondsForLaunch, - #[msg("Insufficient funds")] - InsufficientFunds, - #[msg("Invalid launch state")] - InvalidLaunchState, - #[msg("Launch period not over")] - LaunchPeriodNotOver, - #[msg("Launch is complete, no more funding allowed")] - LaunchExpired, - #[msg("Refund not available")] - LaunchNotRefunding, - #[msg("Launch must be initialized to be started")] - LaunchNotInitialized, - #[msg("Freeze authority can't be set on launchpad tokens")] - FreezeAuthoritySet, - #[msg("Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0")] - InvalidMonthlySpendingLimit, - #[msg("There can only be at most 10 monthly spending limit members")] - InvalidMonthlySpendingLimitMembers, - #[msg("Invalid performance package token amount")] - InvalidPerformancePackageTokenAmount, - #[msg("Insiders must wait at least 12 months before unlocking")] - InvalidPerformancePackageMinUnlockTime, - #[msg("Launch authority must be set to complete the launch until 2 days after closing")] - LaunchAuthorityNotSet, - #[msg("The final amount raised must be >= the minimum raise amount")] - FinalRaiseAmountTooLow, - #[msg("Tokens already claimed")] - TokensAlreadyClaimed, - #[msg("USDC already refunded")] - MoneyAlreadyRefunded, - #[msg("Invariant violated")] - InvariantViolated, - #[msg("Launch must be live to be closed")] - LaunchNotLive, - #[msg("Minimum raise amount too low for liquidity")] - InvalidMinimumRaiseAmount, - #[msg("Final raise amount already set")] - FinalRaiseAmountAlreadySet, - #[msg("Total approved amount too low")] - TotalApprovedAmountTooLow, - #[msg("Additional tokens recipient must be set when amount > 0")] - InvalidAdditionalTokensRecipient, - #[msg("No additional tokens recipient set")] - NoAdditionalTokensRecipientSet, - #[msg("Additional tokens already claimed")] - AdditionalTokensAlreadyClaimed, - #[msg("Funding record approval period is over")] - FundingRecordApprovalPeriodOver, - #[msg("Performance package already initialized")] - PerformancePackageAlreadyInitialized, - #[msg("Invalid DAO")] - InvalidDao, - #[msg("Accumulator activation delay must be less than the launch duration")] - InvalidAccumulatorActivationDelaySeconds, - #[msg("Extend duration would exceed maximum allowed launch duration")] - ExtendDurationExceedsMax, - #[msg("Mint authority does not match expected")] // NEW - InvalidMintAuthority, -} -``` - -Same error variants as v7, reordered/renamed for clarity. `InvalidMintAuthority` added for MintGovernor account validation. - ---- - -## SDK2 Client - -### Directory: `sdk2/src/launchpad/v0.8/` - -Files: -- `LaunchpadClient.ts` -- `pda.ts` -- `types/index.ts` -- `types/v08_launchpad.ts` (generated from IDL) -- `index.ts` (re-exports) - -### `pda.ts` - -```typescript -import { PublicKey } from "@solana/web3.js"; -import { LAUNCHPAD_V0_8_PROGRAM_ID } from "../../constants.js"; - -export function getLaunchAddr( - programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, - tokenMint: PublicKey, -): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch"), tokenMint.toBuffer()], - programId, - ); -} - -export const getLaunchSignerAddr = ( - programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_signer"), launch.toBuffer()], - programId, - ); -}; - -export const getFundingRecordAddr = ( - programId: PublicKey = LAUNCHPAD_V0_8_PROGRAM_ID, - launch: PublicKey, - funder: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], - programId, - ); -}; -``` - -PDA functions are identical to v0.7, just targeting the v0.8 program ID. - -### `LaunchpadClient.ts` - -```typescript -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { PublicKey, ComputeBudgetProgram, SystemProgram } from "@solana/web3.js"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - TOKEN_2022_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; - -// Type imports from generated IDL -import { V08Launchpad as Launchpad, IDL as LaunchpadIDL } from "./types/v08_launchpad.js"; -import { Launch, FundingRecord } from "./types/index.js"; - -// PDA imports -import { getLaunchAddr, getLaunchSignerAddr, getFundingRecordAddr } from "./pda.js"; -import { getEventAuthorityAddr, getMetadataAddr } from "../../pda.js"; - -// Sub-client imports -import { FutarchyClient, getDaoAddr } from "../../futarchy/v0.6/index.js"; -import { MintGovernorClient, getMintGovernorAddr, getMintAuthorityAddr } from "../../mint_governor/v0.7/index.js"; -import { PerformancePackageV2Client, getPerformancePackageV2Addr } from "../../performance_package_v2/v0.7/index.js"; -import { BidWallClient } from "../../bid_wall/v0.7/index.js"; -import * as multisig from "@sqds/multisig"; - -import { - LAUNCHPAD_V0_8_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, - MAINNET_USDC, - SQUADS_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, - DAMM_V2_PROGRAM_ID, - MINT_GOVERNOR_V0_7_PROGRAM_ID, - PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - METADAO_MULTISIG_VAULT, -} from "../../constants.js"; - -export type CreateLaunchpadClientParams = { - provider: AnchorProvider; - launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - mintGovernorProgramId?: PublicKey; - performancePackageV2ProgramId?: PublicKey; - bidWallProgramId?: PublicKey; -}; - -export class LaunchpadClient { - public launchpad: Program; - public provider: AnchorProvider; - public autocratClient: FutarchyClient; - public mintGovernorClient: MintGovernorClient; - public performancePackageV2Client: PerformancePackageV2Client; - public bidWall: BidWallClient; - - private constructor(params: CreateLaunchpadClientParams) { - this.provider = params.provider; - this.launchpad = new Program( - LaunchpadIDL, - params.launchpadProgramId || LAUNCHPAD_V0_8_PROGRAM_ID, - this.provider, - ); - this.autocratClient = FutarchyClient.createClient({ - provider: this.provider, - autocratProgramId: params.autocratProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - }); - this.mintGovernorClient = MintGovernorClient.createClient({ - provider: this.provider, - programId: params.mintGovernorProgramId, - }); - this.performancePackageV2Client = PerformancePackageV2Client.createClient({ - provider: this.provider, - programId: params.performancePackageV2ProgramId, - }); - this.bidWall = BidWallClient.createClient({ - provider: this.provider, - bidWallProgramId: params.bidWallProgramId, - }); - } - - static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { - return new LaunchpadClient(params); - } - - getProgramId(): PublicKey { - return this.launchpad.programId; - } - - // ─── Fetch / Deserialize ──────────────────────────────────────────── - - async getLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetch(launch); - } - - async fetchLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetchNullable(launch); - } - - async deserializeLaunch(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("launch", accountInfo.data); - } - - async getFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetch(fundingRecord); - } - - async fetchFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetchNullable(fundingRecord); - } - - async deserializeFundingRecord(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("fundingRecord", accountInfo.data); - } - - // ─── Address Derivation ───────────────────────────────────────────── - - getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { - return getLaunchAddr(this.launchpad.programId, baseMint)[0]; - } - - getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { - return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; - } - - getMintGovernorAddress({ baseMint, launchSigner }: { - baseMint: PublicKey; - launchSigner: PublicKey; - }): PublicKey { - return getMintGovernorAddr({ - programId: this.mintGovernorClient.programId, - mint: baseMint, - createKey: launchSigner, - })[0]; - } - - getMintAuthorityAddress({ mintGovernor, authorizedMinter }: { - mintGovernor: PublicKey; - authorizedMinter: PublicKey; - }): PublicKey { - return getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter, - })[0]; - } - - getPerformancePackageAddress({ launch }: { launch: PublicKey }): PublicKey { - const launchSigner = this.getLaunchSignerAddress({ launch }); - return getPerformancePackageV2Addr({ - programId: this.performancePackageV2Client.programId, - createKey: launchSigner, - })[0]; - } - - getLaunchDaoAddress({ launch }: { launch: PublicKey }): PublicKey { - const launchSigner = this.getLaunchSignerAddress({ launch }); - return getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner })[0]; - } - - getFundingRecordAddress({ launch, funder }: { - launch: PublicKey; - funder: PublicKey; - }): PublicKey { - return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; - } - - // ─── Instruction Builders ─────────────────────────────────────────── - - initializeLaunchIx({ - tokenName, tokenSymbol, tokenUri, - minimumRaiseAmount, secondsForLaunch = 60 * 60 * 24 * 5, - baseMint, quoteMint = MAINNET_USDC, - monthlySpendingLimitAmount, monthlySpendingLimitMembers, - performancePackageGrantee, performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, teamAddress, - launchAuthority = this.provider.publicKey, - payer = this.provider.publicKey, - additionalTokensRecipient, additionalTokensAmount, - accumulatorActivationDelaySeconds = 0, - hasBidWall = false, - }: { - tokenName: string; - tokenSymbol: string; - tokenUri: string; - minimumRaiseAmount: BN; - secondsForLaunch?: number; - baseMint: PublicKey; - quoteMint?: PublicKey; - monthlySpendingLimitAmount: BN; - monthlySpendingLimitMembers: PublicKey[]; - performancePackageGrantee: PublicKey; - performancePackageTokenAmount: BN; - monthsUntilInsidersCanUnlock: number; - teamAddress: PublicKey; - launchAuthority?: PublicKey; - payer?: PublicKey; - additionalTokensRecipient?: PublicKey; - additionalTokensAmount?: BN; - accumulatorActivationDelaySeconds?: number; - hasBidWall: boolean; - }) { - const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); - const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); - const quoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); - const baseVault = getAssociatedTokenAddressSync(baseMint, launchSigner, true); - const [tokenMetadata] = getMetadataAddr(baseMint); - - // MintGovernor PDAs - const [mintGovernor] = getMintGovernorAddr({ - programId: this.mintGovernorClient.programId, - mint: baseMint, - createKey: launchSigner, - }); - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter: launchSigner, - }); - const [mintGovernorEventAuthority] = getEventAuthorityAddr( - this.mintGovernorClient.programId, - ); - - return this.launchpad.methods - .initializeLaunch({ - minimumRaiseAmount, - secondsForLaunch, - tokenName, tokenSymbol, tokenUri, - monthlySpendingLimitAmount, monthlySpendingLimitMembers, - performancePackageGrantee, performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, teamAddress, - additionalTokensAmount: additionalTokensAmount ?? new BN(0), - accumulatorActivationDelaySeconds, - hasBidWall, - }) - .accounts({ - launch, launchSigner, - quoteVault, baseVault, - launchAuthority, quoteMint, baseMint, tokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - payer, - additionalTokensRecipient: additionalTokensRecipient ?? null, - // New MintGovernor accounts - mintGovernor, - mintAuthority, - mintGovernorProgram: this.mintGovernorClient.programId, - mintGovernorEventAuthority, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(quoteMint, launchSigner, true), - launchSigner, - quoteMint, - ), - ]); - } - - startLaunchIx({ launch, launchAuthority = this.provider.publicKey }: { - launch: PublicKey; - launchAuthority?: PublicKey; - }) { - return this.launchpad.methods.startLaunch().accounts({ - launch, launchAuthority, - }); - } - - fundIx({ launch, amount, funder = this.provider.publicKey, quoteMint = MAINNET_USDC }: { - launch: PublicKey; - amount: BN; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); - const funderQuoteAccount = getAssociatedTokenAddressSync(quoteMint, funder, true); - const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); - - return this.launchpad.methods.fund(amount).accounts({ - launch, launchQuoteVault, fundingRecord, funder, funderQuoteAccount, - }); - } - - closeLaunchIx({ launch }: { launch: PublicKey }) { - return this.launchpad.methods.closeLaunch().accounts({ launch }); - } - - setFundingRecordApprovalIx({ launch, funder, launchAuthority = this.provider.publicKey, approvedAmount }: { - launch: PublicKey; - funder: PublicKey; - launchAuthority?: PublicKey; - approvedAmount: BN; - }) { - const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); - return this.launchpad.methods - .setFundingRecordApproval(approvedAmount) - .accounts({ launch, fundingRecord, launchAuthority }); - } - - settleLaunchIx({ - launch, quoteMint = MAINNET_USDC, baseMint, launchAuthority, - isDevnet = false, meteoraConfig, feeRecipient = METADAO_MULTISIG_VAULT, - }: { - launch: PublicKey; - quoteMint?: PublicKey; - baseMint: PublicKey; - launchAuthority: PublicKey | null; - isDevnet?: boolean; - meteoraConfig: PublicKey; - feeRecipient?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); - const launchBaseVault = getAssociatedTokenAddressSync(baseMint, launchSigner, true); - const [tokenMetadata] = getMetadataAddr(baseMint); - - // DAO / Squads - const [dao] = getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner }); - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ multisigPda, index: 0 }); - const [spendingLimit] = multisig.getSpendingLimitPda({ multisigPda, createKey: dao }); - const treasuryQuoteAccount = getAssociatedTokenAddressSync(quoteMint, multisigVault, true); - const [futarchyEventAuthority] = getEventAuthorityAddr(this.autocratClient.getProgramId()); - - // Futarchy AMM - const [ammPosition] = PublicKey.findProgramAddressSync( - [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], - this.autocratClient.getProgramId(), - ); - - // MintGovernor - const [mintGovernor] = getMintGovernorAddr({ - programId: this.mintGovernorClient.programId, - mint: baseMint, - createKey: launchSigner, - }); - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter: launchSigner, - }); - const [mintGovernorEventAuthority] = getEventAuthorityAddr( - this.mintGovernorClient.programId, - ); - - // Meteora (same as v7) - const [poolAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("pool_authority")], DAMM_V2_PROGRAM_ID, - ); - const [positionNftMint] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_mint"), baseMint.toBuffer()], - this.launchpad.programId, - ); - const [positionNftAccount] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - function getFirstKey(key1: PublicKey, key2: PublicKey) { - return Buffer.compare(key1.toBuffer(), key2.toBuffer()) === 1 - ? key1.toBuffer() : key2.toBuffer(); - } - function getSecondKey(key1: PublicKey, key2: PublicKey) { - return Buffer.compare(key1.toBuffer(), key2.toBuffer()) === 1 - ? key2.toBuffer() : key1.toBuffer(); - } - - const [pool] = PublicKey.findProgramAddressSync( - [Buffer.from("pool"), meteoraConfig.toBuffer(), - getFirstKey(baseMint, quoteMint), getSecondKey(baseMint, quoteMint)], - DAMM_V2_PROGRAM_ID, - ); - const [position] = PublicKey.findProgramAddressSync( - [Buffer.from("position"), positionNftMint.toBuffer()], DAMM_V2_PROGRAM_ID, - ); - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], DAMM_V2_PROGRAM_ID, - ); - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], DAMM_V2_PROGRAM_ID, - ); - const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("damm_pool_creator_authority")], this.launchpad.programId, - ); - const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - - // Bid wall - const bidWall = this.bidWall.getBidWallAddress({ - baseMint, creator: launchSigner, nonce: new BN(0), - }); - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync(quoteMint, bidWall, true); - - return this.launchpad.methods - .settleLaunch() - .accounts({ - launch, launchSigner, launchQuoteVault, launchBaseVault, - launchAuthority, dao, treasuryQuoteAccount, quoteMint, baseMint, - tokenMetadata, - daoOwnedLpPosition: ammPosition, - futarchyAmmQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - futarchyAmmBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - squadsMultisig: multisigPda, - squadsMultisigVault: multisigVault, - spendingLimit, bidWall, bidWallQuoteTokenAccount, feeRecipient, - // New MintGovernor accounts - mintGovernor, mintAuthority, - mintGovernorProgram: this.mintGovernorClient.programId, - mintGovernorEventAuthority, - // Nested (same as v7) - staticAccounts: { - futarchyProgram: this.autocratClient.getProgramId(), - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - futarchyEventAuthority, - squadsProgram: SQUADS_PROGRAM_ID, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury: isDevnet - ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET - : SQUADS_PROGRAM_CONFIG_TREASURY, - bidWallProgram: this.bidWall.programId, - bidWallEventAuthority: this.bidWall.getEventAuthorityAddress(), - }, - meteoraAccounts: { - dammV2Program: DAMM_V2_PROGRAM_ID, - positionNftMint, baseMint, quoteMint, - config: meteoraConfig, - token2022Program: TOKEN_2022_PROGRAM_ID, - positionNftAccount, pool, poolCreatorAuthority, - position, tokenAVault, tokenBVault, poolAuthority, - dammV2EventAuthority, - }, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), - ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), - ]); - } - - finalizeLaunchIx({ - launch, baseMint, performancePackageGrantee, - payer = this.provider.publicKey, - }: { - launch: PublicKey; - baseMint: PublicKey; - performancePackageGrantee: PublicKey; - payer?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - // DAO / Squads - const [dao] = getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner }); - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ multisigPda, index: 0 }); - - // MintGovernor - const [mintGovernor] = getMintGovernorAddr({ - programId: this.mintGovernorClient.programId, - mint: baseMint, - createKey: launchSigner, - }); - - // PP v2 PDA (create_key = launch_signer) - const [performancePackage] = getPerformancePackageV2Addr({ - programId: this.performancePackageV2Client.programId, - createKey: launchSigner, - }); - - // MintAuthority for PP v2 - const [ppMintAuthority] = getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter: performancePackage, - }); - - const [mintGovernorEventAuthority] = getEventAuthorityAddr( - this.mintGovernorClient.programId, - ); - const [ppV2EventAuthority] = getEventAuthorityAddr( - this.performancePackageV2Client.programId, - ); - - return this.launchpad.methods - .finalizeLaunch() - .accounts({ - launch, launchSigner, baseMint, payer, - dao, squadsMultisig: multisigPda, squadsMultisigVault: multisigVault, - performancePackageGrantee, - mintGovernor, ppMintAuthority, performancePackage, - tokenProgram: TOKEN_PROGRAM_ID, - squadsProgram: SQUADS_PROGRAM_ID, - mintGovernorProgram: this.mintGovernorClient.programId, - mintGovernorEventAuthority, - performancePackageV2Program: this.performancePackageV2Client.programId, - performancePackageV2EventAuthority: ppV2EventAuthority, - }); - } - - refundIx({ launch, funder = this.provider.publicKey, quoteMint = MAINNET_USDC }: { - launch: PublicKey; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); - const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); - const launchQuoteVault = getAssociatedTokenAddressSync(quoteMint, launchSigner, true); - const funderQuoteAccount = getAssociatedTokenAddressSync(quoteMint, funder, true); - - return this.launchpad.methods.refund().accounts({ - launch, launchSigner, launchQuoteVault, funder, funderQuoteAccount, fundingRecord, - }); - } - - claimIx(launch: PublicKey, baseMint: PublicKey, funder: PublicKey = this.provider.publicKey) { - const [launchSigner] = getLaunchSignerAddr(this.launchpad.programId, launch); - const [fundingRecord] = getFundingRecordAddr(this.launchpad.programId, launch, funder); - - return this.launchpad.methods.claim().accounts({ - launch, fundingRecord, launchSigner, funder, baseMint, - funderTokenAccount: getAssociatedTokenAddressSync(baseMint, funder, true), - launchBaseVault: getAssociatedTokenAddressSync(baseMint, launchSigner, true), - }).preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, funder, true), - funder, baseMint, - ), - ]); - } - - claimAdditionalTokenAllocationIx({ launch, baseMint, additionalTokensRecipient, payer = this.provider.publicKey }: { - launch: PublicKey; - baseMint: PublicKey; - additionalTokensRecipient: PublicKey; - payer?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - return this.launchpad.methods.claimAdditionalTokenAllocation().accounts({ - launch, payer, launchSigner, - launchBaseVault: getAssociatedTokenAddressSync(baseMint, launchSigner, true), - baseMint, additionalTokensRecipient, - additionalTokensRecipientTokenAccount: getAssociatedTokenAddressSync( - baseMint, additionalTokensRecipient, true, - ), - }); - } - - extendLaunchIx({ launch, durationSeconds, admin = METADAO_MULTISIG_VAULT }: { - launch: PublicKey; - durationSeconds: number; - admin?: PublicKey; - }) { - return this.launchpad.methods.extendLaunch({ durationSeconds }).accounts({ - launch, admin, - }); - } -} -``` - -### `constants.ts` addition - -```typescript -// Add to sdk2/src/constants.ts -export const LAUNCHPAD_V0_8_PROGRAM_ID = new PublicKey("moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n"); -``` - ---- - -## Tests - -### Directory: `tests/launchpad_v8/` - -``` -tests/launchpad_v8/ -├── main.test.ts -├── utils.ts -└── unit/ - ├── initializeLaunch.test.ts - ├── startLaunch.test.ts - ├── fund.test.ts - ├── closeLaunch.test.ts - ├── setFundingRecordApproval.test.ts - ├── settleLaunch.test.ts - ├── finalizeLaunch.test.ts - ├── claim.test.ts - ├── refund.test.ts - ├── claimAdditionalTokenAllocation.test.ts - └── extendLaunch.test.ts -``` - -### `utils.ts` - -Same pattern as v7 but targeting the v0.8 client: -- `initializeMintWithSeeds()` — creates a fresh mint with deterministic PDA -- Helpers to set up a full launch lifecycle (init → start → fund → close → approve → settle) - -### Test Cases - -Each `it()` block below maps 1:1 to a test. Tests marked **(v8-new)** are new for v8; all others carry over from v7. - -#### `initializeLaunch.test.ts` - -1. "initializes a launch with valid parameters" - — Launch account state = Initialized, all fields correct, mint_governor stored - — **(v8-new)** MintGovernor PDA initialized with admin = launch_signer, create_key = launch_signer - — **(v8-new)** MintAuthority for launch_signer created with correct max_total - — **(v8-new)** SPL mint authority is the MintGovernor PDA (not launch_signer) - — **(v8-new)** base_vault has zero balance, base_mint.supply == 0 -2. "fails when monthly spending limit members contains duplicates" -3. "fails when monthly spending limit members is empty" -4. "rejects accumulator activation delay >= seconds_for_launch" -5. "fails when launch signer is faked" — ConstraintSeeds error - -#### `startLaunch.test.ts` - -6. "starts launch correctly" — sets unix_timestamp_started, state = Live - -#### `fund.test.ts` - -7. "fails to fund the launch before it's started" — InvalidLaunchState -8. "successfully funds the launch" — transfers USDC, creates FundingRecord -9. "successfully funds the launch multiple times" — amounts accumulate correctly -10. "fails to fund the launch at the exact boundary second" — LaunchExpired at exact expiration -11. "fails to fund the launch after time expires" — LaunchExpired -12. "accumulator starts at 0 and last_accumulator_update is set on first fund" -13. "accumulator correctly sums across multiple time intervals" -14. "accumulator stays 0 during activation delay period" -15. "accumulator only counts time after activation delay" - -#### `closeLaunch.test.ts` - -16. "successfully closes launch after sufficient time when minimum raise is met" — state = Closed -17. "successfully closes launch after sufficient time when minimum raise is not met" — state = Refunding -18. "fails to close launch before sufficient time has passed" — LaunchPeriodNotOver -19. "fails to close launch when launch has already been closed" — LaunchNotLive -20. "fails to close launch when launch is still in Initialized state" — LaunchNotLive - -#### `setFundingRecordApproval.test.ts` - -21. "can set funding record approval for full, partial, and zero amounts" -22. "correctly updates the launch account total approved amount" — multiple funders -23. "can't set funding record approval before the launch period ends" — InvalidLaunchState -24. "can't set funding record approval after the funding record approval period ends (2 days)" — FundingRecordApprovalPeriodOver -25. "can't set funding record approval after the launch is completed" — InvalidLaunchState -26. "can't set funding record approval to an amount greater than the committed amount" — InsufficientFunds - -#### `settleLaunch.test.ts` - -27. "settles launch successfully when minimum raise is met" - — **(v8-new)** tokens minted via MintGovernor (correct total = participants + futarchy_liq + damm_liq + additional) - — **(v8-new)** base_mint.supply == expected total - — **(v8-new)** MintAuthority.total_minted updated - — **(v8-new)** MintGovernor admin is still launch_signer (NOT transferred yet) - — DAO created, Futarchy AMM has liquidity, Meteora pool created - — metadata update_authority transferred to DAO - — USDC transferred to DAO treasury, state = Complete -28. "sends all USDC to treasury when hasBidWall is false even with excess funding" -29. "initializes bid wall when hasBidWall is true and funding exceeds 1.25x minimum raise" -30. "does not initialize bid wall when hasBidWall is true and funding equals minimum raise" -31. "does not initialize bid wall when hasBidWall is true and funding is exactly 1.25x minimum raise" — boundary -32. "sets state to Refunding when total_approved_amount < minimum_raise_amount" — no tokens minted, no DAO -33. "fails when launch is in refunding state" — InvalidLaunchState - -#### `finalizeLaunch.test.ts` - -34. "finalizes launch successfully after settle" - — PP v2 MintAuthority created with authorized_minter = PP PDA, max_total = pp_token_amount - — PP v2 account: oracle_reader = FutarchyTwap (amm = dao, min_duration = 3 months) - — PP v2 account: reward_function = Threshold with 5 tranches at 2x/4x/8x/16x/32x - — PP v2 account: recipient = performance_package_grantee, authority = squads_multisig_vault - — PP v2 account: min_unlock_timestamp = completion_time + lockup months - — MintGovernor admin transferred to squads_multisig_vault - — is_performance_package_initialized = true -35. "fails when launch state is not Complete" — InvalidLaunchState -36. "can finalize only once" — PerformancePackageAlreadyInitialized - -#### `claim.test.ts` - -37. "successfully claims tokens after launch completion" — proportional amount -38. "fails when launch is not complete" — InvalidLaunchState - -#### `refund.test.ts` - -39. "allows refunds when launch is in refunding state" — full committed_amount -40. "works for oversubscribed launches" — refund = committed - approved -41. "fails when launch is not in refunding or complete state" — LaunchNotRefunding - -#### `claimAdditionalTokenAllocation.test.ts` - -42. "sets and claims additional token allocation successfully, and only once" -43. "fails to claim additional token allocation if the launch doesn't have one" — NoAdditionalTokensRecipientSet - -#### `extendLaunch.test.ts` - -44. "successfully extends a live launch" — seconds_for_launch increases -45. "funders can still fund after original deadline if extended" -46. "close_launch respects new extended deadline" — fails before new deadline - -### Integration Test - -``` -tests/integration/launchpad_v8_full_lifecycle.test.ts -``` - -End-to-end test covering the full lifecycle including PP v2 unlock: -1. `initialize_launch` → verify zero supply, MintGovernor setup -2. `start_launch` -3. Multiple `fund` calls from different funders -4. Wait for launch period → `close_launch` -5. `set_funding_record_approval` for each funder -6. `settle_launch` → verify minting, DAO creation -7. `finalize_launch` → verify PP v2 setup, admin transfer -8. `claim` for each funder -9. `refund` for over-committed funders -10. `claim_additional_token_allocation` -11. (Optional) PP v2 `start_unlock` + `complete_unlock` cycle — verify tokens minted on demand via MintGovernor - ---- - -## CPI Chain Summary - -``` -v08_launchpad::initialize_launch - ├── mpl_token_metadata::create_metadata_accounts_v3 - ├── mint_governor::initialize_mint_governor - ├── mint_governor::add_mint_authority (launch_signer) - └── mint_governor::transfer_authority_to_governor - -v08_launchpad::settle_launch - ├── mint_governor::mint_tokens → base_vault - ├── futarchy::initialize_dao - ├── futarchy::provide_liquidity - ├── bid_wall::initialize_bid_wall (if configured) - ├── damm_v2::initialize_pool_with_dynamic_config - ├── mpl_token_metadata::update_metadata_accounts_v2 - └── token::transfer (USDC → DAO treasury) - -v08_launchpad::finalize_launch - ├── mint_governor::add_mint_authority (PP v2 PDA) - ├── performance_package_v2::initialize_performance_package - └── mint_governor::update_mint_governor_admin → DAO -``` - ---- - -## Implementation Order - -Build incrementally — each phase produces a testable program. Later phases layer on top without breaking earlier work. - -### Phase 1: Scaffolding + State - -Set up the `v08_launchpad` program crate, `lib.rs` with empty instruction stubs, constants, error enum, events module, and the `Launch` / `FundingRecord` state structs (with the new `mint_governor` field). Wire up Cargo dependencies (`mint_governor`, `performance_package_v2`, etc.). Add SDK2 `launchpad/v0.8/` directory with PDA helpers and type stubs. - -Verify: `anchor build -p v08_launchpad` compiles. - -### Phase 2: `initialize_launch` - -The entry point — everything depends on this. Implement the full instruction including the MintGovernor CPI chain (init governor → add mint authority → transfer authority). No minting. - -**Tests:** #1–5 - -### Phase 3: `start_launch` + `fund` + `close_launch` - -These are unchanged from v7 and can be ported directly. They form the fundraising lifecycle that `settle_launch` depends on. - -**Tests:** #6–20 - -### Phase 4: `set_funding_record_approval` - -Unchanged from v7. Needed before settle_launch can run on the happy path (approved amounts determine what gets minted). - -**Tests:** #21–26 - -### Phase 5: `settle_launch` - -The big one — mints tokens via MintGovernor then runs the full DAO/liquidity/Meteora flow. This is the most complex instruction and requires phases 2–4 to be working. - -**Tests:** #27–33 - -### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` - -Unchanged from v7. These operate on the post-settle state. - -**Tests:** #37–43 - -### Phase 7: `finalize_launch` - -The final instruction — adds PP v2 as authorized minter, initializes PP v2, transfers MintGovernor admin to DAO. Requires settle_launch to have run. - -**Tests:** #34–36 - -### Phase 8: `extend_launch` - -Unchanged from v7. Low priority since it's an admin-only emergency lever. - -**Tests:** #44–46 - -### Phase 9: Integration test - -Full lifecycle end-to-end — see Integration Test section above. From 1ac1065aa7e497859f8bb213db0ae34b6e592aa0 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 11 Apr 2026 03:32:07 +0200 Subject: [PATCH 073/100] kill vibes dir --- vibes/launchpad_v8.md | 260 ----------------------------------------- vibes/task-template.md | 54 --------- vibes/tasks.md | 67 ----------- 3 files changed, 381 deletions(-) delete mode 100644 vibes/launchpad_v8.md delete mode 100644 vibes/task-template.md delete mode 100644 vibes/tasks.md diff --git a/vibes/launchpad_v8.md b/vibes/launchpad_v8.md deleted file mode 100644 index 7cc99a139..000000000 --- a/vibes/launchpad_v8.md +++ /dev/null @@ -1,260 +0,0 @@ -# Launchpad v8 Design Document - -## Overview - -Launchpad v8 is the next iteration of the launch program. The two key architectural changes are: - -1. **Mint Governor integration** — instead of transferring raw mint authority to the DAO on completion, the launchpad sets up a `MintGovernor` that provides structured, delegated minting -2. **Performance Package v2** — instead of pre-minting team tokens into a locked vault, tokens are minted on demand via `mint_governor` when milestones are achieved - -These changes shift the token model from **fixed supply at launch** to **structured dilution over time**, giving the DAO fine-grained control over who can mint and how much. - ---- - -## What Changes from v7 - -### v7 Token Flow (current) - -``` -initialize_launch: - mint ALL tokens upfront → - participants (10M) + futarchy_liq (2M) + damm_liq (900K) - + performance_package + additional_tokens - -settle_launch (v7: complete_launch): - transfer mint authority → squads_multisig_vault (raw, unrestricted) - -initialize_performance_package (v7 name): - CPI → price_based_performance_package (v1) - tokens already pre-minted, transferred to PP vault -``` - -### v8 Token Flow (proposed) - -``` -initialize_launch: - 1. create token metadata (launch_signer is still raw mint authority) - 2. initialize MintGovernor (admin = launch_signer, create_key = launch_signer) - 3. add launch_signer as authorized_minter (max_total = known supply) - 4. transfer mint authority → MintGovernor PDA - 5. create base vault ATA (empty — no tokens minted yet) - - NO MINTING. MintGovernor owns the mint authority from the start. - launch_signer is admin throughout the launch lifecycle. - If the launch fails → zero tokens ever exist. - -settle_launch: - 1. mint_governor::mint_tokens → base vault (exact amount needed) - single mint: participants + futarchy_liq + damm_liq + additional_tokens - 2. initialize DAO (same as v7) - 3. provide liquidity (same as v7) - 4. distribute (same as v7) - (net zero CPI change: mint_tokens replaces the old set_authority call) - -finalize_launch: - 1. add PP v2 PDA as authorized_minter in MintGovernor (launch_signer still admin) - 2. initialize performance_package_v2 with oracle_reader + reward_function - 3. transfer MintGovernor admin → squads_multisig_vault (DAO) — final handoff - tokens minted on demand when milestones hit (via mint_governor CPI) -``` - -Fallback: if `settle_launch` CPI budget is too tight, move the mint back -to `initialize_launch` (just add a `mint_governor::mint_tokens` call at the end). -Everything else stays the same. - ---- - -## Architectural Decisions - -### Why MintGovernor instead of raw mint authority? - -In v7, `settle_launch` (then called `complete_launch`) transfers raw SPL mint authority to the DAO's squads vault. This means: -- Any squads vault transaction can mint unlimited tokens -- No per-program caps or audit trail at the protocol level -- The only gate is the Squads multisig approval - -With MintGovernor: -- The DAO admin (squads vault) controls who can mint via `add_mint_authority` / `remove_mint_authority` -- Each authorized minter can have a `max_total` cap -- All minting goes through `mint_governor::mint_tokens`, providing on-chain accounting (`total_minted`) -- The DAO can still reclaim raw authority via `reclaim_authority` if needed (escape hatch) - -### Why Performance Package v2 instead of v1? - -v1 (`price_based_performance_package`) pre-mints tokens into a vault. This has drawbacks: -- Tokens exist on day 1, diluting circulating supply accounting -- If milestones are never hit, tokens sit locked forever (but are counted in supply) -- Oracle reads raw bytes at offsets — fragile and tightly coupled to account layout - -v2 (`performance_package_v2`) mints on demand: -- Zero supply impact until milestones are actually achieved -- Cleaner oracle model (`OracleReader` enum: `Time`, `FutarchyTwap`) -- Flexible reward functions (`CliffLinear`, `Threshold`) -- The PP PDA acts as an `authorized_minter` in MintGovernor — clean CPI chain - ---- - -## Instruction Changes - -### `initialize_launch` - -**Changes from v7:** -- Remove `performance_package_token_amount` from mint calculation -- Remove `token::mint_to` — no minting at init time -- Set up MintGovernor infrastructure and transfer mint authority immediately -- Create base vault ATA (empty) -- Still store performance package config in `Launch` state for later use - -**New flow:** -1. `create_metadata_accounts_v3` — launch_signer is still the raw mint authority at this point, which metaplex requires -2. `mint_governor::initialize_mint_governor` — create_key = launch_signer, admin = launch_signer -3. `mint_governor::add_mint_authority` — launch_signer as authorized_minter, `max_total` = exact needed supply (`TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount`) -4. `mint_governor::transfer_authority_to_governor` — SPL mint authority moves from launch_signer → MintGovernor PDA -5. Create base vault ATA (empty) - -After this, the MintGovernor PDA owns mint authority and launch_signer is admin + authorized minter with unused `max_total`. No tokens exist. If the launch fails, none ever will. - -**Args changes:** -- Keep `performance_package_grantee`, `months_until_insiders_can_unlock`, `performance_package_token_amount` -- Same args as v7 — the tranche structure (5 tranches at 2x/4x/8x/16x/32x) is derived from these at `finalize_launch` time, just targeting PP v2 instead of v1 - -**New accounts needed:** -- `mint_governor` — MintGovernor PDA (initialized via CPI) -- `mint_authority` — MintAuthority PDA for launch_signer (initialized via CPI) -- `mint_governor_program` — the MintGovernor program -- `mint_governor_event_authority` — for CPI events - -### `settle_launch` - -**(v7: `complete_launch`)** - -**Changes from v7:** -- Remove `transfer_mint_authority_to_dao()` (`token::set_authority`) -- Add: `mint_governor::mint_tokens` — single mint of exact needed supply into base vault -- Net zero CPI change: one in, one out -- Everything else stays the same (DAO init, liquidity, Meteora, bid wall, etc.) - -The mint happens at the top of the handler, before any distribution. At this point -we know `total_approved_amount` and can compute exact allocations. The base vault -ATA already exists (created during `initialize_launch`, just empty). - -**Net account impact:** Roughly neutral. We swap `base_mint` authority accounts -for `mint_governor` + `mint_authority` + `mint_governor_program` accounts. - -**New accounts needed:** -- `mint_governor` — the MintGovernor PDA (already exists from init) -- `mint_authority` — the MintAuthority PDA for launch_signer (already exists from init) -- `mint_governor_program` — for the mint CPI -- `mint_governor_event_authority` — for CPI events - -### `finalize_launch` - -**Major rewrite — now targets performance_package_v2:** - -1. CPI → `mint_governor::add_mint_authority` to register the PP v2 PDA as an authorized minter - - Requires DAO admin (squads_multisig_vault) as signer → **reentrancy concern** - - Alternative: the launchpad_signer could be a temporary admin, add the authority, then transfer admin to DAO -2. CPI → `performance_package_v2::initialize_performance_package` with: - - `oracle_reader`: `FutarchyTwap { amm: dao.key(), min_duration: 3_months }` (same TWAP concept as v7) - - `reward_function`: `Threshold` with price-based tranches (2x, 4x, 8x, 16x, 32x of launch price) - - `min_unlock_timestamp`: completion time + lockup months - - `recipient`: performance_package_grantee from launch config - - `authority`: squads_multisig_vault (DAO) - -**Key difference from v7:** No token transfer. The PP v2 will CPI into mint_governor to mint tokens when milestones are hit. - -**Admin transfer happens here — not in `settle_launch`.** -The launch_signer stays MintGovernor admin through `settle_launch` so that -`finalize_launch` can add the PP v2 PDA as an authorized minter -without needing a Squads transaction. The admin transfer to squads_multisig_vault -is the very last operation in the launch lifecycle — after all minting -infrastructure is fully wired up. - -### Removed / unchanged instructions - -| Instruction | Status | -|---|---| -| `start_launch` | Unchanged | -| `fund` | Unchanged | -| `set_funding_record_approval` | Unchanged | -| `complete_launch` | Renamed → `settle_launch` | -| `claim` | Unchanged | -| `refund` | Unchanged | -| `close_launch` | Unchanged | -| `claim_additional_token_allocation` | Unchanged | -| `extend_launch` | Unchanged | -| `initialize_performance_package` | Renamed → `finalize_launch` | - ---- - -## State Changes - -### `Launch` account - -**Fields to add:** -- `mint_governor: Pubkey` — set at initialization (not optional — always present in v8) -- Performance package v2 config fields (or keep existing fields and derive v2 config from them) - -**Fields to keep:** -- `performance_package_token_amount` — no longer pre-minted, but still used to derive the PP v2 reward function at `finalize_launch` time -- `is_performance_package_initialized` — still needed to gate the instruction - -The tranche structure remains hardcoded and opinionated (5 tranches at 2x/4x/8x/16x/32x of launch price), same as v7. The only change is the target program (PP v2 + mint_governor instead of v1 vault). - ---- - -## CPI Chain - -``` -launchpad_v8::initialize_launch - ├── mpl_token_metadata::create_metadata_accounts_v3 (launch_signer is raw authority) - ├── mint_governor::initialize_mint_governor (admin = launch_signer) - ├── mint_governor::add_mint_authority (launch_signer, max_total = known supply) - └── mint_governor::transfer_authority_to_governor (mint auth → MintGovernor PDA) - (base vault ATA created via anchor init_if_needed, empty — no minting) - -launchpad_v8::settle_launch - ├── mint_governor::mint_tokens → base vault (replaces old token::set_authority) - ├── futarchy::initialize_dao (same as v7) - ├── futarchy::provide_liquidity (same as v7) - ├── bid_wall::initialize_bid_wall (same as v7, if configured) - ├── damm_v2::initialize_pool_with_dynamic_config (same as v7) - ├── mpl_token_metadata::update_metadata_accounts_v2 (metadata authority → DAO) - └── token::transfer USDC to DAO treasury (same as v7) - -launchpad_v8::finalize_launch (separate tx, post-completion) - ├── mint_governor::add_mint_authority (PP v2 PDA as authorized_minter) - ├── performance_package_v2::initialize_performance_package - └── mint_governor::update_mint_governor_admin → squads_multisig_vault -``` - -Fallback: if settle_launch CPI budget is too tight, move mint_tokens -back to initialize_launch. Everything else stays the same. - ---- - -## Open Questions - -1. (none currently) - -### Resolved - -- ~~Account pressure on `initialize_launch`~~ — v7 has ~15 accounts and 2 CPIs. v8 adds ~4 accounts and 2 net CPIs (~19 accounts, 4 CPIs total). Well within limits. -- ~~Migration path~~ — fresh program deploy, new program ID. -- ~~`additional_tokens_amount` minting~~ — included in the single `mint_governor::mint_tokens` call in `settle_launch`, part of launch_signer's `max_total`. -- ~~MintGovernor `max_total` for PP v2~~ — set to `performance_package_token_amount`. Deterministic from the hardcoded 5-tranche threshold reward function. -- ~~Metadata authority~~ — unchanged from v7, transferred to DAO via `update_metadata_accounts_v2` in `settle_launch`. - ---- - -## Dependencies - -| Program | Role in v8 | -|---|---| -| `futarchy` | DAO initialization, AMM liquidity | -| `squads_multisig` | DAO authority, spending limits | -| `mint_governor` | **NEW** — structured minting authority | -| `performance_package_v2` | **NEW** — milestone-based token rewards | -| `damm_v2_cpi` | Meteora pool creation | -| `bid_wall` | Price floor mechanism | -| `mpl_token_metadata` | Token metadata | diff --git a/vibes/task-template.md b/vibes/task-template.md deleted file mode 100644 index 85574d7c5..000000000 --- a/vibes/task-template.md +++ /dev/null @@ -1,54 +0,0 @@ -# [Feature Name] Implementation Tasks - -## Instructions for Claude - -**READ THIS FIRST:** - -1. Look at this file and find the task marked with `[NEXT]` -2. Read the referenced section in `vibes/[implementation-plan].md` for full context -3. Do ONLY that task - nothing else -4. After completing the task, verify with `[verification command]` -5. If successful, remove the completed task from this file -6. Mark the next task with `[NEXT]` -7. Stop and wait for the user - -**DO NOT:** -- Do multiple tasks at once -- Skip ahead -- Forget to verify - -**Reference:** Full implementation plan is in `vibes/[implementation-plan].md` - ---- - -## Tasks - -### Phase N: [Phase Name] - -> Reference: `[implementation-plan].md` → "Phase N: [Phase Name]" - -- [NEXT] N.1 [Task title] - - [Detail about what to do] - - [Another detail] - - [File to create/modify] - -- [ ] N.2 [Task title] - - Reference: Section N.2 - - [Detail about what to do] - - [Accounts/Args/Other specifics] - -- [ ] N.3 [Task title] - - Reference: Section N.3 - - [Detail 1] - - [Detail 2] - - [Detail 3] - -### Phase M: [Next Phase Name] - -> Reference: `[implementation-plan].md` → "Phase M: [Next Phase Name]" - -- [ ] M.1 [Task title] - - [Details...] - -- [ ] M.2 [Task title] - - [Details...] diff --git a/vibes/tasks.md b/vibes/tasks.md deleted file mode 100644 index 26bd0430c..000000000 --- a/vibes/tasks.md +++ /dev/null @@ -1,67 +0,0 @@ -# Launchpad v8 Implementation Tasks - -## Instructions for Claude - -**READ THIS FIRST:** - -1. Look at this file and find the task marked with `[NEXT]` -2. Read the referenced section in `vibes/launchpad_v8_spec.md` for full context -3. Do ONLY that task - nothing else -4. After completing the task, verify with the specified verification command -5. If successful, remove the completed task from this file -6. Mark the next task with `[NEXT]` -7. Stop and wait for the user - -**DO NOT:** -- Do multiple tasks at once -- Skip ahead -- Forget to verify - -**IMPORTANT:** After completing a task, always run `./rebuild.sh` before handing back to the user. This rebuilds programs, regenerates SDK types, syncs node_modules, and lints. - -**Reference:** Full implementation plan is in `vibes/launchpad_v8_spec.md` - ---- - -## Tasks - -### Phase 1: Scaffolding + State - -> Reference: `launchpad_v8_spec.md` → "Constants", "State", "Errors", "Events" - -### Phase 2: `initialize_launch` - -> Reference: `launchpad_v8_spec.md` → "1. initialize_launch — CHANGED" - -### Phase 3: `start_launch` + `fund` + `close_launch` - -> Reference: `launchpad_v8_spec.md` → instructions 2, 3, 5 - -### Phase 4: `set_funding_record_approval` - -> Reference: `launchpad_v8_spec.md` → instruction 4 - -### Phase 5: `settle_launch` - -> Reference: `launchpad_v8_spec.md` → "6. settle_launch — CHANGED" - -### Phase 6: `claim` + `refund` + `claim_additional_token_allocation` - -> Reference: `launchpad_v8_spec.md` → instructions 8, 9, 10 - -### Phase 7: `finalize_launch` - -> Reference: `launchpad_v8_spec.md` → "7. finalize_launch — CHANGED" - -### Phase 8: `extend_launch` - -> Reference: `launchpad_v8_spec.md` → instruction 11 - -### Phase 9: Integration + Full Suite - -> Reference: `launchpad_v8_spec.md` → "Integration Test" - -- [NEXT] 9.2 Run full test suite - - Remove all `.only` markers - - Run `anchor test` (full build + all tests) - - All 46 unit tests + integration test must pass From 16a79a05dd795e936e1fa617b444bdc33555ed3e Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 15 Apr 2026 18:48:38 +0200 Subject: [PATCH 074/100] apply latest program changes to new SDK --- sdk2/src/futarchy/v0.6/types/futarchy.ts | 82 ++++++++++++++----- .../futarchy/unit/unstakeFromProposal.test.ts | 2 +- 2 files changed, 61 insertions(+), 23 deletions(-) diff --git a/sdk2/src/futarchy/v0.6/types/futarchy.ts b/sdk2/src/futarchy/v0.6/types/futarchy.ts index 491a7d42d..9592b6385 100644 --- a/sdk2/src/futarchy/v0.6/types/futarchy.ts +++ b/sdk2/src/futarchy/v0.6/types/futarchy.ts @@ -1344,17 +1344,19 @@ export type Futarchy = { isSigner: false; }, { - name: "squadsMultisigVaultTransaction"; + name: "squadsMultisigProgram"; isMut: false; isSigner: false; }, + ]; + args: [ { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; + name: "args"; + type: { + defined: "AdminApproveMultisigProposalArgs"; + }; }, ]; - args: []; }, { name: "adminExecuteMultisigProposal"; @@ -1985,6 +1987,18 @@ export type Futarchy = { ]; }; }, + { + name: "AdminApproveMultisigProposalArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "transactionIndex"; + type: "u64"; + }, + ]; + }; + }, { name: "ConditionalSwapParams"; type: { @@ -3698,36 +3712,41 @@ export type Futarchy = { }, { code: 6037; + name: "ProposalNotReadyToUnstake"; + msg: "Proposal is not ready to be unstaked"; + }, + { + code: 6038; name: "InvalidRecipient"; msg: "Invalid recipient"; }, { - code: 6038; + code: 6039; name: "OptimisticGovernanceDisabled"; msg: "Optimistic governance is disabled"; }, { - code: 6039; + code: 6040; name: "ActiveOptimisticProposalAlreadyEnqueued"; msg: "An active optimistic proposal is already enqueued"; }, { - code: 6040; + code: 6041; name: "NoActiveOptimisticProposal"; msg: "No active optimistic proposal"; }, { - code: 6041; + code: 6042; name: "OptimisticProposalAlreadyPassed"; msg: "Optimistic proposal has already passed"; }, { - code: 6042; + code: 6043; name: "CannotSponsorOptimisticProposalChallenge"; msg: "Team cannot sponsor a challenge to an optimistic proposal"; }, { - code: 6043; + code: 6044; name: "InvalidSpendingLimitMint"; msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; }, @@ -5080,17 +5099,19 @@ export const IDL: Futarchy = { isSigner: false, }, { - name: "squadsMultisigVaultTransaction", + name: "squadsMultisigProgram", isMut: false, isSigner: false, }, + ], + args: [ { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, + name: "args", + type: { + defined: "AdminApproveMultisigProposalArgs", + }, }, ], - args: [], }, { name: "adminExecuteMultisigProposal", @@ -5721,6 +5742,18 @@ export const IDL: Futarchy = { ], }, }, + { + name: "AdminApproveMultisigProposalArgs", + type: { + kind: "struct", + fields: [ + { + name: "transactionIndex", + type: "u64", + }, + ], + }, + }, { name: "ConditionalSwapParams", type: { @@ -7434,36 +7467,41 @@ export const IDL: Futarchy = { }, { code: 6037, + name: "ProposalNotReadyToUnstake", + msg: "Proposal is not ready to be unstaked", + }, + { + code: 6038, name: "InvalidRecipient", msg: "Invalid recipient", }, { - code: 6038, + code: 6039, name: "OptimisticGovernanceDisabled", msg: "Optimistic governance is disabled", }, { - code: 6039, + code: 6040, name: "ActiveOptimisticProposalAlreadyEnqueued", msg: "An active optimistic proposal is already enqueued", }, { - code: 6040, + code: 6041, name: "NoActiveOptimisticProposal", msg: "No active optimistic proposal", }, { - code: 6041, + code: 6042, name: "OptimisticProposalAlreadyPassed", msg: "Optimistic proposal has already passed", }, { - code: 6042, + code: 6043, name: "CannotSponsorOptimisticProposalChallenge", msg: "Team cannot sponsor a challenge to an optimistic proposal", }, { - code: 6043, + code: 6044, name: "InvalidSpendingLimitMint", msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", }, diff --git a/tests/futarchy/unit/unstakeFromProposal.test.ts b/tests/futarchy/unit/unstakeFromProposal.test.ts index 609560a08..7271c56ff 100644 --- a/tests/futarchy/unit/unstakeFromProposal.test.ts +++ b/tests/futarchy/unit/unstakeFromProposal.test.ts @@ -1,7 +1,7 @@ import { InstructionUtils, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy-v2"; import { ComputeBudgetProgram, PublicKey, From c3a60d07bda773e2585524736620bc77c5527e08 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 15 Apr 2026 22:26:10 +0200 Subject: [PATCH 075/100] remove unnecessary logic from initialize_launch --- .../src/instructions/initialize_launch.rs | 48 ++++++------------- sdk/src/v0.7/types/launchpad_v8.ts | 16 ------- sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 16 ------- .../unit/initializeLaunch.test.ts | 22 ++------- 4 files changed, 18 insertions(+), 84 deletions(-) diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs index 0cccedaea..44c6f5d76 100644 --- a/programs/v08_launchpad/src/instructions/initialize_launch.rs +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -4,11 +4,10 @@ use anchor_spl::token::{self, Mint, MintTo, Token, TokenAccount}; use mint_governor::{ cpi::{ - accounts::{AddMintAuthority, InitializeMintGovernor, TransferAuthorityToGovernor}, - add_mint_authority, initialize_mint_governor, transfer_authority_to_governor, + accounts::{InitializeMintGovernor, TransferAuthorityToGovernor}, + initialize_mint_governor, transfer_authority_to_governor, }, program::MintGovernor as MintGovernorProgram, - AddMintAuthorityArgs, }; use crate::error::LaunchpadError; @@ -103,16 +102,22 @@ pub struct InitializeLaunch<'info> { /// CHECK: Just the recipient of the additional tokens pub additional_tokens_recipient: Option>, - /// PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)] - /// Initialized via CPI to mint_governor::initialize_mint_governor /// CHECK: initialized via CPI - #[account(mut)] + #[account( + mut, + seeds = [b"mint_governor", base_mint.key().as_ref(), launch_signer.key().as_ref()], + bump, + seeds::program = mint_governor_program.key(), + )] pub mint_governor: UncheckedAccount<'info>, - /// PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)] - /// Initialized via CPI to mint_governor::add_mint_authority /// CHECK: initialized via CPI - #[account(mut)] + #[account( + mut, + seeds = [b"mint_authority", mint_governor.key().as_ref(), launch_signer.key().as_ref()], + bump, + seeds::program = mint_governor_program.key(), + )] pub mint_authority: UncheckedAccount<'info>, pub mint_governor_program: Program<'info, MintGovernorProgram>, @@ -334,31 +339,6 @@ impl InitializeLaunch<'_> { signer, ))?; - let max_total = TOKENS_TO_PARTICIPANTS - + TOKENS_TO_FUTARCHY_LIQUIDITY - + TOKENS_TO_DAMM_V2_LIQUIDITY - + args.additional_tokens_amount; - - add_mint_authority( - CpiContext::new_with_signer( - ctx.accounts.mint_governor_program.to_account_info(), - AddMintAuthority { - mint_governor: ctx.accounts.mint_governor.to_account_info(), - mint_authority: ctx.accounts.mint_authority.to_account_info(), - admin: ctx.accounts.launch_signer.to_account_info(), - authorized_minter: ctx.accounts.launch_signer.to_account_info(), - payer: ctx.accounts.payer.to_account_info(), - system_program: ctx.accounts.system_program.to_account_info(), - event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), - program: ctx.accounts.mint_governor_program.to_account_info(), - }, - signer, - ), - AddMintAuthorityArgs { - max_total: Some(max_total), - }, - )?; - transfer_authority_to_governor(CpiContext::new_with_signer( ctx.accounts.mint_governor_program.to_account_info(), TransferAuthorityToGovernor { diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 1b016e0eb..c24d6e0ae 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -60,19 +60,11 @@ export type LaunchpadV8 = { name: "mintGovernor"; isMut: true; isSigner: false; - docs: [ - 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', - "Initialized via CPI to mint_governor::initialize_mint_governor", - ]; }, { name: "mintAuthority"; isMut: true; isSigner: false; - docs: [ - 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', - "Initialized via CPI to mint_governor::add_mint_authority", - ]; }, { name: "mintGovernorProgram"; @@ -1960,19 +1952,11 @@ export const IDL: LaunchpadV8 = { name: "mintGovernor", isMut: true, isSigner: false, - docs: [ - 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', - "Initialized via CPI to mint_governor::initialize_mint_governor", - ], }, { name: "mintAuthority", isMut: true, isSigner: false, - docs: [ - 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', - "Initialized via CPI to mint_governor::add_mint_authority", - ], }, { name: "mintGovernorProgram", diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 1b016e0eb..c24d6e0ae 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -60,19 +60,11 @@ export type LaunchpadV8 = { name: "mintGovernor"; isMut: true; isSigner: false; - docs: [ - 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', - "Initialized via CPI to mint_governor::initialize_mint_governor", - ]; }, { name: "mintAuthority"; isMut: true; isSigner: false; - docs: [ - 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', - "Initialized via CPI to mint_governor::add_mint_authority", - ]; }, { name: "mintGovernorProgram"; @@ -1960,19 +1952,11 @@ export const IDL: LaunchpadV8 = { name: "mintGovernor", isMut: true, isSigner: false, - docs: [ - 'PDA: seeds = [b"mint_governor", base_mint, launch_signer (create_key)]', - "Initialized via CPI to mint_governor::initialize_mint_governor", - ], }, { name: "mintAuthority", isMut: true, isSigner: false, - docs: [ - 'PDA: seeds = [b"mint_authority", mint_governor, launch_signer (authorized_minter)]', - "Initialized via CPI to mint_governor::add_mint_authority", - ], }, { name: "mintGovernorProgram", diff --git a/tests/launchpad_v8/unit/initializeLaunch.test.ts b/tests/launchpad_v8/unit/initializeLaunch.test.ts index 1b1abb141..e1c5d6f2b 100644 --- a/tests/launchpad_v8/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v8/unit/initializeLaunch.test.ts @@ -131,32 +131,18 @@ export default function suite() { assert.ok(mintGovernorAccount.admin.equals(launchSigner)); assert.ok(mintGovernorAccount.mint.equals(META)); - // MintAuthority for launch_signer with correct max_total - const [expectedMintAuthority] = getMintAuthorityAddr({ - programId: mintGovernorClient.programId, - mintGovernor: expectedMintGovernor, - authorizedMinter: launchSigner, - }); - const mintAuthorityAccount = await mintGovernorClient.fetchMintAuthority( - expectedMintAuthority, - ); - assert.ok(mintAuthorityAccount.authorizedMinter.equals(launchSigner)); - // max_total = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount + // total_supply = TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY + additional_tokens_amount // = 10_000_000 + 2_000_000 + 900_000 + 0 = 12_900_000 tokens (scaled by 10^6) - const expectedMaxTotal = new BN("12900000000000"); // 12_900_000 * 1_000_000 - assert.equal( - mintAuthorityAccount.maxTotal.toString(), - expectedMaxTotal.toString(), - ); + const expectedTotalSupply = new BN("12900000000000"); // 12_900_000 * 1_000_000 // SPL mint authority is the MintGovernor PDA const mintInfo = await this.getMint(META); assert.ok(mintInfo.mintAuthority.equals(expectedMintGovernor)); // Tokens are minted during initialize_launch (before governor takes over) - assert.equal(mintInfo.supply.toString(), expectedMaxTotal.toString()); + assert.equal(mintInfo.supply.toString(), expectedTotalSupply.toString()); const baseVaultBalance = await this.getTokenBalance(META, launchSigner); - assert.equal(baseVaultBalance.toString(), expectedMaxTotal.toString()); + assert.equal(baseVaultBalance.toString(), expectedTotalSupply.toString()); }); it("fails when monthly spending limit members contains duplicates", async function () { From f5ce8b0af182e4bcee346600683ea8ffe2c0092b Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 15 Apr 2026 23:08:20 +0200 Subject: [PATCH 076/100] remove unnecessary event field, formatting --- programs/v08_launchpad/src/events.rs | 1 - .../v08_launchpad/src/instructions/fund.rs | 1 + .../src/instructions/settle_launch.rs | 31 ++++++++++++++----- sdk/src/v0.7/types/launchpad_v8.ts | 10 ------ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 10 ------ 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/programs/v08_launchpad/src/events.rs b/programs/v08_launchpad/src/events.rs index 3b1a25750..b4bcb8c98 100644 --- a/programs/v08_launchpad/src/events.rs +++ b/programs/v08_launchpad/src/events.rs @@ -85,7 +85,6 @@ pub struct LaunchSettledEvent { pub total_approved_amount: u64, pub bid_wall: Option, pub bid_wall_amount: u64, - pub mint_governor: Pubkey, pub tokens_minted: u64, } diff --git a/programs/v08_launchpad/src/instructions/fund.rs b/programs/v08_launchpad/src/instructions/fund.rs index 734215e6d..a4f182ce4 100644 --- a/programs/v08_launchpad/src/instructions/fund.rs +++ b/programs/v08_launchpad/src/instructions/fund.rs @@ -27,6 +27,7 @@ pub struct Fund<'info> { pub launch_quote_vault: Account<'info, TokenAccount>, pub funder: Signer<'info>, + #[account(mut)] pub payer: Signer<'info>, diff --git a/programs/v08_launchpad/src/instructions/settle_launch.rs b/programs/v08_launchpad/src/instructions/settle_launch.rs index d7b31a089..a80b07f99 100644 --- a/programs/v08_launchpad/src/instructions/settle_launch.rs +++ b/programs/v08_launchpad/src/instructions/settle_launch.rs @@ -187,7 +187,12 @@ pub struct SettleLaunch<'info> { pub quote_mint: Box>, /// CHECK: init by futarchy program - #[account(mut, seeds = [b"amm_position", dao.key().as_ref(), squads_multisig_vault.key().as_ref()], bump, seeds::program = static_accounts.futarchy_program)] + #[account( + mut, + seeds = [b"amm_position", dao.key().as_ref(), squads_multisig_vault.key().as_ref()], + bump, + seeds::program = static_accounts.futarchy_program + )] pub dao_owned_lp_position: UncheckedAccount<'info>, /// CHECK: checked by futarchy program @@ -203,13 +208,27 @@ pub struct SettleLaunch<'info> { pub dao: UncheckedAccount<'info>, /// CHECK: checked by futarchy program - #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = static_accounts.squads_program)] + #[account( + mut, + seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], + bump, + seeds::program = static_accounts.squads_program + )] pub squads_multisig: UncheckedAccount<'info>, /// CHECK: just a signer - #[account(seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], bump, seeds::program = static_accounts.squads_program)] + #[account( + seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_VAULT, 0_u8.to_le_bytes().as_ref()], + bump, + seeds::program = static_accounts.squads_program + )] pub squads_multisig_vault: UncheckedAccount<'info>, /// CHECK: initialized by squads - #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], bump, seeds::program = static_accounts.squads_program)] + #[account( + mut, + seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig.key().as_ref(), squads_multisig_program::SEED_SPENDING_LIMIT, dao.key().as_ref()], + bump, + seeds::program = static_accounts.squads_program + )] pub spending_limit: UncheckedAccount<'info>, /// CHECK: checked by bid wall program @@ -302,9 +321,6 @@ impl SettleLaunch<'_> { ]; let launch_signer = &[&launch_signer_seeds[..]]; - // Tokens were already minted into launch_base_vault during initialize_launch - // (moved there to stay within CPI depth limits during settlement). - let price_1e12 = ((launch_total_approved_amount as u128) * PRICE_SCALE) / (TOKENS_TO_PARTICIPANTS as u128); @@ -370,7 +386,6 @@ impl SettleLaunch<'_> { None }, bid_wall_amount: usdc_to_bid_wall, - mint_governor: launch.mint_governor, tokens_minted: TOKENS_TO_PARTICIPANTS + TOKENS_TO_FUTARCHY_LIQUIDITY + TOKENS_TO_DAMM_V2_LIQUIDITY diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index c24d6e0ae..bc7438e5b 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -1529,11 +1529,6 @@ export type LaunchpadV8 = { type: "u64"; index: false; }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, { name: "tokensMinted"; type: "u64"; @@ -3421,11 +3416,6 @@ export const IDL: LaunchpadV8 = { type: "u64", index: false, }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, { name: "tokensMinted", type: "u64", diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index c24d6e0ae..bc7438e5b 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -1529,11 +1529,6 @@ export type LaunchpadV8 = { type: "u64"; index: false; }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, { name: "tokensMinted"; type: "u64"; @@ -3421,11 +3416,6 @@ export const IDL: LaunchpadV8 = { type: "u64", index: false, }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, { name: "tokensMinted", type: "u64", From d534e557c1e1e7bdc20506e839a6f9175e95bbf8 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 15 Apr 2026 23:33:40 +0200 Subject: [PATCH 077/100] proper naming, more checks --- .../src/instructions/finalize_launch.rs | 23 +++++++++++------- .../src/instructions/initialize_launch.rs | 2 +- programs/v08_launchpad/src/state/launch.rs | 4 ++-- sdk/src/v0.7/types/launchpad_v8.ts | 24 ++++--------------- sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 24 ++++--------------- .../launchpad_v8_full_lifecycle.test.ts | 6 ++--- .../launchpad_v8/unit/finalizeLaunch.test.ts | 4 ++-- .../unit/initializeLaunch.test.ts | 1 + 8 files changed, 31 insertions(+), 57 deletions(-) diff --git a/programs/v08_launchpad/src/instructions/finalize_launch.rs b/programs/v08_launchpad/src/instructions/finalize_launch.rs index 96ecf238b..52e5af6b5 100644 --- a/programs/v08_launchpad/src/instructions/finalize_launch.rs +++ b/programs/v08_launchpad/src/instructions/finalize_launch.rs @@ -86,17 +86,22 @@ pub struct FinalizeLaunch<'info> { #[account(mut)] pub mint_governor: Account<'info, MintGovernor>, - /// MintAuthority for PP v2 PDA — initialized via CPI - /// PDA: seeds = [b"mint_authority", mint_governor, performance_package] /// CHECK: initialized via CPI - #[account(mut)] + #[account( + mut, + seeds = [b"mint_authority", mint_governor.key().as_ref(), performance_package.key().as_ref()], + bump, + seeds::program = mint_governor_program.key(), + )] pub pp_mint_authority: UncheckedAccount<'info>, - // Performance Package v2 - /// PP v2 account — initialized via CPI - /// PDA: seeds = [b"performance_package", launch_signer (create_key)] /// CHECK: initialized via CPI - #[account(mut)] + #[account( + mut, + seeds = [b"performance_package", launch_signer.key().as_ref()], + bump, + seeds::program = performance_package_v2_program.key(), + )] pub performance_package: UncheckedAccount<'info>, // Programs @@ -118,7 +123,7 @@ impl FinalizeLaunch<'_> { LaunchpadError::InvalidLaunchState ); require!( - !self.launch.is_performance_package_initialized, + !self.launch.is_finalized, LaunchpadError::PerformancePackageAlreadyInitialized ); Ok(()) @@ -225,7 +230,7 @@ impl FinalizeLaunch<'_> { ))?; let launch = &mut ctx.accounts.launch; - launch.is_performance_package_initialized = true; + launch.is_finalized = true; launch.seq_num += 1; let clock = Clock::get()?; diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs index 44c6f5d76..c5dfba23d 100644 --- a/programs/v08_launchpad/src/instructions/initialize_launch.rs +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -258,7 +258,7 @@ impl InitializeLaunch<'_> { .map(|a| a.key()), additional_tokens_claimed: false, unix_timestamp_completed: None, - is_performance_package_initialized: false, + is_finalized: false, accumulator_activation_delay_seconds: args.accumulator_activation_delay_seconds, has_bid_wall: args.has_bid_wall, mint_governor: ctx.accounts.mint_governor.key(), diff --git a/programs/v08_launchpad/src/state/launch.rs b/programs/v08_launchpad/src/state/launch.rs index 5558c90b9..4d92dccf8 100644 --- a/programs/v08_launchpad/src/state/launch.rs +++ b/programs/v08_launchpad/src/state/launch.rs @@ -84,8 +84,8 @@ pub struct Launch { pub additional_tokens_claimed: bool, /// The unix timestamp when the launch was completed. pub unix_timestamp_completed: Option, - /// Whether the performance package has been initialized. - pub is_performance_package_initialized: bool, + /// Whether the launch has been finalized. + pub is_finalized: bool, /// Number of seconds after launch start before the funding accumulator /// begins tracking. pub accumulator_activation_delay_seconds: u32, diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index bc7438e5b..b47e1988f 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -742,19 +742,11 @@ export type LaunchpadV8 = { name: "ppMintAuthority"; isMut: true; isSigner: false; - docs: [ - "MintAuthority for PP v2 PDA — initialized via CPI", - 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', - ]; }, { name: "performancePackage"; isMut: true; isSigner: false; - docs: [ - "PP v2 account — initialized via CPI", - 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', - ]; }, { name: "systemProgram"; @@ -1089,8 +1081,8 @@ export type LaunchpadV8 = { }; }, { - name: "isPerformancePackageInitialized"; - docs: ["Whether the performance package has been initialized."]; + name: "isFinalized"; + docs: ["Whether the launch has been finalized."]; type: "bool"; }, { @@ -2629,19 +2621,11 @@ export const IDL: LaunchpadV8 = { name: "ppMintAuthority", isMut: true, isSigner: false, - docs: [ - "MintAuthority for PP v2 PDA — initialized via CPI", - 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', - ], }, { name: "performancePackage", isMut: true, isSigner: false, - docs: [ - "PP v2 account — initialized via CPI", - 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', - ], }, { name: "systemProgram", @@ -2976,8 +2960,8 @@ export const IDL: LaunchpadV8 = { }, }, { - name: "isPerformancePackageInitialized", - docs: ["Whether the performance package has been initialized."], + name: "isFinalized", + docs: ["Whether the launch has been finalized."], type: "bool", }, { diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index bc7438e5b..b47e1988f 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -742,19 +742,11 @@ export type LaunchpadV8 = { name: "ppMintAuthority"; isMut: true; isSigner: false; - docs: [ - "MintAuthority for PP v2 PDA — initialized via CPI", - 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', - ]; }, { name: "performancePackage"; isMut: true; isSigner: false; - docs: [ - "PP v2 account — initialized via CPI", - 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', - ]; }, { name: "systemProgram"; @@ -1089,8 +1081,8 @@ export type LaunchpadV8 = { }; }, { - name: "isPerformancePackageInitialized"; - docs: ["Whether the performance package has been initialized."]; + name: "isFinalized"; + docs: ["Whether the launch has been finalized."]; type: "bool"; }, { @@ -2629,19 +2621,11 @@ export const IDL: LaunchpadV8 = { name: "ppMintAuthority", isMut: true, isSigner: false, - docs: [ - "MintAuthority for PP v2 PDA — initialized via CPI", - 'PDA: seeds = [b"mint_authority", mint_governor, performance_package]', - ], }, { name: "performancePackage", isMut: true, isSigner: false, - docs: [ - "PP v2 account — initialized via CPI", - 'PDA: seeds = [b"performance_package", launch_signer (create_key)]', - ], }, { name: "systemProgram", @@ -2976,8 +2960,8 @@ export const IDL: LaunchpadV8 = { }, }, { - name: "isPerformancePackageInitialized", - docs: ["Whether the performance package has been initialized."], + name: "isFinalized", + docs: ["Whether the launch has been finalized."], type: "bool", }, { diff --git a/tests/integration/launchpad_v8_full_lifecycle.test.ts b/tests/integration/launchpad_v8_full_lifecycle.test.ts index ec9b710d3..5c05be460 100644 --- a/tests/integration/launchpad_v8_full_lifecycle.test.ts +++ b/tests/integration/launchpad_v8_full_lifecycle.test.ts @@ -296,7 +296,7 @@ export default async function suite() { // ===================== // 7. finalize_launch → verify PP v2 setup, MintGovernor admin transfer // ===================== - assert.equal(launchAccount.isPerformancePackageInitialized, false); + assert.equal(launchAccount.isFinalized, false); await launchpadClient .finalizeLaunchIx({ @@ -307,7 +307,7 @@ export default async function suite() { .rpc(); launchAccount = await launchpadClient.fetchLaunch(launch); - assert.equal(launchAccount.isPerformancePackageInitialized, true); + assert.equal(launchAccount.isFinalized, true); // Verify MintGovernor admin transferred to DAO squads vault const daoAddr = launchpadClient.getLaunchDaoAddress({ launch }); @@ -432,6 +432,6 @@ export default async function suite() { ); launchAccount = await launchpadClient.fetchLaunch(launch); - assert.equal(launchAccount.additionalTokensClaimed, true); + assert.isTrue(launchAccount.additionalTokensClaimed); }); } diff --git a/tests/launchpad_v8/unit/finalizeLaunch.test.ts b/tests/launchpad_v8/unit/finalizeLaunch.test.ts index 00ddc7c50..ba5426796 100644 --- a/tests/launchpad_v8/unit/finalizeLaunch.test.ts +++ b/tests/launchpad_v8/unit/finalizeLaunch.test.ts @@ -147,7 +147,7 @@ export default function suite() { // Verify launch is Complete before finalize let launchAccount = await launchpadClient.fetchLaunch(launch); assert.deepEqual(launchAccount.state, { complete: {} }); - assert.equal(launchAccount.isPerformancePackageInitialized, false); + assert.equal(launchAccount.isFinalized, false); // Finalize await launchpadClient @@ -160,7 +160,7 @@ export default function suite() { // Reload launch state launchAccount = await launchpadClient.fetchLaunch(launch); - assert.equal(launchAccount.isPerformancePackageInitialized, true); + assert.equal(launchAccount.isFinalized, true); // Derive expected addresses const mintGovernorAddr = launchpadClient.getMintGovernorAddress({ diff --git a/tests/launchpad_v8/unit/initializeLaunch.test.ts b/tests/launchpad_v8/unit/initializeLaunch.test.ts index e1c5d6f2b..566654908 100644 --- a/tests/launchpad_v8/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v8/unit/initializeLaunch.test.ts @@ -115,6 +115,7 @@ export default function suite() { assert.isNull(storedLaunch.dao); assert.equal(storedLaunch.accumulatorActivationDelaySeconds, 0); assert.isTrue(storedLaunch.hasBidWall); + assert.isFalse(storedLaunch.isFinalized); // MintGovernor PDA stored on launch const mintGovernorClient = launchpadClient.mintGovernorClient; From fc9876f20ba4de3bd3ebab33597394897b3bbc4f Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 16 Apr 2026 00:01:36 +0200 Subject: [PATCH 078/100] add immediate ability to mint to dao's squads multisig vault --- programs/v08_launchpad/src/events.rs | 1 + .../src/instructions/finalize_launch.rs | 29 +++++++++++++++++++ sdk/src/v0.7/types/launchpad_v8.ts | 20 +++++++++++++ sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 7 +++++ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 20 +++++++++++++ .../launchpad_v8_full_lifecycle.test.ts | 14 +++++++++ .../launchpad_v8/unit/finalizeLaunch.test.ts | 14 +++++++++ 7 files changed, 105 insertions(+) diff --git a/programs/v08_launchpad/src/events.rs b/programs/v08_launchpad/src/events.rs index b4bcb8c98..01062aae5 100644 --- a/programs/v08_launchpad/src/events.rs +++ b/programs/v08_launchpad/src/events.rs @@ -96,6 +96,7 @@ pub struct LaunchFinalizedEvent { pub mint_governor: Pubkey, pub mint_governor_new_admin: Pubkey, pub pp_mint_authority: Pubkey, + pub dao_mint_authority: Pubkey, } #[event] diff --git a/programs/v08_launchpad/src/instructions/finalize_launch.rs b/programs/v08_launchpad/src/instructions/finalize_launch.rs index 52e5af6b5..45bf49a2f 100644 --- a/programs/v08_launchpad/src/instructions/finalize_launch.rs +++ b/programs/v08_launchpad/src/instructions/finalize_launch.rs @@ -95,6 +95,15 @@ pub struct FinalizeLaunch<'info> { )] pub pp_mint_authority: UncheckedAccount<'info>, + /// CHECK: initialized via CPI + #[account( + mut, + seeds = [b"mint_authority", mint_governor.key().as_ref(), squads_multisig_vault.key().as_ref()], + bump, + seeds::program = mint_governor_program.key(), + )] + pub dao_mint_authority: UncheckedAccount<'info>, + /// CHECK: initialized via CPI #[account( mut, @@ -172,6 +181,25 @@ impl FinalizeLaunch<'_> { }, )?; + // CPI → mint_governor::add_mint_authority (DAO) + add_mint_authority( + CpiContext::new_with_signer( + ctx.accounts.mint_governor_program.to_account_info(), + AddMintAuthority { + mint_governor: ctx.accounts.mint_governor.to_account_info(), + mint_authority: ctx.accounts.dao_mint_authority.to_account_info(), + admin: ctx.accounts.launch_signer.to_account_info(), + authorized_minter: ctx.accounts.squads_multisig_vault.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + event_authority: ctx.accounts.mint_governor_event_authority.to_account_info(), + program: ctx.accounts.mint_governor_program.to_account_info(), + }, + signer, + ), + AddMintAuthorityArgs { max_total: None }, + )?; + // CPI → performance_package_v2::initialize_performance_package let min_unlock_timestamp = ctx.accounts.launch.unix_timestamp_completed.unwrap() + (ctx.accounts.launch.months_until_insiders_can_unlock as i64) * 30 * 24 * 60 * 60; @@ -241,6 +269,7 @@ impl FinalizeLaunch<'_> { mint_governor: ctx.accounts.mint_governor.key(), mint_governor_new_admin: ctx.accounts.squads_multisig_vault.key(), pp_mint_authority: ctx.accounts.pp_mint_authority.key(), + dao_mint_authority: ctx.accounts.dao_mint_authority.key(), }); Ok(()) diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index b47e1988f..12c4efc02 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -743,6 +743,11 @@ export type LaunchpadV8 = { isMut: true; isSigner: false; }, + { + name: "daoMintAuthority"; + isMut: true; + isSigner: false; + }, { name: "performancePackage"; isMut: true; @@ -1563,6 +1568,11 @@ export type LaunchpadV8 = { type: "publicKey"; index: false; }, + { + name: "daoMintAuthority"; + type: "publicKey"; + index: false; + }, ]; }, { @@ -2622,6 +2632,11 @@ export const IDL: LaunchpadV8 = { isMut: true, isSigner: false, }, + { + name: "daoMintAuthority", + isMut: true, + isSigner: false, + }, { name: "performancePackage", isMut: true, @@ -3442,6 +3457,11 @@ export const IDL: LaunchpadV8 = { type: "publicKey", index: false, }, + { + name: "daoMintAuthority", + type: "publicKey", + index: false, + }, ], }, { diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 192d967b8..9772f1e9e 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -725,6 +725,12 @@ export class LaunchpadClient { authorizedMinter: performancePackage, }); + const [daoMintAuthority] = getMintAuthorityAddr({ + programId: this.mintGovernorClient.programId, + mintGovernor, + authorizedMinter: squadsMultisigVault, + }); + const [mintGovernorEventAuthority] = getEventAuthorityAddr( this.mintGovernorClient.programId, ); @@ -745,6 +751,7 @@ export class LaunchpadClient { performancePackageGrantee, mintGovernor, ppMintAuthority, + daoMintAuthority, performancePackage, squadsProgram: SQUADS_PROGRAM_ID, mintGovernorProgram: this.mintGovernorClient.programId, diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index b47e1988f..12c4efc02 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -743,6 +743,11 @@ export type LaunchpadV8 = { isMut: true; isSigner: false; }, + { + name: "daoMintAuthority"; + isMut: true; + isSigner: false; + }, { name: "performancePackage"; isMut: true; @@ -1563,6 +1568,11 @@ export type LaunchpadV8 = { type: "publicKey"; index: false; }, + { + name: "daoMintAuthority"; + type: "publicKey"; + index: false; + }, ]; }, { @@ -2622,6 +2632,11 @@ export const IDL: LaunchpadV8 = { isMut: true, isSigner: false, }, + { + name: "daoMintAuthority", + isMut: true, + isSigner: false, + }, { name: "performancePackage", isMut: true, @@ -3442,6 +3457,11 @@ export const IDL: LaunchpadV8 = { type: "publicKey", index: false, }, + { + name: "daoMintAuthority", + type: "publicKey", + index: false, + }, ], }, { diff --git a/tests/integration/launchpad_v8_full_lifecycle.test.ts b/tests/integration/launchpad_v8_full_lifecycle.test.ts index 5c05be460..aa1bf1d32 100644 --- a/tests/integration/launchpad_v8_full_lifecycle.test.ts +++ b/tests/integration/launchpad_v8_full_lifecycle.test.ts @@ -336,6 +336,20 @@ export default async function suite() { ppAccount.recipient.equals(launchAccount.performancePackageGrantee), ); + // Verify DAO MintAuthority was created for the squads_multisig_vault + const daoMintAuthorityAddr = launchpadClient.getMintAuthorityAddress({ + mintGovernor: mintGovernorAddr, + authorizedMinter: squadsMultisigVault, + }); + const daoMintAuthorityAccount = + await launchpadClient.mintGovernorClient.fetchMintAuthority( + daoMintAuthorityAddr, + ); + assert.ok( + daoMintAuthorityAccount.authorizedMinter.equals(squadsMultisigVault), + ); + assert.isNull(daoMintAuthorityAccount.maxTotal); + // ===================== // 8. claim (each funder) // ===================== diff --git a/tests/launchpad_v8/unit/finalizeLaunch.test.ts b/tests/launchpad_v8/unit/finalizeLaunch.test.ts index ba5426796..957d7a277 100644 --- a/tests/launchpad_v8/unit/finalizeLaunch.test.ts +++ b/tests/launchpad_v8/unit/finalizeLaunch.test.ts @@ -216,6 +216,20 @@ export default function suite() { assert.ok( ppAccount.recipient.equals(launchAccount.performancePackageGrantee), ); + + // Verify DAO MintAuthority was created for the squads_multisig_vault + const daoMintAuthorityAddr = launchpadClient.getMintAuthorityAddress({ + mintGovernor: mintGovernorAddr, + authorizedMinter: squadsMultisigVault, + }); + const daoMintAuthorityAccount = + await launchpadClient.mintGovernorClient.fetchMintAuthority( + daoMintAuthorityAddr, + ); + assert.ok( + daoMintAuthorityAccount.authorizedMinter.equals(squadsMultisigVault), + ); + assert.isNull(daoMintAuthorityAccount.maxTotal); }); it("fails when launch state is not Complete", async function () { From 4833ac5aeef38fd447d4ac20064e02472c691159 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 16 Apr 2026 15:01:01 +0200 Subject: [PATCH 079/100] add sdk2 to CI --- .github/workflows/anchor-test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/anchor-test.yaml b/.github/workflows/anchor-test.yaml index 9dfdd6f92..445fa6080 100644 --- a/.github/workflows/anchor-test.yaml +++ b/.github/workflows/anchor-test.yaml @@ -28,11 +28,15 @@ jobs: run: | cd sdk yarn install + cd ../sdk2 + yarn install - name: Build SDK run: | cd sdk yarn build + cd ../sdk2 + yarn build - uses: metadaoproject/anchor-test@v2.3 with: From 25af8ef9bd9f0f8dde210c09bb3f4f18ca3b93cd Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 16 Apr 2026 16:34:40 +0200 Subject: [PATCH 080/100] enable optimistic governance by default for DAOs initialized with a team address --- .../src/instructions/initialize_dao.rs | 3 ++- .../unit/finalizeOptimisticProposal.test.ts | 22 ---------------- tests/futarchy/unit/initializeDao.test.ts | 7 ++++-- .../futarchy/unit/initializeProposal.test.ts | 24 ------------------ ...itiateVaultSpendOptimisticProposal.test.ts | 2 -- tests/futarchy/unit/launchProposal.test.ts | 25 ------------------- tests/futarchy/unit/updateDao.test.ts | 25 +------------------ 7 files changed, 8 insertions(+), 100 deletions(-) diff --git a/programs/futarchy/src/instructions/initialize_dao.rs b/programs/futarchy/src/instructions/initialize_dao.rs index 64fe30be7..c7a689e3b 100644 --- a/programs/futarchy/src/instructions/initialize_dao.rs +++ b/programs/futarchy/src/instructions/initialize_dao.rs @@ -222,7 +222,8 @@ impl InitializeDao<'_> { team_sponsored_pass_threshold_bps, team_address, optimistic_proposal: None, - is_optimistic_governance_enabled: false, + // if the team address is not the default address, then optimistic governance should be enabled + is_optimistic_governance_enabled: !team_address.eq(&Pubkey::default()), }); dao.invariant()?; diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index a25481887..82cc17fcf 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -25,28 +25,8 @@ export default function suite() { dao: PublicKey, spendingLimit: BN, transferAmount: bigint; - let setOptimisticGovernanceEnabled: ( - dao: PublicKey, - enabled: boolean, - ) => Promise; beforeEach(async function () { - setOptimisticGovernanceEnabled = async ( - dao: PublicKey, - enabled: boolean, - ) => { - const daoAccount = await this.futarchy.getDao(dao); - daoAccount.isOptimisticGovernanceEnabled = enabled; - const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( - "dao", - daoAccount, - ); - - const daoBanksAccount = await this.banksClient.getAccount(dao); - daoBanksAccount.data.set(daoAccountBuffer, 0); - this.context.setAccount(dao, daoBanksAccount); - }; META = await this.createMint(this.payer.publicKey, 9); spendingLimit = new BN(10_000); transferAmount = 1000n; @@ -102,8 +82,6 @@ export default function suite() { 100_000 * 1_000_000, ); - await setOptimisticGovernanceEnabled(dao, true); - await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 8eced9a5d..805c176a8 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -77,7 +77,7 @@ export default function suite() { assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); assert.isNull(storedDao.optimisticProposal); - assert.isFalse(storedDao.isOptimisticGovernanceEnabled); + assert.isTrue(storedDao.isOptimisticGovernanceEnabled); const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const squadsMultisigVault = multisig.getVaultPda({ @@ -188,7 +188,7 @@ export default function suite() { assert.isTrue(storedDao.teamAddress.equals(this.payer.publicKey)); assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); assert.isNull(storedDao.optimisticProposal); - assert.isFalse(storedDao.isOptimisticGovernanceEnabled); + assert.isTrue(storedDao.isOptimisticGovernanceEnabled); }); it("doesn't allow DAOs with identical base and quote mints", async function () { @@ -213,6 +213,9 @@ export default function suite() { passThresholdBps: 300, nonce: new BN(9999), initialSpendingLimit: null, + baseToStake: new BN(1000), + teamSponsoredPassThresholdBps: 1500, + teamAddress: this.payer.publicKey, }, }) .rpc() diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 6f4525658..f06fd34e0 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -20,29 +20,7 @@ const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; - let setOptimisticGovernanceEnabled: ( - dao: PublicKey, - enabled: boolean, - ) => Promise; - beforeEach(async function () { - setOptimisticGovernanceEnabled = async ( - dao: PublicKey, - enabled: boolean, - ) => { - const daoAccount = await this.futarchy.getDao(dao); - daoAccount.isOptimisticGovernanceEnabled = enabled; - const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( - "dao", - daoAccount, - ); - - const daoBanksAccount = await this.banksClient.getAccount(dao); - daoBanksAccount.data.set(daoAccountBuffer, 0); - this.context.setAccount(dao, daoBanksAccount); - }; - META = await this.createMint(this.payer.publicKey, 9); USDC = await this.createMint(this.payer.publicKey, 6); @@ -191,8 +169,6 @@ export default function suite() { await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); - await setOptimisticGovernanceEnabled(dao, true); - await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 72e63804c..7f981046d 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -113,8 +113,6 @@ export default function suite() { quoteAmount: new BN(100_000 * 10 ** 6), }) .rpc(); - - await setOptimisticGovernanceEnabled(dao, true); }); it("can initiate a vault spend optimistic proposal", async function () { diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index a536e0c00..643fb12bb 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -25,29 +25,7 @@ export default function suite() { spendingLimit: BN, transferAmount: bigint; - let setOptimisticGovernanceEnabled: ( - dao: PublicKey, - enabled: boolean, - ) => Promise; - beforeEach(async function () { - setOptimisticGovernanceEnabled = async ( - dao: PublicKey, - enabled: boolean, - ) => { - const daoAccount = await this.futarchy.getDao(dao); - daoAccount.isOptimisticGovernanceEnabled = enabled; - const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( - "dao", - daoAccount, - ); - - const daoBanksAccount = await this.banksClient.getAccount(dao); - daoBanksAccount.data.set(daoAccountBuffer, 0); - this.context.setAccount(dao, daoBanksAccount); - }; - META = await this.createMint(this.payer.publicKey, 6); USDC = await this.createMint(this.payer.publicKey, 6); spendingLimit = new BN(10_000); @@ -525,8 +503,6 @@ export default function suite() { 10_000_000 * 10 ** 6, ); - await setOptimisticGovernanceEnabled(dao, true); - let daoAccount = await this.futarchy.getDao(dao); await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); @@ -620,7 +596,6 @@ export default function suite() { this.payer, 10_000_000 * 10 ** 6, ); - await setOptimisticGovernanceEnabled(dao, true); let daoAccount = await this.futarchy.getDao(dao); diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 08febc609..12e8d143b 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -22,29 +22,8 @@ const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; - let setOptimisticGovernanceEnabled: ( - dao: PublicKey, - enabled: boolean, - ) => Promise; beforeEach(async function () { - setOptimisticGovernanceEnabled = async ( - dao: PublicKey, - enabled: boolean, - ) => { - const daoAccount = await this.futarchy.getDao(dao); - daoAccount.isOptimisticGovernanceEnabled = enabled; - const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( - "dao", - daoAccount, - ); - - const daoBanksAccount = await this.banksClient.getAccount(dao); - daoBanksAccount.data.set(daoAccountBuffer, 0); - this.context.setAccount(dao, daoBanksAccount); - }; - META = await this.createMint(this.payer.publicKey, 9); USDC = MAINNET_USDC; @@ -565,9 +544,7 @@ export default function suite() { let daoState = await this.futarchy.getDao(dao); assert.isDefined(daoState.amm.state.spot); - // Step 5: Enable optimistic governance and enqueue a real optimistic proposal - await setOptimisticGovernanceEnabled(dao, true); - + // Step 5: Enqueue an optimistic proposal await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, From 8a07998182f874fe6a254bdc51b0877589f86e5e Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 17 Apr 2026 22:00:17 +0200 Subject: [PATCH 081/100] remove unused account --- .../src/instructions/initialize_launch.rs | 9 --------- sdk/src/v0.7/types/launchpad_v8.ts | 10 ---------- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 6 ------ sdk2/src/launchpad/v0.8/types/launchpad_v8.ts | 10 ---------- 4 files changed, 35 deletions(-) diff --git a/programs/v08_launchpad/src/instructions/initialize_launch.rs b/programs/v08_launchpad/src/instructions/initialize_launch.rs index c5dfba23d..6ea5f626f 100644 --- a/programs/v08_launchpad/src/instructions/initialize_launch.rs +++ b/programs/v08_launchpad/src/instructions/initialize_launch.rs @@ -111,15 +111,6 @@ pub struct InitializeLaunch<'info> { )] pub mint_governor: UncheckedAccount<'info>, - /// CHECK: initialized via CPI - #[account( - mut, - seeds = [b"mint_authority", mint_governor.key().as_ref(), launch_signer.key().as_ref()], - bump, - seeds::program = mint_governor_program.key(), - )] - pub mint_authority: UncheckedAccount<'info>, - pub mint_governor_program: Program<'info, MintGovernorProgram>, /// CHECK: checked by mint_governor program diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts index 12c4efc02..42cbef700 100644 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ b/sdk/src/v0.7/types/launchpad_v8.ts @@ -61,11 +61,6 @@ export type LaunchpadV8 = { isMut: true; isSigner: false; }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, { name: "mintGovernorProgram"; isMut: false; @@ -1950,11 +1945,6 @@ export const IDL: LaunchpadV8 = { isMut: true, isSigner: false, }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, { name: "mintGovernorProgram", isMut: false, diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 9772f1e9e..217bf0f94 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -255,11 +255,6 @@ export class LaunchpadClient { mint: baseMint, createKey: launchSigner, }); - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.mintGovernorClient.programId, - mintGovernor, - authorizedMinter: launchSigner, - }); const [mintGovernorEventAuthority] = getEventAuthorityAddr( this.mintGovernorClient.programId, ); @@ -294,7 +289,6 @@ export class LaunchpadClient { payer, additionalTokensRecipient: additionalTokensRecipient ?? null, mintGovernor, - mintAuthority, mintGovernorProgram: this.mintGovernorClient.programId, mintGovernorEventAuthority, }) diff --git a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts index 12c4efc02..42cbef700 100644 --- a/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts +++ b/sdk2/src/launchpad/v0.8/types/launchpad_v8.ts @@ -61,11 +61,6 @@ export type LaunchpadV8 = { isMut: true; isSigner: false; }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, { name: "mintGovernorProgram"; isMut: false; @@ -1950,11 +1945,6 @@ export const IDL: LaunchpadV8 = { isMut: true, isSigner: false, }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, { name: "mintGovernorProgram", isMut: false, From aa962ba3d0408c3faa456cfcc9f1efba883ef0a3 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 17 Apr 2026 23:57:58 +0200 Subject: [PATCH 082/100] reintroduce disabling of optimistic governance on dao initialization and migration --- .../src/instructions/initialize_dao.rs | 3 +-- .../futarchy/src/instructions/resize_dao.rs | 3 +-- .../unit/finalizeOptimisticProposal.test.ts | 4 ++- tests/futarchy/unit/initializeDao.test.ts | 4 +-- .../futarchy/unit/initializeProposal.test.ts | 4 ++- ...itiateVaultSpendOptimisticProposal.test.ts | 26 +++---------------- tests/futarchy/unit/launchProposal.test.ts | 6 ++++- tests/futarchy/unit/updateDao.test.ts | 3 +++ tests/utils.ts | 18 +++++++++++++ 9 files changed, 40 insertions(+), 31 deletions(-) diff --git a/programs/futarchy/src/instructions/initialize_dao.rs b/programs/futarchy/src/instructions/initialize_dao.rs index c7a689e3b..64fe30be7 100644 --- a/programs/futarchy/src/instructions/initialize_dao.rs +++ b/programs/futarchy/src/instructions/initialize_dao.rs @@ -222,8 +222,7 @@ impl InitializeDao<'_> { team_sponsored_pass_threshold_bps, team_address, optimistic_proposal: None, - // if the team address is not the default address, then optimistic governance should be enabled - is_optimistic_governance_enabled: !team_address.eq(&Pubkey::default()), + is_optimistic_governance_enabled: false, }); dao.invariant()?; diff --git a/programs/futarchy/src/instructions/resize_dao.rs b/programs/futarchy/src/instructions/resize_dao.rs index fbed86068..6352ac116 100644 --- a/programs/futarchy/src/instructions/resize_dao.rs +++ b/programs/futarchy/src/instructions/resize_dao.rs @@ -56,8 +56,7 @@ impl ResizeDao<'_> { team_sponsored_pass_threshold_bps: old_dao_data.team_sponsored_pass_threshold_bps, team_address: old_dao_data.team_address, optimistic_proposal: None, - // if the team address is not the default address, then optimistic governance should be enabled - is_optimistic_governance_enabled: !old_dao_data.team_address.eq(&Pubkey::default()), + is_optimistic_governance_enabled: false, }; dao.realloc(AFTER_REALLOC_SIZE, true)?; diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index 82cc17fcf..b10ffdea3 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -9,7 +9,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import BN from "bn.js"; -import { expectError } from "../../utils.js"; +import { expectError, setOptimisticGovernanceEnabled } from "../../utils.js"; import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; import { createTransferInstruction, @@ -82,6 +82,8 @@ export default function suite() { 100_000 * 1_000_000, ); + await setOptimisticGovernanceEnabled(this, dao, true); + await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 805c176a8..4066a9d90 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -77,7 +77,7 @@ export default function suite() { assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); assert.isNull(storedDao.optimisticProposal); - assert.isTrue(storedDao.isOptimisticGovernanceEnabled); + assert.isFalse(storedDao.isOptimisticGovernanceEnabled); const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const squadsMultisigVault = multisig.getVaultPda({ @@ -188,7 +188,7 @@ export default function suite() { assert.isTrue(storedDao.teamAddress.equals(this.payer.publicKey)); assert.equal(storedDao.teamSponsoredPassThresholdBps, 123); assert.isNull(storedDao.optimisticProposal); - assert.isTrue(storedDao.isOptimisticGovernanceEnabled); + assert.isFalse(storedDao.isOptimisticGovernanceEnabled); }); it("doesn't allow DAOs with identical base and quote mints", async function () { diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index f06fd34e0..97221628f 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -10,7 +10,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import BN from "bn.js"; -import { expectError, setupBasicDao } from "../../utils.js"; +import { expectError, setOptimisticGovernanceEnabled } from "../../utils.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; const { Permissions, Permission } = multisig.types; @@ -71,6 +71,8 @@ export default function suite() { nonce, daoCreator: this.payer.publicKey, }); + + await setOptimisticGovernanceEnabled(this, dao, true); }); it("should initialize a proposal", async function () { diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 7f981046d..a6cb8d848 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -13,7 +13,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import BN from "bn.js"; -import { expectError } from "../../utils.js"; +import { expectError, setOptimisticGovernanceEnabled } from "../../utils.js"; import { getDaoAddr, MAINNET_USDC } from "@metadaoproject/futarchy/v0.7"; import { createAssociatedTokenAccountIdempotentInstruction, @@ -28,28 +28,8 @@ const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); export default function suite() { let META: PublicKey, dao: PublicKey, spendingLimit: BN; - let setOptimisticGovernanceEnabled: ( - dao: PublicKey, - enabled: boolean, - ) => Promise; beforeEach(async function () { - setOptimisticGovernanceEnabled = async ( - dao: PublicKey, - enabled: boolean, - ) => { - const daoAccount = await this.futarchy.getDao(dao); - daoAccount.isOptimisticGovernanceEnabled = enabled; - const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( - "dao", - daoAccount, - ); - - const daoBanksAccount = await this.banksClient.getAccount(dao); - daoBanksAccount.data.set(daoAccountBuffer, 0); - this.context.setAccount(dao, daoBanksAccount); - }; META = await this.createMint(this.payer.publicKey, 9); spendingLimit = new BN(10_000); // Create payer's token accounts for both mints @@ -113,6 +93,8 @@ export default function suite() { quoteAmount: new BN(100_000 * 10 ** 6), }) .rpc(); + + await setOptimisticGovernanceEnabled(this, dao, true); }); it("can initiate a vault spend optimistic proposal", async function () { @@ -334,7 +316,7 @@ export default function suite() { }); it("can't initiate a vault spend optimistic proposal if the DAO doesn't have optimistic governance enabled", async function () { - await setOptimisticGovernanceEnabled(dao, false); + await setOptimisticGovernanceEnabled(this, dao, false); const callbacks = expectError( "OptimisticGovernanceDisabled", diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index 643fb12bb..ed44fa66d 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -12,7 +12,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import BN from "bn.js"; -import { expectError, setupBasicDao } from "../../utils.js"; +import { expectError, setOptimisticGovernanceEnabled } from "../../utils.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; @@ -507,6 +507,8 @@ export default function suite() { await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); + await setOptimisticGovernanceEnabled(this, dao, true); + await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, @@ -601,6 +603,8 @@ export default function suite() { await this.createTokenAccount(USDC, daoAccount.squadsMultisigVault); + await setOptimisticGovernanceEnabled(this, dao, true); + await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 12e8d143b..70a3efe21 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -17,6 +17,7 @@ import { } from "@metadaoproject/futarchy/v0.7"; import { sha256 } from "@metadaoproject/futarchy"; import BN from "bn.js"; +import { setOptimisticGovernanceEnabled } from "../../utils.js"; const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); @@ -545,6 +546,8 @@ export default function suite() { assert.isDefined(daoState.amm.state.spot); // Step 5: Enqueue an optimistic proposal + await setOptimisticGovernanceEnabled(this, dao, true); + await this.futarchy .initiateVaultSpendOptimisticProposalIx({ dao, diff --git a/tests/utils.ts b/tests/utils.ts index a8a6ca3cd..af52b0241 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -70,6 +70,24 @@ export async function setupBasicDao({ return dao; } +export async function setOptimisticGovernanceEnabled( + context: TestContext, + dao: PublicKey, + enabled: boolean, +): Promise { + const daoAccount = await context.futarchy.getDao(dao); + daoAccount.isOptimisticGovernanceEnabled = enabled; + const daoAccountBuffer = + await context.futarchy.autocrat.account.dao.coder.accounts.encode( + "dao", + daoAccount, + ); + + const daoBanksAccount = await context.banksClient.getAccount(dao); + daoBanksAccount.data.set(daoAccountBuffer, 0); + context.context.setAccount(dao, daoBanksAccount); +} + /** * Creates a lookup table for all unique accounts in a transaction * @param transaction - The transaction to create a lookup table for From c70de22759d898d4bd5a7938bd4c47a558aecfe7 Mon Sep 17 00:00:00 2001 From: Pileks Date: Mon, 20 Apr 2026 18:42:15 +0200 Subject: [PATCH 083/100] final cleanup pass --- programs/futarchy/src/error.rs | 8 +-- .../admin_execute_multisig_proposal.rs | 2 +- .../execute_spending_limit_change.rs | 2 +- .../finalize_optimistic_proposal.rs | 22 ++++---- ...nitiate_vault_spend_optimistic_proposal.rs | 2 +- .../futarchy/src/instructions/update_dao.rs | 2 +- sdk/src/v0.7/types/futarchy.ts | 52 ++++++------------- .../unit/finalizeOptimisticProposal.test.ts | 40 +++++++------- tests/futarchy/unit/updateDao.test.ts | 2 +- 9 files changed, 54 insertions(+), 78 deletions(-) diff --git a/programs/futarchy/src/error.rs b/programs/futarchy/src/error.rs index c34de217e..d822ac676 100644 --- a/programs/futarchy/src/error.rs +++ b/programs/futarchy/src/error.rs @@ -80,18 +80,14 @@ pub enum FutarchyError { InvalidMint, #[msg("Proposal is not ready to be unstaked")] ProposalNotReadyToUnstake, - #[msg("Invalid recipient")] - InvalidRecipient, #[msg("Optimistic governance is disabled")] OptimisticGovernanceDisabled, #[msg("An active optimistic proposal is already enqueued")] ActiveOptimisticProposalAlreadyEnqueued, - #[msg("No active optimistic proposal")] - NoActiveOptimisticProposal, #[msg("Optimistic proposal has already passed")] OptimisticProposalAlreadyPassed, - #[msg("Team cannot sponsor a challenge to an optimistic proposal")] - CannotSponsorOptimisticProposalChallenge, #[msg("Invalid spending limit mint. Must be the same as the DAO's quote mint")] InvalidSpendingLimitMint, + #[msg("No active optimistic proposal")] + NoActiveOptimisticProposal, } diff --git a/programs/futarchy/src/instructions/admin_execute_multisig_proposal.rs b/programs/futarchy/src/instructions/admin_execute_multisig_proposal.rs index 62bb3f0cf..7a2e6e619 100644 --- a/programs/futarchy/src/instructions/admin_execute_multisig_proposal.rs +++ b/programs/futarchy/src/instructions/admin_execute_multisig_proposal.rs @@ -67,7 +67,7 @@ impl<'info, 'c: 'info> AdminExecuteMultisigProposal<'info> { return Err(FutarchyError::PoolNotInSpotState.into()); } - if matches!(self.dao.optimistic_proposal, Some(_)) { + if self.dao.optimistic_proposal.is_some() { return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); } diff --git a/programs/futarchy/src/instructions/execute_spending_limit_change.rs b/programs/futarchy/src/instructions/execute_spending_limit_change.rs index 046e8e0c3..35d672045 100644 --- a/programs/futarchy/src/instructions/execute_spending_limit_change.rs +++ b/programs/futarchy/src/instructions/execute_spending_limit_change.rs @@ -28,7 +28,7 @@ impl<'info, 'c: 'info> ExecuteSpendingLimitChange<'info> { return Err(FutarchyError::PoolNotInSpotState.into()); } - if matches!(self.dao.optimistic_proposal, Some(_)) { + if self.dao.optimistic_proposal.is_some() { return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); } diff --git a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs index 164e3d66b..08fa5e346 100644 --- a/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/finalize_optimistic_proposal.rs @@ -5,7 +5,7 @@ use super::*; pub struct FinalizeOptimisticProposal<'info> { #[account(mut, seeds = [squads_multisig_program::SEED_PREFIX, squads_multisig_program::SEED_MULTISIG, dao.key().as_ref()], bump, seeds::program = squads_program)] pub squads_multisig: Account<'info, squads_multisig_program::Multisig>, - #[account(mut, address = dao.optimistic_proposal.as_ref().unwrap().squads_proposal)] + #[account(mut)] pub squads_proposal: Box>, #[account(mut, has_one = squads_multisig)] @@ -16,18 +16,22 @@ pub struct FinalizeOptimisticProposal<'info> { impl FinalizeOptimisticProposal<'_> { pub fn validate(&self) -> Result<()> { + require!( + self.dao.optimistic_proposal.is_some(), + FutarchyError::NoActiveOptimisticProposal + ); + let optimistic_proposal = self.dao.optimistic_proposal.as_ref().unwrap(); + + require_keys_eq!( + self.squads_proposal.key(), + optimistic_proposal.squads_proposal + ); require_keys_eq!(self.squads_proposal.multisig, self.dao.squads_multisig); - // A minimum of proposal duration must have passed since the the optimistic proposal was enqueued - // We know that the optimistic proposal is not None, because the address constraint would have already panicked + // A minimum of proposal duration must have passed since the optimistic proposal was enqueued require_gte!( Clock::get()?.unix_timestamp, - self.dao - .optimistic_proposal - .as_ref() - .unwrap() - .enqueued_timestamp - + self.dao.seconds_per_proposal as i64, + optimistic_proposal.enqueued_timestamp + self.dao.seconds_per_proposal as i64, FutarchyError::ProposalTooYoung ); diff --git a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs index 29af31b07..ed80464d4 100644 --- a/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs +++ b/programs/futarchy/src/instructions/initiate_vault_spend_optimistic_proposal.rs @@ -71,7 +71,7 @@ impl InitiateVaultSpendOptimisticProposal<'_> { // Amount must be less than or equal to 3 times the spending limit require_gte!( - self.squads_spending_limit.amount * 3, + self.squads_spending_limit.amount.saturating_mul(3), params.amount, FutarchyError::InvalidAmount ); diff --git a/programs/futarchy/src/instructions/update_dao.rs b/programs/futarchy/src/instructions/update_dao.rs index 26df64645..d5d5d5d74 100644 --- a/programs/futarchy/src/instructions/update_dao.rs +++ b/programs/futarchy/src/instructions/update_dao.rs @@ -31,7 +31,7 @@ impl UpdateDao<'_> { } // Prevent updates to DAO parameters if an optimistic proposal is enqueued - if matches!(self.dao.optimistic_proposal, Some(_)) { + if self.dao.optimistic_proposal.is_some() { return Err(FutarchyError::ActiveOptimisticProposalAlreadyEnqueued.into()); } diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/v0.7/types/futarchy.ts index 9592b6385..a54c805af 100644 --- a/sdk/src/v0.7/types/futarchy.ts +++ b/sdk/src/v0.7/types/futarchy.ts @@ -3717,39 +3717,29 @@ export type Futarchy = { }, { code: 6038; - name: "InvalidRecipient"; - msg: "Invalid recipient"; - }, - { - code: 6039; name: "OptimisticGovernanceDisabled"; msg: "Optimistic governance is disabled"; }, { - code: 6040; + code: 6039; name: "ActiveOptimisticProposalAlreadyEnqueued"; msg: "An active optimistic proposal is already enqueued"; }, { - code: 6041; - name: "NoActiveOptimisticProposal"; - msg: "No active optimistic proposal"; - }, - { - code: 6042; + code: 6040; name: "OptimisticProposalAlreadyPassed"; msg: "Optimistic proposal has already passed"; }, { - code: 6043; - name: "CannotSponsorOptimisticProposalChallenge"; - msg: "Team cannot sponsor a challenge to an optimistic proposal"; - }, - { - code: 6044; + code: 6041; name: "InvalidSpendingLimitMint"; msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; }, + { + code: 6042; + name: "NoActiveOptimisticProposal"; + msg: "No active optimistic proposal"; + }, ]; }; @@ -7472,38 +7462,28 @@ export const IDL: Futarchy = { }, { code: 6038, - name: "InvalidRecipient", - msg: "Invalid recipient", - }, - { - code: 6039, name: "OptimisticGovernanceDisabled", msg: "Optimistic governance is disabled", }, { - code: 6040, + code: 6039, name: "ActiveOptimisticProposalAlreadyEnqueued", msg: "An active optimistic proposal is already enqueued", }, { - code: 6041, - name: "NoActiveOptimisticProposal", - msg: "No active optimistic proposal", - }, - { - code: 6042, + code: 6040, name: "OptimisticProposalAlreadyPassed", msg: "Optimistic proposal has already passed", }, { - code: 6043, - name: "CannotSponsorOptimisticProposalChallenge", - msg: "Team cannot sponsor a challenge to an optimistic proposal", - }, - { - code: 6044, + code: 6041, name: "InvalidSpendingLimitMint", msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", }, + { + code: 6042, + name: "NoActiveOptimisticProposal", + msg: "No active optimistic proposal", + }, ], }; diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index b10ffdea3..07b0d58e1 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -191,8 +191,8 @@ export default function suite() { await this.banksClient.processTransaction(dupeProposalTx); const callbacks = expectError( - "ConstraintAddress", - "An address constraint was violated", + "RequireKeysEqViolated", + "Squads proposal must not match the enqueued optimistic proposal", ); await this.futarchy @@ -237,25 +237,21 @@ export default function suite() { }) .rpc(); - try { - await this.futarchy - .finalizeOptimisticProposalIx({ - dao, - squadsProposal: daoAccount.optimisticProposal.squadsProposal, - }) - .preInstructions([ - // Add any instruction to prevent banksClient from reverting the transaction - compute budget is perfectly fine - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]) - .rpc(); - - assert.fail("Should have thrown error"); - } catch (error) { - const logsAggregated = error.logs.map((log: string) => log).join("\n"); - assert.include( - logsAggregated, - "panicked at 'called `Option::unwrap()` on a `None` value'", - ); - } + const callbacks = expectError( + "NoActiveOptimisticProposal", + "No active optimistic proposal expected", + ); + + await this.futarchy + .finalizeOptimisticProposalIx({ + dao, + squadsProposal: daoAccount.optimisticProposal.squadsProposal, + }) + .preInstructions([ + // Different compute budget produces a distinct signature from the first finalize call + ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), + ]) + .rpc() + .then(callbacks[0], callbacks[1]); }); } diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 70a3efe21..0460e6ba1 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -586,7 +586,7 @@ export default function suite() { } catch (e) { assert( e.toString().includes("ActiveOptimisticProposalAlreadyEnqueued") || - e.toString().includes("0x1798"), + e.toString().includes("0x1797"), `Expected ActiveOptimisticProposalAlreadyEnqueued error, got: ${e}`, ); } From 656352f018560de0071eaedca21af5460d5a8600 Mon Sep 17 00:00:00 2001 From: Pileks Date: Mon, 20 Apr 2026 19:44:51 +0200 Subject: [PATCH 084/100] update sdk --- sdk/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/package.json b/sdk/package.json index 5f5f2ad62..ca4cb1a88 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@metadaoproject/futarchy", - "version": "0.7.4-alpha.1", + "version": "0.7.4-alpha.2", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/yarn.lock b/yarn.lock index 8e6be5dd5..8b94eba8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -975,7 +975,7 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@metadaoproject/futarchy@./sdk": - version "0.7.4-alpha.1" + version "0.7.4-alpha.2" dependencies: "@coral-xyz/anchor" "^0.29.0" "@metaplex-foundation/umi" "^0.9.2" From 73509ad8cf651ec2ea8da600d65f912543fa35b8 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 23 Apr 2026 20:15:17 +0200 Subject: [PATCH 085/100] update sdkv2 with changes from old sdk --- sdk2/src/futarchy/v0.6/types/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk2/src/futarchy/v0.6/types/index.ts b/sdk2/src/futarchy/v0.6/types/index.ts index 40d476c2c..240cf5c94 100644 --- a/sdk2/src/futarchy/v0.6/types/index.ts +++ b/sdk2/src/futarchy/v0.6/types/index.ts @@ -35,6 +35,10 @@ export type WithdrawLiquidityEvent = IdlEvents["WithdrawLiquidityEvent"]; export type SponsorProposalEvent = IdlEvents["SponsorProposalEvent"]; +export type InitiateVaultSpendOptimisticProposalEvent = + IdlEvents["InitiateVaultSpendOptimisticProposalEvent"]; +export type FinalizeOptimisticProposalEvent = + IdlEvents["FinalizeOptimisticProposalEvent"]; export type FutarchyEvent = | CollectFeesEvent | InitializeDaoEvent @@ -48,4 +52,6 @@ export type FutarchyEvent = | ConditionalSwapEvent | ProvideLiquidityEvent | WithdrawLiquidityEvent - | SponsorProposalEvent; + | SponsorProposalEvent + | InitiateVaultSpendOptimisticProposalEvent + | FinalizeOptimisticProposalEvent; From 53ac3767993559c8e5219c0c0aab18d04cd18b5a Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 23 Apr 2026 21:58:32 +0200 Subject: [PATCH 086/100] rename autocrat to futarchy in v0.6 clients --- sdk2/src/futarchy/v0.6/FutarchyClient.ts | 66 +++++++++---------- sdk2/src/launchpad/v0.6/LaunchpadClient.ts | 2 +- sdk2/src/launchpad/v0.7/LaunchpadClient.ts | 14 ++-- .../futarchy/integration/futarchyAmm.test.ts | 4 +- .../unit/adminApproveMultisigProposal.test.ts | 12 ++-- .../futarchy/unit/adminCancelProposal.test.ts | 6 +- .../unit/adminExecuteMultisigProposal.test.ts | 6 +- .../futarchy/unit/adminRemoveProposal.test.ts | 8 +-- .../unit/executeSpendingLimitChange.test.ts | 10 +-- tests/futarchy/unit/finalizeProposal.test.ts | 24 +------ .../futarchy/unit/initializeProposal.test.ts | 2 +- ...itiateVaultSpendOptimisticProposal.test.ts | 6 +- tests/futarchy/unit/launchProposal.test.ts | 2 +- tests/futarchy/unit/provideLiquidity.test.ts | 12 ++-- tests/integration/fullLaunch.test.ts | 2 +- tests/integration/fullLaunch_v7.test.ts | 2 +- tests/launchpad/unit/fund.test.ts | 4 +- tests/utils.ts | 2 +- 18 files changed, 81 insertions(+), 103 deletions(-) diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk2/src/futarchy/v0.6/FutarchyClient.ts index 9a56bab74..e8067769c 100644 --- a/sdk2/src/futarchy/v0.6/FutarchyClient.ts +++ b/sdk2/src/futarchy/v0.6/FutarchyClient.ts @@ -59,7 +59,7 @@ import { ConditionalVaultClient } from "../../conditional_vault/v0.4/index.js"; export type CreateClientParams = { provider: AnchorProvider; - autocratProgramId?: PublicKey; + futarchyProgramId?: PublicKey; conditionalVaultProgramId?: PublicKey; }; @@ -70,20 +70,20 @@ export type ProposalVaults = { export class FutarchyClient { public readonly provider: AnchorProvider; - public readonly autocrat: Program; + public readonly futarchy: Program; public readonly vaultClient: ConditionalVaultClient; public readonly luts: AddressLookupTableAccount[]; constructor( provider: AnchorProvider, - autocratProgramId: PublicKey, + futarchyProgramId: PublicKey, conditionalVaultProgramId: PublicKey, luts: AddressLookupTableAccount[], ) { this.provider = provider; - this.autocrat = new Program( + this.futarchy = new Program( FutarchyIDL, - autocratProgramId, + futarchyProgramId, provider, ); this.vaultClient = ConditionalVaultClient.createClient({ @@ -94,49 +94,49 @@ export class FutarchyClient { } public static createClient( - createAutocratClientParams: CreateClientParams, + createFutarchyClientParams: CreateClientParams, ): FutarchyClient { - let { provider, autocratProgramId, conditionalVaultProgramId } = - createAutocratClientParams; + let { provider, futarchyProgramId, conditionalVaultProgramId } = + createFutarchyClientParams; const luts: AddressLookupTableAccount[] = []; return new FutarchyClient( provider, - autocratProgramId || FUTARCHY_V0_6_PROGRAM_ID, + futarchyProgramId || FUTARCHY_V0_6_PROGRAM_ID, conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, luts, ); } getProgramId(): PublicKey { - return this.autocrat.programId; + return this.futarchy.programId; } async getProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetch(proposal); + return this.futarchy.account.proposal.fetch(proposal); } async getDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetch(dao); + return this.futarchy.account.dao.fetch(dao); } async fetchProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetchNullable(proposal); + return this.futarchy.account.proposal.fetchNullable(proposal); } async fetchDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetchNullable(dao); + return this.futarchy.account.dao.fetchNullable(dao); } async deserializeProposal( accountInfo: AccountInfo, ): Promise { - return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); + return this.futarchy.coder.accounts.decode("proposal", accountInfo.data); } async deserializeDao(accountInfo: AccountInfo): Promise { - return this.autocrat.coder.accounts.decode("dao", accountInfo.data); + return this.futarchy.coder.accounts.decode("dao", accountInfo.data); } getProposalPdas( @@ -247,7 +247,7 @@ export class FutarchyClient { createKey: dao, })[0]; - return this.autocrat.methods.initializeDao(params).accounts({ + return this.futarchy.methods.initializeDao(params).accounts({ dao, baseMint, quoteMint, @@ -290,7 +290,7 @@ export class FutarchyClient { const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; - return this.autocrat.methods + return this.futarchy.methods .launchProposal() .accounts({ proposal, @@ -347,7 +347,7 @@ export class FutarchyClient { minOutputAmount?: BN; trader?: PublicKey; }) { - return this.autocrat.methods + return this.futarchy.methods .spotSwap({ swapType: swapType === "buy" ? { buy: {} } : { sell: {} }, inputAmount, @@ -409,7 +409,7 @@ export class FutarchyClient { this.getProgramId(), )[0]; - return this.autocrat.methods + return this.futarchy.methods .provideLiquidity({ quoteAmount, maxBaseAmount, @@ -504,7 +504,7 @@ export class FutarchyClient { ); } - return this.autocrat.methods + return this.futarchy.methods .conditionalSwap({ market: market == "pass" ? { pass: {} } : { fail: {} }, swapType: swapType == "buy" ? { buy: {} } : { sell: {} }, @@ -622,7 +622,7 @@ export class FutarchyClient { ): Promise { const storedDao = await this.getDao(dao); - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal); await this.vaultClient.initializeQuestion( sha256(`Will ${proposal} pass?/FAIL/PASS`), @@ -670,7 +670,7 @@ export class FutarchyClient { question: PublicKey, proposer: PublicKey = this.provider.publicKey, ) { - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); + let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal); const { baseVault, quoteVault, @@ -687,7 +687,7 @@ export class FutarchyClient { const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; - return this.autocrat.methods + return this.futarchy.methods .initializeProposal() .accounts({ question, @@ -787,7 +787,7 @@ export class FutarchyClient { const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); - return this.autocrat.methods + return this.futarchy.methods .finalizeProposal() .accounts({ proposal, @@ -849,7 +849,7 @@ export class FutarchyClient { index: 0, })[0]; - return this.autocrat.methods.updateDao(params).accounts({ + return this.futarchy.methods.updateDao(params).accounts({ dao, squadsMultisigVault, }); @@ -876,7 +876,7 @@ export class FutarchyClient { staker, )[0]; - return this.autocrat.methods + return this.futarchy.methods .stakeToProposal({ amount }) .accounts({ proposal, @@ -932,7 +932,7 @@ export class FutarchyClient { staker, )[0]; - return this.autocrat.methods.unstakeFromProposal({ amount }).accounts({ + return this.futarchy.methods.unstakeFromProposal({ amount }).accounts({ proposal, dao, stakerBaseAccount: getAssociatedTokenAddressSync(baseMint, staker, true), @@ -969,7 +969,7 @@ export class FutarchyClient { true, ); - return this.autocrat.methods.collectFees().accounts({ + return this.futarchy.methods.collectFees().accounts({ dao, admin: this.provider.publicKey, ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), @@ -988,7 +988,7 @@ export class FutarchyClient { dao: PublicKey; teamAddress?: PublicKey; }) { - return this.autocrat.methods.sponsorProposal().accounts({ + return this.futarchy.methods.sponsorProposal().accounts({ proposal, dao, teamAddress, @@ -1085,7 +1085,7 @@ export class FutarchyClient { const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - return this.autocrat.methods.collectMeteoraDammFees().accounts({ + return this.futarchy.methods.collectMeteoraDammFees().accounts({ dao, admin, squadsMultisig: multisigPda, @@ -1195,7 +1195,7 @@ export class FutarchyClient { rentPayer: payer, }); - return this.autocrat.methods + return this.futarchy.methods .initiateVaultSpendOptimisticProposal({ amount }) .accounts({ squadsMultisig: multisigPda, @@ -1232,7 +1232,7 @@ export class FutarchyClient { }) { const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - return this.autocrat.methods.finalizeOptimisticProposal().accounts({ + return this.futarchy.methods.finalizeOptimisticProposal().accounts({ squadsMultisig: multisigPda, squadsProposal, dao, diff --git a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts index 2b2eec93d..096e7248f 100644 --- a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts @@ -67,7 +67,7 @@ export class LaunchpadClient { ); this.futarchyClient = FutarchyClient.createClient({ provider: this.provider, - autocratProgramId: params.futarchyProgramId, + futarchyProgramId: params.futarchyProgramId, conditionalVaultProgramId: params.conditionalVaultProgramId, }); this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ diff --git a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts index 51da373e5..c2f4910ad 100644 --- a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.7/LaunchpadClient.ts @@ -48,7 +48,7 @@ import { BidWallClient } from "../../bid_wall/v0.7/index.js"; export type CreateLaunchpadClientParams = { provider: AnchorProvider; launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; + futarchyProgramId?: PublicKey; conditionalVaultProgramId?: PublicKey; priceBasedUnlockProgramId?: PublicKey; bidWallProgramId?: PublicKey; @@ -57,7 +57,7 @@ export type CreateLaunchpadClientParams = { export class LaunchpadClient { public launchpad: Program; public provider: AnchorProvider; - public autocratClient: FutarchyClient; + public futarchyClient: FutarchyClient; public priceBasedUnlock: PriceBasedPerformancePackageClient; public bidWall: BidWallClient; @@ -68,9 +68,9 @@ export class LaunchpadClient { params.launchpadProgramId || LAUNCHPAD_V0_7_PROGRAM_ID, this.provider, ); - this.autocratClient = FutarchyClient.createClient({ + this.futarchyClient = FutarchyClient.createClient({ provider: this.provider, - autocratProgramId: params.autocratProgramId, + futarchyProgramId: params.futarchyProgramId, conditionalVaultProgramId: params.conditionalVaultProgramId, }); this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ @@ -318,7 +318,7 @@ export class LaunchpadClient { }); const [futarchyEventAuthority] = getEventAuthorityAddr( - this.autocratClient.getProgramId(), + this.futarchyClient.getProgramId(), ); const [tokenMetadata] = getMetadataAddr(baseMint); @@ -342,7 +342,7 @@ export class LaunchpadClient { const [ammPosition] = PublicKey.findProgramAddressSync( [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], - this.autocratClient.getProgramId(), + this.futarchyClient.getProgramId(), ); const [performancePackage] = getPerformancePackageAddr({ @@ -457,7 +457,7 @@ export class LaunchpadClient { true, ), staticAccounts: { - futarchyProgram: this.autocratClient.getProgramId(), + futarchyProgram: this.futarchyClient.getProgramId(), tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, futarchyEventAuthority, squadsProgram: SQUADS_PROGRAM_ID, diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index 756db5511..aa76f58cb 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -137,7 +137,7 @@ export default function suite() { it("futarchy amm", async function () { // Get initial state before spot swap (before launching proposal) const daoBeforeSpotSwap = - await this.futarchy.autocrat.account.dao.fetch(dao); + await this.futarchy.futarchy.account.dao.fetch(dao); const initialUserBaseBalance = await this.getTokenBalance( META, @@ -163,7 +163,7 @@ export default function suite() { // Get state after spot swap const daoAfterSpotSwap = - await this.futarchy.autocrat.account.dao.fetch(dao); + await this.futarchy.futarchy.account.dao.fetch(dao); const finalUserBaseBalance = await this.getTokenBalance( META, diff --git a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts index 91a7bae55..695f45c72 100644 --- a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts @@ -97,7 +97,7 @@ export default function suite() { multisig.generated.isProposalStatusActive(squadsProposal.status), ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminApproveMultisigProposal({ transactionIndex: new BN(1) }) .accounts({ dao: dao, @@ -228,7 +228,7 @@ export default function suite() { }); // Approve and execute the config transaction using the new split instructions - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminApproveMultisigProposal({ transactionIndex: new BN(configTransactionIndex.toString()), }) @@ -242,7 +242,7 @@ export default function suite() { .signers([this.payer]) .rpc(); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminExecuteMultisigProposal() .accounts({ dao: dao, @@ -279,7 +279,7 @@ export default function suite() { "The proposal should not be approved because it should have been invalidated", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminApproveMultisigProposal({ transactionIndex: new BN(1) }) .accounts({ dao: dao, @@ -366,7 +366,7 @@ export default function suite() { enqueuedTimestamp: new BN(1000), }; const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( + await this.futarchy.futarchy.account.dao.coder.accounts.encode( "dao", daoAccount, ); @@ -379,7 +379,7 @@ export default function suite() { "Should fail because DAO has an active optimistic proposal", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminApproveMultisigProposal({ transactionIndex: new BN(1) }) .accounts({ dao: dao, diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index 7ee98d275..e7a00a56f 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -154,7 +154,7 @@ export default function suite() { CONDITIONAL_VAULT_v0_4_PROGRAM_ID, ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminCancelProposal() .accounts({ proposal, @@ -303,7 +303,7 @@ export default function suite() { }; // Cancel the proposal first - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminCancelProposal() .accounts(accounts) .preInstructions([ @@ -321,7 +321,7 @@ export default function suite() { "should not cancel an already cancelled proposal", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminCancelProposal() .accounts(accounts) .preInstructions([ diff --git a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts index f3a25e2cb..bd9992949 100644 --- a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts @@ -110,7 +110,7 @@ export default function suite() { }); // First approve - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminApproveMultisigProposal({ transactionIndex: new BN(1) }) .accounts({ dao: dao, @@ -123,7 +123,7 @@ export default function suite() { .rpc(); // Then execute - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminExecuteMultisigProposal() .accounts({ dao: dao, @@ -227,7 +227,7 @@ export default function suite() { "The proposal should not be executed because it has not been approved", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminExecuteMultisigProposal() .accounts({ dao: dao, diff --git a/tests/futarchy/unit/adminRemoveProposal.test.ts b/tests/futarchy/unit/adminRemoveProposal.test.ts index ccde4c023..aa72f3468 100644 --- a/tests/futarchy/unit/adminRemoveProposal.test.ts +++ b/tests/futarchy/unit/adminRemoveProposal.test.ts @@ -99,7 +99,7 @@ export default function suite() { assert.exists(storedProposal.state.draft); // Call admin_remove_proposal - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminRemoveProposal() .accounts({ proposal, @@ -130,7 +130,7 @@ export default function suite() { .rpc(); // Remove the proposal - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminRemoveProposal() .accounts({ proposal, @@ -166,7 +166,7 @@ export default function suite() { it("should not allow staking to Removed proposals", async function () { // Remove the proposal first - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminRemoveProposal() .accounts({ proposal, @@ -245,7 +245,7 @@ export default function suite() { "Should not allow removing Pending proposal", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .adminRemoveProposal() .accounts({ proposal, diff --git a/tests/futarchy/unit/executeSpendingLimitChange.test.ts b/tests/futarchy/unit/executeSpendingLimitChange.test.ts index 9b81a29aa..95fb5b332 100644 --- a/tests/futarchy/unit/executeSpendingLimitChange.test.ts +++ b/tests/futarchy/unit/executeSpendingLimitChange.test.ts @@ -166,7 +166,7 @@ export default function suite() { }, ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ squadsMultisig: multisigPda, @@ -290,7 +290,7 @@ export default function suite() { enqueuedTimestamp: new BN(0), }; const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( + await this.futarchy.futarchy.account.dao.coder.accounts.encode( "dao", daoAccount, ); @@ -331,7 +331,7 @@ export default function suite() { "Should fail because there is an active optimistic proposal", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ squadsMultisig: multisigPda, @@ -458,7 +458,7 @@ export default function suite() { "The transaction should not be executed because it contains a call to remove the DAO as a member", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ squadsMultisig: multisigPda, @@ -585,7 +585,7 @@ export default function suite() { "The transaction should not be executed because it contains a call to remove the DAO as a member", ); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ squadsMultisig: multisigPda, diff --git a/tests/futarchy/unit/finalizeProposal.test.ts b/tests/futarchy/unit/finalizeProposal.test.ts index fb4d84c0f..99ddca942 100644 --- a/tests/futarchy/unit/finalizeProposal.test.ts +++ b/tests/futarchy/unit/finalizeProposal.test.ts @@ -115,7 +115,7 @@ export default function suite() { await this.banksClient.processTransaction(tx); - // Now initialize the autocrat proposal + // Now initialize the futarchy proposal proposal = await this.futarchy.initializeProposal(dao, squadsProposalPda); await this.futarchy @@ -170,26 +170,6 @@ export default function suite() { dao, ); - // await this.autocratClient. - // await this.futarchy.autocrat.methods.launchProposal() - // .accounts({ - // proposal, - // dao, - // baseVault, - // quoteVault, - // passBaseMint, - // passQuoteMint, - // failBaseMint, - // failQuoteMint, - // ammPassBaseVault: getAssociatedTokenAddressSync(passBaseMint, dao, true), - // ammPassQuoteVault: getAssociatedTokenAddressSync(passQuoteMint, dao, true), - // ammFailBaseVault: getAssociatedTokenAddressSync(failBaseMint, dao, true), - // ammFailQuoteVault: getAssociatedTokenAddressSync(failQuoteMint, dao, true), - // payer: this.payer.publicKey, - // }) - // .preInstructions([ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 })]) - // .rpc(); - await this.futarchy .conditionalSwapIx({ dao, @@ -497,7 +477,7 @@ export default function suite() { await this.banksClient.processTransaction(tx); - // Now initialize the autocrat proposal + // Now initialize the futarchy proposal const teamSponsoredProposal = await this.futarchy.initializeProposal( daoWithTeamSponsorship, squadsProposalPda, diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 2f1754bf9..70414c9ee 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -132,7 +132,7 @@ export default function suite() { await this.banksClient.processTransaction(tx); - // Now initialize the autocrat proposal + // Now initialize the futarchy proposal const proposal = await this.futarchy.initializeProposal( dao, squadsProposalPda, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 016bbd2cf..430b2d7ed 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -269,7 +269,7 @@ export default function suite() { programId: squads.PROGRAM_ID, }); - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ squadsMultisig: multisigPda, @@ -364,7 +364,7 @@ export default function suite() { }; const daoAccountBuffer = - await this.futarchy.autocrat.account.dao.coder.accounts.encode( + await this.futarchy.futarchy.account.dao.coder.accounts.encode( "dao", daoAccount, ); @@ -536,7 +536,7 @@ export default function suite() { true, ); - return ctx.futarchy.autocrat.methods + return ctx.futarchy.futarchy.methods .initiateVaultSpendOptimisticProposal({ amount }) .accounts({ squadsMultisig: multisigPda, diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index aa3d475ba..0e9b25765 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -384,7 +384,7 @@ export default function suite() { // Directly modify the DAO's secondsPerProposal to 5 days const daoAccountInfo = await this.banksClient.getAccount(dao); - const coder = this.futarchy.autocrat.coder.accounts; + const coder = this.futarchy.futarchy.coder.accounts; const daoData = coder.decode("dao", Buffer.from(daoAccountInfo.data)); daoData.secondsPerProposal = FIVE_DAYS; const encodedData = await coder.encode("dao", daoData); diff --git a/tests/futarchy/unit/provideLiquidity.test.ts b/tests/futarchy/unit/provideLiquidity.test.ts index ffd588e12..dfc0ae01a 100644 --- a/tests/futarchy/unit/provideLiquidity.test.ts +++ b/tests/futarchy/unit/provideLiquidity.test.ts @@ -37,7 +37,7 @@ export default function suite() { // Fetch position before const positionBefore = - await this.futarchy.autocrat.account.ammPosition.fetch(ammPositionPda); + await this.futarchy.futarchy.account.ammPosition.fetch(ammPositionPda); // Call provideLiquidityIx to add more liquidity // maxBaseAmount needs buffer for rounding (add 1% or more) @@ -56,7 +56,7 @@ export default function suite() { // Fetch position after const positionAfter = - await this.futarchy.autocrat.account.ammPosition.fetch(ammPositionPda); + await this.futarchy.futarchy.account.ammPosition.fetch(ammPositionPda); // Assert liquidity increased assert.isTrue(positionAfter.liquidity.gt(positionBefore.liquidity)); @@ -88,7 +88,7 @@ export default function suite() { // Fetch position before attack const positionBefore = - await this.futarchy.autocrat.account.ammPosition.fetch(ammPositionPda); + await this.futarchy.futarchy.account.ammPosition.fetch(ammPositionPda); // Attacker calls provideLiquidityIx with positionAuthority=victim, liquidityProvider=attacker await this.futarchy @@ -107,7 +107,7 @@ export default function suite() { // Fetch position after attack const positionAfter = - await this.futarchy.autocrat.account.ammPosition.fetch(ammPositionPda); + await this.futarchy.futarchy.account.ammPosition.fetch(ammPositionPda); // Assert position_authority is still victim (not overwritten to attacker) assert.isTrue(positionAfter.positionAuthority.equals(this.payer.publicKey)); @@ -162,7 +162,7 @@ export default function suite() { // Fetch position to get current liquidity const position = - await this.futarchy.autocrat.account.ammPosition.fetch(ammPositionPda); + await this.futarchy.futarchy.account.ammPosition.fetch(ammPositionPda); // Derive event authority const [eventAuthority] = PublicKey.findProgramAddressSync( @@ -171,7 +171,7 @@ export default function suite() { ); // Victim withdraws all liquidity - await this.futarchy.autocrat.methods + await this.futarchy.futarchy.methods .withdrawLiquidity({ liquidityToWithdraw: position.liquidity, minBaseAmount: new BN(0), diff --git a/tests/integration/fullLaunch.test.ts b/tests/integration/fullLaunch.test.ts index f2777e956..9aa1f9d06 100644 --- a/tests/integration/fullLaunch.test.ts +++ b/tests/integration/fullLaunch.test.ts @@ -432,7 +432,7 @@ export default async function suite() { await this.banksClient.processTransaction(squadsTx); - // Now initialize the autocrat proposal with the proper squads proposal + // Now initialize the futarchy proposal with the proper squads proposal const proposal = await this.futarchy.initializeProposal( dao, squadsProposalPda, diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index 90613f3ac..498b33766 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -477,7 +477,7 @@ export default async function suite() { await this.banksClient.processTransaction(squadsTx); - // Now initialize the autocrat proposal with the proper squads proposal + // Now initialize the futarchy proposal with the proper squads proposal const proposal = await this.futarchy.initializeProposal( dao, squadsProposalPda, diff --git a/tests/launchpad/unit/fund.test.ts b/tests/launchpad/unit/fund.test.ts index fdbf9d461..c48bc2b5b 100644 --- a/tests/launchpad/unit/fund.test.ts +++ b/tests/launchpad/unit/fund.test.ts @@ -4,14 +4,13 @@ import { getFundingRecordAddr, LaunchpadClient, } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { - let autocratClient: FutarchyClient; let launchpadClient: LaunchpadClient; let META: PublicKey; let launch: PublicKey; @@ -29,7 +28,6 @@ export default function suite() { const unlockThreshold = new BN(2000_000000); before(async function () { - autocratClient = this.futarchy; launchpadClient = this.launchpad_v6; }); diff --git a/tests/utils.ts b/tests/utils.ts index 994165b5d..a0412115f 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -78,7 +78,7 @@ export async function setOptimisticGovernanceEnabled( const daoAccount = await context.futarchy.getDao(dao); daoAccount.isOptimisticGovernanceEnabled = enabled; const daoAccountBuffer = - await context.futarchy.autocrat.account.dao.coder.accounts.encode( + await context.futarchy.futarchy.account.dao.coder.accounts.encode( "dao", daoAccount, ); From f05e45102bfc767ec3d570a67716e859929354c1 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 23 Apr 2026 23:04:19 +0200 Subject: [PATCH 087/100] rename autocratClient to futarchyClient --- sdk2/src/launchpad/v0.8/LaunchpadClient.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts index 217bf0f94..c49d8b146 100644 --- a/sdk2/src/launchpad/v0.8/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.8/LaunchpadClient.ts @@ -47,7 +47,7 @@ import { BidWallClient } from "../../bid_wall/v0.7/index.js"; export type CreateLaunchpadClientParams = { provider: AnchorProvider; launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; + futarchyProgramId?: PublicKey; conditionalVaultProgramId?: PublicKey; mintGovernorProgramId?: PublicKey; performancePackageV2ProgramId?: PublicKey; @@ -57,7 +57,7 @@ export type CreateLaunchpadClientParams = { export class LaunchpadClient { public launchpad: Program; public provider: AnchorProvider; - public autocratClient: FutarchyClient; + public futarchyClient: FutarchyClient; public mintGovernorClient: MintGovernorClient; public performancePackageV2: PerformancePackageV2Client; public bidWall: BidWallClient; @@ -69,9 +69,9 @@ export class LaunchpadClient { params.launchpadProgramId || LAUNCHPAD_V0_8_PROGRAM_ID, this.provider, ); - this.autocratClient = FutarchyClient.createClient({ + this.futarchyClient = FutarchyClient.createClient({ provider: this.provider, - autocratProgramId: params.autocratProgramId, + futarchyProgramId: params.futarchyProgramId, conditionalVaultProgramId: params.conditionalVaultProgramId, }); this.mintGovernorClient = MintGovernorClient.createClient({ @@ -426,7 +426,7 @@ export class LaunchpadClient { }); const [futarchyEventAuthority] = getEventAuthorityAddr( - this.autocratClient.getProgramId(), + this.futarchyClient.getProgramId(), ); const [tokenMetadata] = getMetadataAddr(baseMint); @@ -450,7 +450,7 @@ export class LaunchpadClient { const [ammPosition] = PublicKey.findProgramAddressSync( [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], - this.autocratClient.getProgramId(), + this.futarchyClient.getProgramId(), ); // Meteora PDAs @@ -557,7 +557,7 @@ export class LaunchpadClient { true, ), staticAccounts: { - futarchyProgram: this.autocratClient.getProgramId(), + futarchyProgram: this.futarchyClient.getProgramId(), tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, futarchyEventAuthority, squadsProgram: SQUADS_PROGRAM_ID, From 03f3d762a46e0133e9bb77698777fa7bd148918e Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 24 Apr 2026 15:24:20 +0200 Subject: [PATCH 088/100] sdk2 is now main sdk --- package.json | 3 +-- sdk2/package.json | 4 ++-- tests/bidWall/main.test.ts | 2 +- tests/bidWall/unit/cancelBidWall.test.ts | 2 +- tests/bidWall/unit/closeBidWall.test.ts | 2 +- tests/bidWall/unit/collectFees.test.ts | 2 +- tests/bidWall/unit/initializeBidWall.test.ts | 2 +- tests/bidWall/unit/sellTokens.test.ts | 2 +- tests/bidWall/utils.ts | 2 +- .../binaryPredictionMarket.test.ts | 2 +- .../multiOptionPredictionMarket.test.ts | 2 +- .../integration/scalarGrantMarket.test.ts | 2 +- tests/conditionalVault/unit.ts | 2 +- .../addMetadataToConditionalTokens.test.ts | 2 +- .../unit/initializeConditionalVault.test.ts | 2 +- .../unit/initializeQuestion.test.ts | 2 +- .../conditionalVault/unit/mergeTokens.test.ts | 2 +- .../unit/redeemTokens.test.ts | 2 +- .../unit/resolveQuestion.test.ts | 2 +- .../conditionalVault/unit/splitTokens.test.ts | 2 +- .../futarchy/integration/fullProposal.test.ts | 5 +---- .../futarchy/integration/futarchyAmm.test.ts | 2 +- .../integration/proposalBatchTx.test.ts | 5 +---- tests/futarchy/main.test.ts | 2 +- .../unit/adminApproveMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminCancelProposal.test.ts | 2 +- .../unit/adminExecuteMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminRemoveProposal.test.ts | 2 +- tests/futarchy/unit/collectFees.test.ts | 2 +- .../unit/collectMeteoraDammFees.test.ts | 2 +- tests/futarchy/unit/conditionalSwap.test.ts | 2 +- .../unit/executeSpendingLimitChange.test.ts | 2 +- .../unit/finalizeOptimisticProposal.test.ts | 2 +- tests/futarchy/unit/finalizeProposal.test.ts | 2 +- tests/futarchy/unit/initializeDao.test.ts | 2 +- .../futarchy/unit/initializeProposal.test.ts | 2 +- ...itiateVaultSpendOptimisticProposal.test.ts | 2 +- tests/futarchy/unit/launchProposal.test.ts | 2 +- tests/futarchy/unit/provideLiquidity.test.ts | 2 +- .../futarchy/unit/unstakeFromProposal.test.ts | 2 +- tests/futarchy/unit/updateDao.test.ts | 2 +- tests/integration/fullLaunch.test.ts | 2 +- tests/integration/fullLaunch_v7.test.ts | 2 +- tests/integration/mintAndSwap.test.ts | 2 +- tests/launchpad/main.test.ts | 4 +--- tests/launchpad/unit/claim.test.ts | 4 ++-- tests/launchpad/unit/closeLaunch.test.ts | 4 ++-- tests/launchpad/unit/completeLaunch.test.ts | 4 ++-- tests/launchpad/unit/fund.test.ts | 4 ++-- tests/launchpad/unit/initializeLaunch.test.ts | 4 ++-- tests/launchpad/unit/refund.test.ts | 4 ++-- tests/launchpad/unit/returnFunds.test.ts | 4 ++-- tests/launchpad/unit/startLaunch.test.ts | 4 ++-- tests/launchpad/utils.ts | 2 +- tests/launchpad_v7/main.test.ts | 2 +- tests/launchpad_v7/unit/claim.test.ts | 2 +- .../claimAdditionalTokenAllocation.test.ts | 2 +- tests/launchpad_v7/unit/closeLaunch.test.ts | 2 +- .../launchpad_v7/unit/completeLaunch.test.ts | 2 +- tests/launchpad_v7/unit/extendLaunch.test.ts | 2 +- tests/launchpad_v7/unit/fund.test.ts | 2 +- .../unit/initializeLaunch.test.ts | 4 ++-- .../unit/initializePerformancePackage.test.ts | 2 +- tests/launchpad_v7/unit/refund.test.ts | 2 +- .../unit/setFundingRecordApproval.test.ts | 2 +- tests/launchpad_v7/unit/startLaunch.test.ts | 4 ++-- tests/launchpad_v7/utils.ts | 7 ++----- tests/liquidation/main.test.ts | 2 +- .../unit/activateLiquidation.test.ts | 2 +- .../unit/initializeLiquidation.test.ts | 2 +- tests/liquidation/unit/refund.test.ts | 2 +- .../liquidation/unit/setRefundRecord.test.ts | 2 +- .../unit/withdrawRemainingQuote.test.ts | 2 +- tests/liquidation/utils.ts | 2 +- tests/main.test.ts | 4 ++-- tests/mintGovernor/main.test.ts | 2 +- .../unit/addMintAuthority.test.ts | 2 +- .../unit/initializeMintGovernor.test.ts | 2 +- tests/mintGovernor/unit/mintTokens.test.ts | 2 +- .../unit/reclaimAuthority.test.ts | 2 +- .../unit/removeMintAuthority.test.ts | 2 +- .../unit/transferAuthorityToGovernor.test.ts | 2 +- .../unit/updateMintAuthority.test.ts | 2 +- .../unit/updateMintGovernorAdmin.test.ts | 2 +- tests/mintGovernor/utils.ts | 2 +- tests/performancePackageV2/main.test.ts | 2 +- .../unit/changeAuthority.test.ts | 2 +- .../unit/closePerformancePackage.test.ts | 2 +- .../unit/completeUnlock.test.ts | 2 +- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 2 +- .../unit/proposeChange.test.ts | 2 +- .../unit/startUnlock.test.ts | 2 +- tests/performancePackageV2/utils.ts | 4 ++-- .../unit/burnPerformancePackage.test.ts | 5 +---- .../unit/completeUnlock.test.ts | 2 +- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 5 +---- .../unit/startUnlock.test.ts | 2 +- tests/utils.ts | 2 +- yarn.lock | 19 ++----------------- 101 files changed, 116 insertions(+), 149 deletions(-) diff --git a/package.json b/package.json index 585c0afe2..95e2393c1 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "dependencies": { "@coral-xyz/anchor": "=0.29.0", "@inquirer/prompts": "^7.3.3", - "@metadaoproject/futarchy": "./sdk", - "@metadaoproject/futarchy-v2": "./sdk2", + "@metadaoproject/futarchy": "./sdk2", "@metaplex-foundation/mpl-token-metadata": "^3.2.0", "@metaplex-foundation/umi": "^0.9.1", "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", diff --git a/sdk2/package.json b/sdk2/package.json index f314c16e6..6c6429124 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -1,6 +1,6 @@ { - "name": "@metadaoproject/futarchy-v2", - "version": "0.7.3-alpha.1", + "name": "@metadaoproject/futarchy", + "version": "0.8.0-alpha.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/tests/bidWall/main.test.ts b/tests/bidWall/main.test.ts index 0fd2919a7..2a329e308 100644 --- a/tests/bidWall/main.test.ts +++ b/tests/bidWall/main.test.ts @@ -7,7 +7,7 @@ import { PublicKey } from "@solana/web3.js"; import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; export default function suite() { before(async function () { diff --git a/tests/bidWall/unit/cancelBidWall.test.ts b/tests/bidWall/unit/cancelBidWall.test.ts index 5b27df9c8..6cc434d9f 100644 --- a/tests/bidWall/unit/cancelBidWall.test.ts +++ b/tests/bidWall/unit/cancelBidWall.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/bidWall/unit/closeBidWall.test.ts b/tests/bidWall/unit/closeBidWall.test.ts index 4b2e02a44..b064aba73 100644 --- a/tests/bidWall/unit/closeBidWall.test.ts +++ b/tests/bidWall/unit/closeBidWall.test.ts @@ -14,7 +14,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/collectFees.test.ts b/tests/bidWall/unit/collectFees.test.ts index 7c11b0162..2c2cc1817 100644 --- a/tests/bidWall/unit/collectFees.test.ts +++ b/tests/bidWall/unit/collectFees.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync, diff --git a/tests/bidWall/unit/initializeBidWall.test.ts b/tests/bidWall/unit/initializeBidWall.test.ts index 04be71d47..514456b9d 100644 --- a/tests/bidWall/unit/initializeBidWall.test.ts +++ b/tests/bidWall/unit/initializeBidWall.test.ts @@ -12,7 +12,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/sellTokens.test.ts b/tests/bidWall/unit/sellTokens.test.ts index c9a1a9886..c8d86bcc4 100644 --- a/tests/bidWall/unit/sellTokens.test.ts +++ b/tests/bidWall/unit/sellTokens.test.ts @@ -12,7 +12,7 @@ import { BidWallClient, MAINNET_USDC, getBidWallAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/utils.ts b/tests/bidWall/utils.ts index 4b7a3b4c1..b0b7dcbf4 100644 --- a/tests/bidWall/utils.ts +++ b/tests/bidWall/utils.ts @@ -5,7 +5,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts index db458344d..a848a3180 100644 --- a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts index 74933fe06..eba8424cf 100644 --- a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/scalarGrantMarket.test.ts b/tests/conditionalVault/integration/scalarGrantMarket.test.ts index 8446e65b0..373d0055b 100644 --- a/tests/conditionalVault/integration/scalarGrantMarket.test.ts +++ b/tests/conditionalVault/integration/scalarGrantMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy-v2"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/unit.ts b/tests/conditionalVault/unit.ts index 351e40a80..678d63941 100644 --- a/tests/conditionalVault/unit.ts +++ b/tests/conditionalVault/unit.ts @@ -33,7 +33,7 @@ import { getQuestionAddr, getVaultAddr, sha256, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; export type VaultProgram = anchor.Program; export type PublicKey = anchor.web3.PublicKey; diff --git a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts index 29d08e38b..794470265 100644 --- a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts +++ b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts @@ -3,7 +3,7 @@ import { ConditionalVaultClient, getConditionalTokenMintAddr, getMetadataAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeConditionalVault.test.ts b/tests/conditionalVault/unit/initializeConditionalVault.test.ts index 0844835a6..c173305eb 100644 --- a/tests/conditionalVault/unit/initializeConditionalVault.test.ts +++ b/tests/conditionalVault/unit/initializeConditionalVault.test.ts @@ -3,7 +3,7 @@ import { getVaultAddr, getConditionalTokenMintAddr, sha256, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint, getMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeQuestion.test.ts b/tests/conditionalVault/unit/initializeQuestion.test.ts index 1cafb91de..6c9aca68a 100644 --- a/tests/conditionalVault/unit/initializeQuestion.test.ts +++ b/tests/conditionalVault/unit/initializeQuestion.test.ts @@ -2,7 +2,7 @@ import { sha256, ConditionalVaultClient, getQuestionAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; // const { ConditionalVaultClient, getQuestionAddr } = futarchy; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; diff --git a/tests/conditionalVault/unit/mergeTokens.test.ts b/tests/conditionalVault/unit/mergeTokens.test.ts index 238c7a678..0adc5ee73 100644 --- a/tests/conditionalVault/unit/mergeTokens.test.ts +++ b/tests/conditionalVault/unit/mergeTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/redeemTokens.test.ts b/tests/conditionalVault/unit/redeemTokens.test.ts index d4c0894f1..b95a4e56e 100644 --- a/tests/conditionalVault/unit/redeemTokens.test.ts +++ b/tests/conditionalVault/unit/redeemTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/resolveQuestion.test.ts b/tests/conditionalVault/unit/resolveQuestion.test.ts index 4e65f32f1..7f45bd16a 100644 --- a/tests/conditionalVault/unit/resolveQuestion.test.ts +++ b/tests/conditionalVault/unit/resolveQuestion.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/conditionalVault/unit/splitTokens.test.ts b/tests/conditionalVault/unit/splitTokens.test.ts index fd1e44931..a0686a604 100644 --- a/tests/conditionalVault/unit/splitTokens.test.ts +++ b/tests/conditionalVault/unit/splitTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy-v2"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { getMint } from "spl-token-bankrun"; diff --git a/tests/futarchy/integration/fullProposal.test.ts b/tests/futarchy/integration/fullProposal.test.ts index c6143b571..edc64c3a8 100644 --- a/tests/futarchy/integration/fullProposal.test.ts +++ b/tests/futarchy/integration/fullProposal.test.ts @@ -1,7 +1,4 @@ -import { - getDaoAddr, - PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, SystemProgram, diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index aa76f58cb..6e6a8f299 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/integration/proposalBatchTx.test.ts b/tests/futarchy/integration/proposalBatchTx.test.ts index 3cf431ea5..df04d5c59 100644 --- a/tests/futarchy/integration/proposalBatchTx.test.ts +++ b/tests/futarchy/integration/proposalBatchTx.test.ts @@ -1,7 +1,4 @@ -import { - getDaoAddr, - PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, SystemProgram, diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index 5437a99db..918f58123 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -26,7 +26,7 @@ import { PublicKey } from "@solana/web3.js"; import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; export default function suite() { before(async function () { diff --git a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts index 695f45c72..994554678 100644 --- a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index e7a00a56f..d82afb773 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -3,7 +3,7 @@ import { CONDITIONAL_VAULT_v0_4_PROGRAM_ID, SQUADS_PROGRAM_ID, getEventAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts index bd9992949..9e1d8fc57 100644 --- a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/adminRemoveProposal.test.ts b/tests/futarchy/unit/adminRemoveProposal.test.ts index aa72f3468..0e6f628b5 100644 --- a/tests/futarchy/unit/adminRemoveProposal.test.ts +++ b/tests/futarchy/unit/adminRemoveProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/collectFees.test.ts b/tests/futarchy/unit/collectFees.test.ts index 6da5d2f8d..54fcf27de 100644 --- a/tests/futarchy/unit/collectFees.test.ts +++ b/tests/futarchy/unit/collectFees.test.ts @@ -12,7 +12,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import BN from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import { METADAO_MULTISIG_VAULT } from "../../../sdk/src/v0.6/constants.js"; diff --git a/tests/futarchy/unit/collectMeteoraDammFees.test.ts b/tests/futarchy/unit/collectMeteoraDammFees.test.ts index ea7e81b75..86f3da789 100644 --- a/tests/futarchy/unit/collectMeteoraDammFees.test.ts +++ b/tests/futarchy/unit/collectMeteoraDammFees.test.ts @@ -13,7 +13,7 @@ import { LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../../launchpad_v7/utils.js"; import { createLookupTableForTransaction } from "../../utils.js"; diff --git a/tests/futarchy/unit/conditionalSwap.test.ts b/tests/futarchy/unit/conditionalSwap.test.ts index 6f0845847..3b00d1f13 100644 --- a/tests/futarchy/unit/conditionalSwap.test.ts +++ b/tests/futarchy/unit/conditionalSwap.test.ts @@ -11,7 +11,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import { BN } from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import { ComputeBudget } from "litesvm"; diff --git a/tests/futarchy/unit/executeSpendingLimitChange.test.ts b/tests/futarchy/unit/executeSpendingLimitChange.test.ts index 95fb5b332..f1bc094a2 100644 --- a/tests/futarchy/unit/executeSpendingLimitChange.test.ts +++ b/tests/futarchy/unit/executeSpendingLimitChange.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index 441100f67..1eedf946e 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -3,7 +3,7 @@ import { PriceMath, getDaoAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/finalizeProposal.test.ts b/tests/futarchy/unit/finalizeProposal.test.ts index 99ddca942..42564fd7b 100644 --- a/tests/futarchy/unit/finalizeProposal.test.ts +++ b/tests/futarchy/unit/finalizeProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy-v2"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 6b5919ba4..0eb7a5b9b 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 70414c9ee..615c39022 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 430b2d7ed..03ccb889b 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -4,7 +4,7 @@ import { SQUADS_PROGRAM_ID, getDaoAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index 0e9b25765..9aee0cd8c 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -3,7 +3,7 @@ import { PriceMath, getDaoAddr, getProposalAddrV2, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/provideLiquidity.test.ts b/tests/futarchy/unit/provideLiquidity.test.ts index dfc0ae01a..2079811f6 100644 --- a/tests/futarchy/unit/provideLiquidity.test.ts +++ b/tests/futarchy/unit/provideLiquidity.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { FUTARCHY_V0_6_PROGRAM_ID } from "@metadaoproject/futarchy-v2"; +import { FUTARCHY_V0_6_PROGRAM_ID } from "@metadaoproject/futarchy"; import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, diff --git a/tests/futarchy/unit/unstakeFromProposal.test.ts b/tests/futarchy/unit/unstakeFromProposal.test.ts index 7271c56ff..3f21090fc 100644 --- a/tests/futarchy/unit/unstakeFromProposal.test.ts +++ b/tests/futarchy/unit/unstakeFromProposal.test.ts @@ -1,7 +1,7 @@ import { InstructionUtils, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 6b4d82511..047a4b1a2 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -15,7 +15,7 @@ import { PriceMath, MAINNET_USDC, sha256, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; import { setOptimisticGovernanceEnabled } from "../../utils.js"; diff --git a/tests/integration/fullLaunch.test.ts b/tests/integration/fullLaunch.test.ts index 9aa1f9d06..6c47a1057 100644 --- a/tests/integration/fullLaunch.test.ts +++ b/tests/integration/fullLaunch.test.ts @@ -12,7 +12,7 @@ import { LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad/utils.js"; import { createLookupTableForTransaction } from "../utils.js"; diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index 498b33766..a1f6d9d9e 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -13,7 +13,7 @@ import { LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad_v7/utils.js"; import { createLookupTableForTransaction, expectError } from "../utils.js"; diff --git a/tests/integration/mintAndSwap.test.ts b/tests/integration/mintAndSwap.test.ts index 3022543fc..752e0397b 100644 --- a/tests/integration/mintAndSwap.test.ts +++ b/tests/integration/mintAndSwap.test.ts @@ -2,7 +2,7 @@ import { ConditionalVaultClient, FutarchyClient, InstructionUtils, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { PublicKey, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; diff --git a/tests/launchpad/main.test.ts b/tests/launchpad/main.test.ts index 6d7d3b719..df542acd6 100644 --- a/tests/launchpad/main.test.ts +++ b/tests/launchpad/main.test.ts @@ -7,14 +7,12 @@ import refund from "./unit/refund.test.js"; import closeLaunch from "./unit/closeLaunch.test.js"; import returnFunds from "./unit/returnFunds.test.js"; import { PublicKey } from "@solana/web3.js"; -import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; import { LAUNCHPAD_V0_6_PROGRAM_ID, LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; -import { BankrunProvider } from "anchor-bankrun"; // TODO add a many-outcome integration test export default function suite() { diff --git a/tests/launchpad/unit/claim.test.ts b/tests/launchpad/unit/claim.test.ts index 0d3678b9e..aa0595dc9 100644 --- a/tests/launchpad/unit/claim.test.ts +++ b/tests/launchpad/unit/claim.test.ts @@ -8,8 +8,8 @@ import { assert } from "chai"; import { getFundingRecordAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/closeLaunch.test.ts b/tests/launchpad/unit/closeLaunch.test.ts index d583e6a5f..6447eb5aa 100644 --- a/tests/launchpad/unit/closeLaunch.test.ts +++ b/tests/launchpad/unit/closeLaunch.test.ts @@ -1,7 +1,7 @@ import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; +import { MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/completeLaunch.test.ts b/tests/launchpad/unit/completeLaunch.test.ts index 206b72281..e1ae2ead8 100644 --- a/tests/launchpad/unit/completeLaunch.test.ts +++ b/tests/launchpad/unit/completeLaunch.test.ts @@ -9,12 +9,12 @@ import { FutarchyClient, getMetadataAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { getLiquidityPoolAddr, getRaydiumCpmmLpMintAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad/unit/fund.test.ts b/tests/launchpad/unit/fund.test.ts index c48bc2b5b..6e8ae1b94 100644 --- a/tests/launchpad/unit/fund.test.ts +++ b/tests/launchpad/unit/fund.test.ts @@ -3,8 +3,8 @@ import { assert } from "chai"; import { getFundingRecordAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; +import { MAINNET_USDC } from "@metadaoproject/futarchy"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad/unit/initializeLaunch.test.ts b/tests/launchpad/unit/initializeLaunch.test.ts index 6d868b611..28662e43e 100644 --- a/tests/launchpad/unit/initializeLaunch.test.ts +++ b/tests/launchpad/unit/initializeLaunch.test.ts @@ -9,7 +9,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; @@ -18,7 +18,7 @@ import { getMetadataAddr, MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad/unit/refund.test.ts b/tests/launchpad/unit/refund.test.ts index 678c20aa8..34414a435 100644 --- a/tests/launchpad/unit/refund.test.ts +++ b/tests/launchpad/unit/refund.test.ts @@ -5,8 +5,8 @@ import { VersionedTransaction, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/returnFunds.test.ts b/tests/launchpad/unit/returnFunds.test.ts index 97291f514..7c9bea630 100644 --- a/tests/launchpad/unit/returnFunds.test.ts +++ b/tests/launchpad/unit/returnFunds.test.ts @@ -3,8 +3,8 @@ import { assert } from "chai"; import { getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/launchpad/unit/startLaunch.test.ts b/tests/launchpad/unit/startLaunch.test.ts index b1e37f46e..13e017e8b 100644 --- a/tests/launchpad/unit/startLaunch.test.ts +++ b/tests/launchpad/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad/utils.ts b/tests/launchpad/utils.ts index d294494f3..5e7cd4048 100644 --- a/tests/launchpad/utils.ts +++ b/tests/launchpad/utils.ts @@ -5,7 +5,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/launchpad_v7/main.test.ts b/tests/launchpad_v7/main.test.ts index 9cfb21772..415b6645f 100644 --- a/tests/launchpad_v7/main.test.ts +++ b/tests/launchpad_v7/main.test.ts @@ -14,7 +14,7 @@ import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; // TODO add a many-outcome integration test diff --git a/tests/launchpad_v7/unit/claim.test.ts b/tests/launchpad_v7/unit/claim.test.ts index 56fcfb372..66be40c69 100644 --- a/tests/launchpad_v7/unit/claim.test.ts +++ b/tests/launchpad_v7/unit/claim.test.ts @@ -11,7 +11,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts index 3b2e0792d..9a3cd3929 100644 --- a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts +++ b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts @@ -11,7 +11,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/closeLaunch.test.ts b/tests/launchpad_v7/unit/closeLaunch.test.ts index b99efb61c..bcea0585c 100644 --- a/tests/launchpad_v7/unit/closeLaunch.test.ts +++ b/tests/launchpad_v7/unit/closeLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/completeLaunch.test.ts b/tests/launchpad_v7/unit/completeLaunch.test.ts index f30f591a3..fa950e615 100644 --- a/tests/launchpad_v7/unit/completeLaunch.test.ts +++ b/tests/launchpad_v7/unit/completeLaunch.test.ts @@ -11,7 +11,7 @@ import { getMetadataAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/extendLaunch.test.ts b/tests/launchpad_v7/unit/extendLaunch.test.ts index a24069a56..d8b2b46a6 100644 --- a/tests/launchpad_v7/unit/extendLaunch.test.ts +++ b/tests/launchpad_v7/unit/extendLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/fund.test.ts b/tests/launchpad_v7/unit/fund.test.ts index 70a852e27..400c286ed 100644 --- a/tests/launchpad_v7/unit/fund.test.ts +++ b/tests/launchpad_v7/unit/fund.test.ts @@ -9,7 +9,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad_v7/unit/initializeLaunch.test.ts b/tests/launchpad_v7/unit/initializeLaunch.test.ts index 6f9dca305..d0b4942a4 100644 --- a/tests/launchpad_v7/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v7/unit/initializeLaunch.test.ts @@ -12,14 +12,14 @@ import { getLaunchSignerAddr, getMetadataAddr, LaunchpadClient, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; import { MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts index 242c5d5a3..a6dc354b0 100644 --- a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts +++ b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts @@ -13,7 +13,7 @@ import { LaunchpadClient, MAINNET_USDC, PriceBasedPerformancePackageClient, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/refund.test.ts b/tests/launchpad_v7/unit/refund.test.ts index 31fece2ef..5126d3bab 100644 --- a/tests/launchpad_v7/unit/refund.test.ts +++ b/tests/launchpad_v7/unit/refund.test.ts @@ -10,7 +10,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts index b5e8ef7d6..be2f8d52d 100644 --- a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts +++ b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts @@ -9,7 +9,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/startLaunch.test.ts b/tests/launchpad_v7/unit/startLaunch.test.ts index a1bd0da9b..d849ef6c5 100644 --- a/tests/launchpad_v7/unit/startLaunch.test.ts +++ b/tests/launchpad_v7/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey, Signer } from "@solana/web3.js"; import { assert } from "chai"; -import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy-v2"; +import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { MAINNET_USDC } from "@metadaoproject/futarchy-v2"; +import { MAINNET_USDC } from "@metadaoproject/futarchy"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad_v7/utils.ts b/tests/launchpad_v7/utils.ts index 8af05d043..2fcb984d5 100644 --- a/tests/launchpad_v7/utils.ts +++ b/tests/launchpad_v7/utils.ts @@ -1,11 +1,8 @@ import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { BanksClient } from "solana-bankrun"; -import { LaunchpadClient } from "@metadaoproject/futarchy-v2"; -import { - getLaunchAddr, - getLaunchSignerAddr, -} from "@metadaoproject/futarchy-v2"; +import { LaunchpadClient } from "@metadaoproject/futarchy"; +import { getLaunchAddr, getLaunchSignerAddr } from "@metadaoproject/futarchy"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/liquidation/main.test.ts b/tests/liquidation/main.test.ts index 3ac0c3379..1ca2fca86 100644 --- a/tests/liquidation/main.test.ts +++ b/tests/liquidation/main.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { BankrunProvider } from "anchor-bankrun"; import initializeLiquidation from "./unit/initializeLiquidation.test.js"; import setRefundRecord from "./unit/setRefundRecord.test.js"; diff --git a/tests/liquidation/unit/activateLiquidation.test.ts b/tests/liquidation/unit/activateLiquidation.test.ts index 61189b341..1bce84268 100644 --- a/tests/liquidation/unit/activateLiquidation.test.ts +++ b/tests/liquidation/unit/activateLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/initializeLiquidation.test.ts b/tests/liquidation/unit/initializeLiquidation.test.ts index 43564bc7a..d28d40c88 100644 --- a/tests/liquidation/unit/initializeLiquidation.test.ts +++ b/tests/liquidation/unit/initializeLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import * as token from "@solana/spl-token"; diff --git a/tests/liquidation/unit/refund.test.ts b/tests/liquidation/unit/refund.test.ts index 16bddeb7d..0d57b9f9c 100644 --- a/tests/liquidation/unit/refund.test.ts +++ b/tests/liquidation/unit/refund.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { Keypair, PublicKey, diff --git a/tests/liquidation/unit/setRefundRecord.test.ts b/tests/liquidation/unit/setRefundRecord.test.ts index fb89f6d95..5235239c0 100644 --- a/tests/liquidation/unit/setRefundRecord.test.ts +++ b/tests/liquidation/unit/setRefundRecord.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/withdrawRemainingQuote.test.ts b/tests/liquidation/unit/withdrawRemainingQuote.test.ts index ed1797120..93f10d27f 100644 --- a/tests/liquidation/unit/withdrawRemainingQuote.test.ts +++ b/tests/liquidation/unit/withdrawRemainingQuote.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/utils.ts b/tests/liquidation/utils.ts index 0c4e37d8c..981352315 100644 --- a/tests/liquidation/utils.ts +++ b/tests/liquidation/utils.ts @@ -4,7 +4,7 @@ import { ComputeBudgetProgram, SystemProgram, } from "@solana/web3.js"; -import { LiquidationClient } from "@metadaoproject/futarchy-v2"; +import { LiquidationClient } from "@metadaoproject/futarchy"; import BN from "bn.js"; export async function setupLiquidation(ctx: Mocha.Context): Promise<{ diff --git a/tests/main.test.ts b/tests/main.test.ts index 783954674..040fa7b63 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -39,8 +39,8 @@ import { LiquidationClient, LOW_FEE_RAYDIUM_CONFIG, sha256, -} from "@metadaoproject/futarchy-v2"; -import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy-v2/launchpad/v0.6"; +} from "@metadaoproject/futarchy"; +import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, diff --git a/tests/mintGovernor/main.test.ts b/tests/mintGovernor/main.test.ts index 8b8297b50..9c5394121 100644 --- a/tests/mintGovernor/main.test.ts +++ b/tests/mintGovernor/main.test.ts @@ -6,7 +6,7 @@ import removeMintAuthority from "./unit/removeMintAuthority.test.js"; import mintTokens from "./unit/mintTokens.test.js"; import updateMintGovernorAdmin from "./unit/updateMintGovernorAdmin.test.js"; import reclaimAuthority from "./unit/reclaimAuthority.test.js"; -import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; +import { MintGovernorClient } from "@metadaoproject/futarchy"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/mintGovernor/unit/addMintAuthority.test.ts b/tests/mintGovernor/unit/addMintAuthority.test.ts index 1a739d7c0..b26b62202 100644 --- a/tests/mintGovernor/unit/addMintAuthority.test.ts +++ b/tests/mintGovernor/unit/addMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/initializeMintGovernor.test.ts b/tests/mintGovernor/unit/initializeMintGovernor.test.ts index 657684cbe..ab5ccb690 100644 --- a/tests/mintGovernor/unit/initializeMintGovernor.test.ts +++ b/tests/mintGovernor/unit/initializeMintGovernor.test.ts @@ -3,7 +3,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { createMintWithAuthority } from "../utils.js"; export default function suite() { diff --git a/tests/mintGovernor/unit/mintTokens.test.ts b/tests/mintGovernor/unit/mintTokens.test.ts index 0b1f65703..df596d1f8 100644 --- a/tests/mintGovernor/unit/mintTokens.test.ts +++ b/tests/mintGovernor/unit/mintTokens.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintWithGovernor, createMintAndGovernor, diff --git a/tests/mintGovernor/unit/reclaimAuthority.test.ts b/tests/mintGovernor/unit/reclaimAuthority.test.ts index d56815ebc..f845bb56d 100644 --- a/tests/mintGovernor/unit/reclaimAuthority.test.ts +++ b/tests/mintGovernor/unit/reclaimAuthority.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintWithGovernor, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/removeMintAuthority.test.ts b/tests/mintGovernor/unit/removeMintAuthority.test.ts index 80c105b6d..6b965112d 100644 --- a/tests/mintGovernor/unit/removeMintAuthority.test.ts +++ b/tests/mintGovernor/unit/removeMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts index ccd0bd72e..dc4ffccc2 100644 --- a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts +++ b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; +import { MintGovernorClient } from "@metadaoproject/futarchy"; import { createMintWithAuthority, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintAuthority.test.ts b/tests/mintGovernor/unit/updateMintAuthority.test.ts index f94ca83eb..67fbcdbbd 100644 --- a/tests/mintGovernor/unit/updateMintAuthority.test.ts +++ b/tests/mintGovernor/unit/updateMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts index 9f7e83fbc..1af8fd1bd 100644 --- a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts +++ b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy-v2"; +import { MintGovernorClient } from "@metadaoproject/futarchy"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/utils.ts b/tests/mintGovernor/utils.ts index 07f7ac585..0292ba662 100644 --- a/tests/mintGovernor/utils.ts +++ b/tests/mintGovernor/utils.ts @@ -9,7 +9,7 @@ import { BanksClient } from "solana-bankrun"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; /** * Creates a mint with the payer as the mint authority diff --git a/tests/performancePackageV2/main.test.ts b/tests/performancePackageV2/main.test.ts index acfcbdde1..be6e4d601 100644 --- a/tests/performancePackageV2/main.test.ts +++ b/tests/performancePackageV2/main.test.ts @@ -8,7 +8,7 @@ import closePerformancePackage from "./unit/closePerformancePackage.test.js"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/performancePackageV2/unit/changeAuthority.test.ts b/tests/performancePackageV2/unit/changeAuthority.test.ts index d2521edeb..155936537 100644 --- a/tests/performancePackageV2/unit/changeAuthority.test.ts +++ b/tests/performancePackageV2/unit/changeAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/closePerformancePackage.test.ts b/tests/performancePackageV2/unit/closePerformancePackage.test.ts index a8f264ecf..11cc5279f 100644 --- a/tests/performancePackageV2/unit/closePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/closePerformancePackage.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/completeUnlock.test.ts b/tests/performancePackageV2/unit/completeUnlock.test.ts index f20dcc005..03fec4be1 100644 --- a/tests/performancePackageV2/unit/completeUnlock.test.ts +++ b/tests/performancePackageV2/unit/completeUnlock.test.ts @@ -11,7 +11,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, setupMintGovernorWithAuthority, diff --git a/tests/performancePackageV2/unit/executeChange.test.ts b/tests/performancePackageV2/unit/executeChange.test.ts index 3391ad01d..1929f7461 100644 --- a/tests/performancePackageV2/unit/executeChange.test.ts +++ b/tests/performancePackageV2/unit/executeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts index 324ed07dd..ac8348696 100644 --- a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts @@ -5,7 +5,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupMintGovernorWithAuthority, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/proposeChange.test.ts b/tests/performancePackageV2/unit/proposeChange.test.ts index b3aa0f624..cc2ab6f49 100644 --- a/tests/performancePackageV2/unit/proposeChange.test.ts +++ b/tests/performancePackageV2/unit/proposeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/startUnlock.test.ts b/tests/performancePackageV2/unit/startUnlock.test.ts index b6e2ef634..5a6eae2b5 100644 --- a/tests/performancePackageV2/unit/startUnlock.test.ts +++ b/tests/performancePackageV2/unit/startUnlock.test.ts @@ -5,7 +5,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/utils.ts b/tests/performancePackageV2/utils.ts index 1b2dcd1d6..dec18500f 100644 --- a/tests/performancePackageV2/utils.ts +++ b/tests/performancePackageV2/utils.ts @@ -16,11 +16,11 @@ import { getPerformancePackageV2Addr, PriceMath, getDaoAddr, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; import type { PerformancePackageV2OracleReader, PerformancePackageV2RewardFunction, -} from "@metadaoproject/futarchy-v2"; +} from "@metadaoproject/futarchy"; /** * Creates a mint with the specified authority diff --git a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts index 3370f9893..87ff44596 100644 --- a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts @@ -7,10 +7,7 @@ import { import { assert } from "chai"; import { mintTo, getAccount } from "spl-token-bankrun"; import BN from "bn.js"; -import { - getPerformancePackageAddr, - Tranche, -} from "@metadaoproject/futarchy-v2"; +import { getPerformancePackageAddr, Tranche } from "@metadaoproject/futarchy"; import { expectError } from "../../utils.js"; import { getAssociatedTokenAddress } from "@solana/spl-token"; diff --git a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts index b1fa9c12b..2b5f0b8a9 100644 --- a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts @@ -8,7 +8,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy-v2"; +import { getPerformancePackageAddr } from "@metadaoproject/futarchy"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts index 52d43e1cc..0fda760d7 100644 --- a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts +++ b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts @@ -7,7 +7,7 @@ import { import { assert } from "chai"; import BN from "bn.js"; import { expectError } from "../../utils.js"; -import { getChangeRequestAddr } from "@metadaoproject/futarchy-v2"; +import { getChangeRequestAddr } from "@metadaoproject/futarchy"; export default function () { let createKey: Keypair; diff --git a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts index 2d91da2ee..737602350 100644 --- a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts @@ -7,10 +7,7 @@ import { import { assert } from "chai"; import { mintTo, getAccount } from "spl-token-bankrun"; import BN from "bn.js"; -import { - getPerformancePackageAddr, - Tranche, -} from "@metadaoproject/futarchy-v2"; +import { getPerformancePackageAddr, Tranche } from "@metadaoproject/futarchy"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts index 0a2ca4533..cb634242d 100644 --- a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts @@ -10,7 +10,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy-v2"; +import { getPerformancePackageAddr } from "@metadaoproject/futarchy"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/utils.ts b/tests/utils.ts index a0412115f..6c9e66b31 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -10,7 +10,7 @@ import { Transaction, } from "@solana/web3.js"; import { TestContext } from "./main.test.js"; -import { getDaoAddr, PriceMath } from "@metadaoproject/futarchy-v2"; +import { getDaoAddr, PriceMath } from "@metadaoproject/futarchy"; export const TEN_SECONDS_IN_SLOTS = 25n; export const ONE_MINUTE_IN_SLOTS = TEN_SECONDS_IN_SLOTS * 6n; diff --git a/yarn.lock b/yarn.lock index 25f20f7f1..02846c241 100644 --- a/yarn.lock +++ b/yarn.lock @@ -974,23 +974,8 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@metadaoproject/futarchy-v2@./sdk2": - version "0.7.3-alpha.1" - dependencies: - "@coral-xyz/anchor" "^0.29.0" - "@metaplex-foundation/umi" "^0.9.2" - "@metaplex-foundation/umi-bundle-defaults" "^0.9.2" - "@metaplex-foundation/umi-uploader-bundlr" "^0.9.2" - "@noble/hashes" "^1.4.0" - "@solana/spl-token" "^0.3.7" - "@solana/web3.js" "^1.76.0" - "@sqds/multisig" "^2.1.4" - bn.js "^5.2.1" - decimal.js "^10.4.3" - esbuild "^0.17.15" - -"@metadaoproject/futarchy@./sdk": - version "0.7.4-alpha.3" +"@metadaoproject/futarchy@./sdk2": + version "0.8.0-alpha.0" dependencies: "@coral-xyz/anchor" "^0.29.0" "@metaplex-foundation/umi" "^0.9.2" From 4d34c7d7f9d80071590aaf8f2d888182e83af44f Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 24 Apr 2026 22:41:38 +0200 Subject: [PATCH 089/100] fix up typescript errors in tests --- package.json | 2 +- sdk2/package.json | 2 +- sdk2/yarn.lock | 2 +- tests/bidWall/unit/collectFees.test.ts | 1 + tests/bidWall/unit/initializeBidWall.test.ts | 1 + tests/bidWall/unit/sellTokens.test.ts | 1 + tests/conditionalVault/unit.ts | 4 +-- .../unit/initializeQuestion.test.ts | 2 +- .../conditionalVault/unit/splitTokens.test.ts | 2 +- .../futarchy/integration/fullProposal.test.ts | 2 ++ .../futarchy/integration/futarchyAmm.test.ts | 1 + .../integration/proposalBatchTx.test.ts | 2 ++ .../futarchy/unit/adminCancelProposal.test.ts | 1 + .../futarchy/unit/adminRemoveProposal.test.ts | 1 + .../unit/collectMeteoraDammFees.test.ts | 13 +------- tests/futarchy/unit/finalizeProposal.test.ts | 2 ++ .../futarchy/unit/unstakeFromProposal.test.ts | 1 + tests/integration/fullLaunch_v7.test.ts | 1 + tests/integration/mintAndSwap.test.ts | 2 ++ .../unit/changeLockerAuthority.test.ts | 33 +++++++++---------- .../unit/initializePerformancePackage.test.ts | 26 +++++++-------- yarn.lock | 8 ++--- 22 files changed, 57 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 95e2393c1..e0d3ba4d6 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "ts-mocha": "^10.0.0", "ts-node": "^10.9.2", "tsx": "^4.7.1", - "typescript": "^4.3.5", + "typescript": "5.9.3", "typescript-eslint": "^8.43.0" }, "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e", diff --git a/sdk2/package.json b/sdk2/package.json index 6c6429124..4c5cfffb3 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -58,7 +58,7 @@ "solana-bankrun": "^0.2.0", "spl-token-bankrun": "0.2.3", "ts-mocha": "^10.0.0", - "typescript": "^5.5.5" + "typescript": "5.9.3" }, "resolutions": { "error-ex": "=1.3.2", diff --git a/sdk2/yarn.lock b/sdk2/yarn.lock index ced234393..bf1c0f358 100644 --- a/sdk2/yarn.lock +++ b/sdk2/yarn.lock @@ -3160,7 +3160,7 @@ typed-array-buffer@^1.0.3: es-errors "^1.3.0" is-typed-array "^1.1.14" -typescript@^5.5.5: +typescript@5.9.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== diff --git a/tests/bidWall/unit/collectFees.test.ts b/tests/bidWall/unit/collectFees.test.ts index 2c2cc1817..b71f8e26a 100644 --- a/tests/bidWall/unit/collectFees.test.ts +++ b/tests/bidWall/unit/collectFees.test.ts @@ -82,6 +82,7 @@ export default function suite() { performancePackageTokenAmount: new BN(10), // Effectively no premine monthsUntilInsidersCanUnlock: 24, // 2 years teamAddress: PublicKey.default, + hasBidWall: false, }) .rpc(); diff --git a/tests/bidWall/unit/initializeBidWall.test.ts b/tests/bidWall/unit/initializeBidWall.test.ts index 514456b9d..761e3ab92 100644 --- a/tests/bidWall/unit/initializeBidWall.test.ts +++ b/tests/bidWall/unit/initializeBidWall.test.ts @@ -81,6 +81,7 @@ export default function suite() { performancePackageTokenAmount: new BN(10), // Effectively no premine monthsUntilInsidersCanUnlock: 24, // 2 years teamAddress: PublicKey.default, + hasBidWall: false, }) .rpc(); diff --git a/tests/bidWall/unit/sellTokens.test.ts b/tests/bidWall/unit/sellTokens.test.ts index c8d86bcc4..1c3f6d5c1 100644 --- a/tests/bidWall/unit/sellTokens.test.ts +++ b/tests/bidWall/unit/sellTokens.test.ts @@ -78,6 +78,7 @@ export default function suite() { performancePackageTokenAmount: new BN(10), // Effectively no premine monthsUntilInsidersCanUnlock: 24, // 2 years teamAddress: PublicKey.default, + hasBidWall: false, }) .rpc(); diff --git a/tests/conditionalVault/unit.ts b/tests/conditionalVault/unit.ts index 678d63941..bff9c27b7 100644 --- a/tests/conditionalVault/unit.ts +++ b/tests/conditionalVault/unit.ts @@ -25,7 +25,7 @@ const { PublicKey, Keypair } = web3; import { ConditionalVault, IDL as ConditionalVaultIDL, -} from "../../target/types/conditional_vault"; +} from "../../target/types/conditional_vault.js"; import { CONDITIONAL_VAULT_v0_4_PROGRAM_ID, ConditionalVaultClient, @@ -463,7 +463,7 @@ describe("conditional_vault", async function () { ).then((acc) => acc.amount); await vaultClient - .redeemTokensIx(question, vault, underlyingTokenMint, new BN(600), 2) + .redeemTokensIx(question, vault, underlyingTokenMint, 2) .rpc(); const balanceAfter = await getAccount( diff --git a/tests/conditionalVault/unit/initializeQuestion.test.ts b/tests/conditionalVault/unit/initializeQuestion.test.ts index 6c9aca68a..79116a9bb 100644 --- a/tests/conditionalVault/unit/initializeQuestion.test.ts +++ b/tests/conditionalVault/unit/initializeQuestion.test.ts @@ -6,7 +6,7 @@ import { // const { ConditionalVaultClient, getQuestionAddr } = futarchy; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; -import { expectError } from "../../utils"; +import { expectError } from "../../utils.js"; // import { getQuestionAddr } from "@metadaoproject/futarchy/dist/v0.4"; export default function suite() { diff --git a/tests/conditionalVault/unit/splitTokens.test.ts b/tests/conditionalVault/unit/splitTokens.test.ts index a0686a604..749b39b4c 100644 --- a/tests/conditionalVault/unit/splitTokens.test.ts +++ b/tests/conditionalVault/unit/splitTokens.test.ts @@ -37,7 +37,7 @@ export default function suite() { underlyingTokenMint, this.payer.publicKey, this.payer, - 10_000_000_000n, + 10_000_000_000, ); }); diff --git a/tests/futarchy/integration/fullProposal.test.ts b/tests/futarchy/integration/fullProposal.test.ts index edc64c3a8..e2de48a65 100644 --- a/tests/futarchy/integration/fullProposal.test.ts +++ b/tests/futarchy/integration/fullProposal.test.ts @@ -1,3 +1,5 @@ +// @ts-nocheck +// TODO: fix this test and remove the @ts-nocheck import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index 6e6a8f299..b7675e285 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -78,6 +78,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); diff --git a/tests/futarchy/integration/proposalBatchTx.test.ts b/tests/futarchy/integration/proposalBatchTx.test.ts index df04d5c59..520cdc230 100644 --- a/tests/futarchy/integration/proposalBatchTx.test.ts +++ b/tests/futarchy/integration/proposalBatchTx.test.ts @@ -1,3 +1,5 @@ +// @ts-nocheck +// TODO: fix this test and remove the @ts-nocheck import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index d82afb773..a3ad1c2b6 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -74,6 +74,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); diff --git a/tests/futarchy/unit/adminRemoveProposal.test.ts b/tests/futarchy/unit/adminRemoveProposal.test.ts index 0e6f628b5..567736efc 100644 --- a/tests/futarchy/unit/adminRemoveProposal.test.ts +++ b/tests/futarchy/unit/adminRemoveProposal.test.ts @@ -50,6 +50,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); diff --git a/tests/futarchy/unit/collectMeteoraDammFees.test.ts b/tests/futarchy/unit/collectMeteoraDammFees.test.ts index 86f3da789..ba9f459e8 100644 --- a/tests/futarchy/unit/collectMeteoraDammFees.test.ts +++ b/tests/futarchy/unit/collectMeteoraDammFees.test.ts @@ -73,6 +73,7 @@ export default function suite() { performancePackageTokenAmount: premineAmount, monthsUntilInsidersCanUnlock: 18, teamAddress: PublicKey.default, + hasBidWall: false, }) .rpc(); @@ -176,16 +177,6 @@ export default function suite() { DAMM_V2_PROGRAM_ID, ); - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), META.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), MAINNET_USDC.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - const swapTx = await cpAmm._program.methods .swap({ amountIn: new BN(1_000_000), // 1 USDC swap @@ -202,8 +193,6 @@ export default function suite() { payer: this.payer.publicKey, pool: pool, program: DAMM_V2_PROGRAM_ID, - tokenAVault: tokenAVault, - tokenBVault: tokenBVault, }) .transaction(); diff --git a/tests/futarchy/unit/finalizeProposal.test.ts b/tests/futarchy/unit/finalizeProposal.test.ts index 42564fd7b..9f7a5e96d 100644 --- a/tests/futarchy/unit/finalizeProposal.test.ts +++ b/tests/futarchy/unit/finalizeProposal.test.ts @@ -74,6 +74,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); @@ -434,6 +435,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); diff --git a/tests/futarchy/unit/unstakeFromProposal.test.ts b/tests/futarchy/unit/unstakeFromProposal.test.ts index 3f21090fc..818cbe3a6 100644 --- a/tests/futarchy/unit/unstakeFromProposal.test.ts +++ b/tests/futarchy/unit/unstakeFromProposal.test.ts @@ -76,6 +76,7 @@ export default function suite() { twapStartDelaySeconds: null, teamSponsoredPassThresholdBps: null, teamAddress: null, + isOptimisticGovernanceEnabled: null, }, }) .instruction(); diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index a1f6d9d9e..d8f671526 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -164,6 +164,7 @@ export default async function suite() { monthsUntilInsidersCanUnlock: 24, teamAddress: PublicKey.default, launchAuthority: launchAuthority.publicKey, + hasBidWall: false, }) .rpc(); diff --git a/tests/integration/mintAndSwap.test.ts b/tests/integration/mintAndSwap.test.ts index 752e0397b..08435eed3 100644 --- a/tests/integration/mintAndSwap.test.ts +++ b/tests/integration/mintAndSwap.test.ts @@ -44,6 +44,8 @@ export default async function test() { nonce, initialSpendingLimit: null, baseToStake: new BN(0), + teamAddress: PublicKey.default, + teamSponsoredPassThresholdBps: 0, }, provideLiquidity: false, }) diff --git a/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts b/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts index 2e7d34709..3eb5f5413 100644 --- a/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts +++ b/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts @@ -6,6 +6,10 @@ import { } from "@solana/web3.js"; import { assert } from "chai"; import BN from "bn.js"; +import { + getPerformancePackageAddr, + InitializePerformancePackageParams, +} from "@metadaoproject/futarchy"; export default function () { let createKey: Keypair; @@ -64,9 +68,7 @@ export default function () { await this.mintTo(tokenMint, tokenAuthority, this.payer, 1000000); // 1M tokens // Initialize a performancePackage - const params = { - priceThreshold: new BN(1000000), - tokenAmount: new BN(100000), + const params: InitializePerformancePackageParams = { minUnlockTimestamp: new BN( Number((await this.context.banksClient.getClock()).unixTimestamp) + 3600, @@ -75,9 +77,12 @@ export default function () { oracleAccount: oracleAccount.publicKey, byteOffset: 0, }, - twapLengthSeconds: new BN(3600), - tokenRecipient: recipient.publicKey, + twapLengthSeconds: 3600, + grantee: recipient.publicKey, performancePackageAuthority: currentAuthority.publicKey, + tranches: [ + { priceThreshold: new BN(1000000), tokenAmount: new BN(100000) }, + ], }; await this.priceBasedPerformancePackage @@ -85,17 +90,15 @@ export default function () { params, createKey: createKey.publicKey, tokenMint, - fromTokenAccount: tokenAccount, - tokenAuthority: tokenAuthority, - payer: this.payer.publicKey, + grantor: tokenAuthority, + grantorTokenAccount: tokenAccount, }) .rpc(); // Get performancePackage address - performancePackage = - this.priceBasedPerformancePackage.getPerformancePackage( - createKey.publicKey, - ); + performancePackage = getPerformancePackageAddr({ + createKey: createKey.publicKey, + })[0]; }); it("should change performancePackage authority successfully", async function () { @@ -248,7 +251,6 @@ export default function () { }, performancePackage, proposer: newAuthority.publicKey, // New authority proposes - payer: newAuthority.publicKey, }) .transaction(); @@ -270,9 +272,6 @@ export default function () { await this.priceBasedPerformancePackage.getChangeRequest( changeRequestAddr, ); - assert.equal( - changeRequest.proposer.toString(), - newAuthority.publicKey.toString(), - ); + assert.isNotNull(changeRequest.proposerType.authority); }); } diff --git a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts index 737602350..f21b1eedb 100644 --- a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts @@ -7,7 +7,11 @@ import { import { assert } from "chai"; import { mintTo, getAccount } from "spl-token-bankrun"; import BN from "bn.js"; -import { getPerformancePackageAddr, Tranche } from "@metadaoproject/futarchy"; +import { + getPerformancePackageAddr, + InitializePerformancePackageParams, + Tranche, +} from "@metadaoproject/futarchy"; import { expectError } from "../../utils.js"; export default function () { @@ -85,7 +89,7 @@ export default function () { tokenAmount: new BN(200000), }, ]; - const params = { + const params: InitializePerformancePackageParams = { tranches, grantee: recipient.publicKey, performancePackageAuthority: this.payer.publicKey, @@ -97,8 +101,7 @@ export default function () { oracleAccount: oracleAccount.publicKey, byteOffset: 0, }, - twapLengthSeconds: new BN(86_400), // 1 day - tokenRecipient: recipient.publicKey, + twapLengthSeconds: 86_400, // 1 day }; const tx = await this.priceBasedPerformancePackage @@ -199,7 +202,7 @@ export default function () { fundingTx.sign(this.payer); await this.banksClient.processTransaction(fundingTx); - const params = { + const params: InitializePerformancePackageParams = { tranches: [ { priceThreshold: new BN(1000000), @@ -216,8 +219,7 @@ export default function () { oracleAccount: oracleAccount.publicKey, byteOffset: 0, }, - twapLengthSeconds: new BN(24 * 60 * 60), - tokenRecipient: recipient.publicKey, + twapLengthSeconds: 24 * 60 * 60, }; const tx = await this.priceBasedPerformancePackage @@ -252,7 +254,7 @@ export default function () { it("should fail if recipient equals authority", async function () { const sameKeyCreateKey = Keypair.generate(); - const params = { + const params: InitializePerformancePackageParams = { tranches: [ { priceThreshold: new BN(1000000), @@ -269,8 +271,7 @@ export default function () { oracleAccount: oracleAccount.publicKey, byteOffset: 0, }, - twapLengthSeconds: new BN(86_400), - tokenRecipient: this.payer.publicKey, + twapLengthSeconds: 86_400, }; const callbacks = expectError( @@ -307,7 +308,7 @@ export default function () { fundingTx.sign(this.payer); await this.banksClient.processTransaction(fundingTx); - const params = { + const params: InitializePerformancePackageParams = { tranches: [ { priceThreshold: new BN(1000000), @@ -324,8 +325,7 @@ export default function () { oracleAccount: oracleAccount.publicKey, byteOffset: 0, }, - twapLengthSeconds: new BN(3600), - tokenRecipient: recipient.publicKey, + twapLengthSeconds: 3600, }; const callbacks = expectError( diff --git a/yarn.lock b/yarn.lock index 02846c241..937d44c21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4729,10 +4729,10 @@ typescript-eslint@^8.43.0: "@typescript-eslint/typescript-estree" "8.46.2" "@typescript-eslint/utils" "8.46.2" -typescript@^4.3.5: - version "4.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== +typescript@5.9.3: + version "5.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== u3@^0.1.1: version "0.1.1" From 1b670c891a6092372144d097cbc49f914e464c22 Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 25 Apr 2026 00:35:52 +0200 Subject: [PATCH 090/100] add v0.3 clients, fix autocomplete behavior for imports --- sdk2/package.json | 38 +- sdk2/src/amm/v0.3/AmmClient.ts | 354 +++++ sdk2/src/amm/v0.3/index.ts | 3 + sdk2/src/amm/v0.3/pda.ts | 28 + sdk2/src/amm/v0.3/types/amm.ts | 1083 ++++++++++++++ sdk2/src/amm/v0.3/types/index.ts | 6 + sdk2/src/autocrat/v0.3/AutocratClient.ts | 717 ++++++++++ sdk2/src/autocrat/v0.3/cu.ts | 11 + sdk2/src/autocrat/v0.3/index.ts | 4 + sdk2/src/autocrat/v0.3/pda.ts | 26 + sdk2/src/autocrat/v0.3/types/autocrat.ts | 1263 +++++++++++++++++ sdk2/src/autocrat/v0.3/types/index.ts | 13 + .../v0.3/ConditionalVaultClient.ts | 341 +++++ sdk2/src/conditional_vault/v0.3/index.ts | 8 + sdk2/src/conditional_vault/v0.3/pda.ts | 43 + .../v0.3/types/conditional_vault.ts | 895 ++++++++++++ .../src/conditional_vault/v0.3/types/index.ts | 10 + sdk2/src/constants.ts | 10 + 18 files changed, 4837 insertions(+), 16 deletions(-) create mode 100644 sdk2/src/amm/v0.3/AmmClient.ts create mode 100644 sdk2/src/amm/v0.3/index.ts create mode 100644 sdk2/src/amm/v0.3/pda.ts create mode 100644 sdk2/src/amm/v0.3/types/amm.ts create mode 100644 sdk2/src/amm/v0.3/types/index.ts create mode 100644 sdk2/src/autocrat/v0.3/AutocratClient.ts create mode 100644 sdk2/src/autocrat/v0.3/cu.ts create mode 100644 sdk2/src/autocrat/v0.3/index.ts create mode 100644 sdk2/src/autocrat/v0.3/pda.ts create mode 100644 sdk2/src/autocrat/v0.3/types/autocrat.ts create mode 100644 sdk2/src/autocrat/v0.3/types/index.ts create mode 100644 sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts create mode 100644 sdk2/src/conditional_vault/v0.3/index.ts create mode 100644 sdk2/src/conditional_vault/v0.3/pda.ts create mode 100644 sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts create mode 100644 sdk2/src/conditional_vault/v0.3/types/index.ts diff --git a/sdk2/package.json b/sdk2/package.json index 4c5cfffb3..137a8b4de 100644 --- a/sdk2/package.json +++ b/sdk2/package.json @@ -7,22 +7,28 @@ "types": "dist/index.d.ts", "exports": { ".": "./dist/index.js", - "./bid_wall/v0.7": "./dist/bid_wall/v0.7/index.js", - "./conditional_vault/v0.4": "./dist/conditional_vault/v0.4/index.js", - "./futarchy/v0.6": "./dist/futarchy/v0.6/index.js", - "./launchpad/v0.6": "./dist/launchpad/v0.6/index.js", - "./launchpad/v0.7": "./dist/launchpad/v0.7/index.js", - "./liquidation/v0.7": "./dist/liquidation/v0.7/index.js", - "./mint_governor/v0.7": "./dist/mint_governor/v0.7/index.js", - "./performance_package_v2/v0.7": "./dist/performance_package_v2/v0.7/index.js", - "./price_based_performance_package/v0.6": "./dist/price_based_performance_package/v0.6/index.js", - "./autocrat/v0.5": "./dist/autocrat/v0.5/index.js", - "./amm/v0.5": "./dist/amm/v0.5/index.js", - "./launchpad/v0.5": "./dist/launchpad/v0.5/index.js", - "./shared_liquidity_manager/v0.5": "./dist/shared_liquidity_manager/v0.5/index.js", - "./autocrat/v0.4": "./dist/autocrat/v0.4/index.js", - "./amm/v0.4": "./dist/amm/v0.4/index.js", - "./launchpad/v0.4": "./dist/launchpad/v0.4/index.js" + "./amm": "./dist/amm/index.js", + "./autocrat": "./dist/autocrat/index.js", + "./bid_wall": "./dist/bid_wall/index.js", + "./conditional_vault": "./dist/conditional_vault/index.js", + "./futarchy": "./dist/futarchy/index.js", + "./launchpad": "./dist/launchpad/index.js", + "./liquidation": "./dist/liquidation/index.js", + "./mint_governor": "./dist/mint_governor/index.js", + "./performance_package_v2": "./dist/performance_package_v2/index.js", + "./price_based_performance_package": "./dist/price_based_performance_package/index.js", + "./shared_liquidity_manager": "./dist/shared_liquidity_manager/index.js", + "./amm/*": "./dist/amm/*/index.js", + "./autocrat/*": "./dist/autocrat/*/index.js", + "./bid_wall/*": "./dist/bid_wall/*/index.js", + "./conditional_vault/*": "./dist/conditional_vault/*/index.js", + "./futarchy/*": "./dist/futarchy/*/index.js", + "./launchpad/*": "./dist/launchpad/*/index.js", + "./liquidation/*": "./dist/liquidation/*/index.js", + "./mint_governor/*": "./dist/mint_governor/*/index.js", + "./performance_package_v2/*": "./dist/performance_package_v2/*/index.js", + "./price_based_performance_package/*": "./dist/price_based_performance_package/*/index.js", + "./shared_liquidity_manager/*": "./dist/shared_liquidity_manager/*/index.js" }, "license": "BSL-1.0", "files": [ diff --git a/sdk2/src/amm/v0.3/AmmClient.ts b/sdk2/src/amm/v0.3/AmmClient.ts new file mode 100644 index 000000000..1e933ef20 --- /dev/null +++ b/sdk2/src/amm/v0.3/AmmClient.ts @@ -0,0 +1,354 @@ +import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; +import { AddressLookupTableAccount, Keypair, PublicKey } from "@solana/web3.js"; + +import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; + +import BN from "bn.js"; +import { AMM_V0_3_PROGRAM_ID } from "../../constants.js"; +import { Amm } from "./types/index.js"; +import { LowercaseKeys } from "../../utils.js"; +import { getAmmLpMintAddr, getAmmAddr } from "./pda.js"; +import { + MintLayout, + unpackMint, + getAssociatedTokenAddressSync, + createAssociatedTokenAccountIdempotentInstruction, +} from "@solana/spl-token"; +import { AmmMath, PriceMath } from "../../priceMath.js"; + +export type SwapType = LowercaseKeys["SwapType"]>; + +export type CreateAmmClientParams = { + provider: AnchorProvider; + ammProgramId?: PublicKey; +}; + +export class AmmClient { + public readonly provider: AnchorProvider; + public readonly program: Program; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.program = new Program(AmmIDL, ammProgramId, provider); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateAmmClientParams, + ): AmmClient { + let { provider, ammProgramId: programId } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AmmClient(provider, programId || AMM_V0_3_PROGRAM_ID, luts); + } + + getProgramId(): PublicKey { + return this.program.programId; + } + + async createAmm( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + twapInitialObservation: number, + twapMaxObservationChangePerUpdate?: number, + ): Promise { + if (!twapMaxObservationChangePerUpdate) { + twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; + } + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + + let baseDecimals = unpackMint( + baseMint, + await this.provider.connection.getAccountInfo(baseMint), + ).decimals; + let quoteDecimals = unpackMint( + quoteMint, + await this.provider.connection.getAccountInfo(quoteMint), + ).decimals; + + let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = + PriceMath.getAmmPrices( + baseDecimals, + quoteDecimals, + twapInitialObservation, + twapMaxObservationChangePerUpdate, + ); + + await this.createAmmIx( + baseMint, + quoteMint, + twapFirstObservationScaled, + twapMaxObservationChangePerUpdateScaled, + ).rpc(); + + return amm; + } + + // both twap values need to be scaled beforehand + createAmmIx( + baseMint: PublicKey, + quoteMint: PublicKey, + twapInitialObservation: BN, + twapMaxObservationChangePerUpdate: BN, + ) { + let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); + let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); + + let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); + let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); + + return this.program.methods + .createAmm({ + twapInitialObservation, + twapMaxObservationChangePerUpdate, + }) + .accounts({ + user: this.provider.publicKey, + amm, + lpMint, + baseMint, + quoteMint, + vaultAtaBase, + vaultAtaQuote, + }); + } + + async addLiquidity( + amm: PublicKey, + quoteAmount?: number, + baseAmount?: number, + ) { + let storedAmm = await this.getAmm(amm); + + let lpMintSupply = unpackMint( + storedAmm.lpMint, + await this.provider.connection.getAccountInfo(storedAmm.lpMint), + ).supply; + + let quoteAmountCasted: BN | undefined; + let baseAmountCasted: BN | undefined; + + if (quoteAmount != undefined) { + let quoteDecimals = unpackMint( + storedAmm.quoteMint, + await this.provider.connection.getAccountInfo(storedAmm.quoteMint), + ).decimals; + quoteAmountCasted = new BN(quoteAmount).mul( + new BN(10).pow(new BN(quoteDecimals)), + ); + } + + if (baseAmount != undefined) { + let baseDecimals = unpackMint( + storedAmm.baseMint, + await this.provider.connection.getAccountInfo(storedAmm.baseMint), + ).decimals; + baseAmountCasted = new BN(baseAmount).mul( + new BN(10).pow(new BN(baseDecimals)), + ); + } + + if (lpMintSupply == 0n) { + if (quoteAmount == undefined || baseAmount == undefined) { + throw new Error( + "No pool created yet, you need to specify both base and quote", + ); + } + + return await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + quoteAmountCasted as BN, + baseAmountCasted as BN, + new BN(0), + ).rpc(); + } + + let sim = AmmMath.simulateAddLiquidity( + storedAmm.baseAmount, + storedAmm.quoteAmount, + Number(lpMintSupply), + baseAmountCasted, + quoteAmountCasted, + ); + + await this.addLiquidityIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + sim.quoteAmount, + sim.baseAmount, + sim.expectedLpTokens, + ).rpc(); + } + + addLiquidityIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + quoteAmount: BN, + maxBaseAmount: BN, + minLpTokens: BN, + user: PublicKey = this.provider.publicKey, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); + + const userLpAccount = getAssociatedTokenAddressSync(lpMint, user); + + return this.program.methods + .addLiquidity({ + quoteAmount, + maxBaseAmount, + minLpTokens, + }) + .accounts({ + user, + amm, + lpMint, + userLpAccount, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + userLpAccount, + this.provider.publicKey, + lpMint, + ), + ]); + } + + removeLiquidityIx( + ammAddr: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + lpTokensToBurn: BN, + minBaseAmount: BN, + minQuoteAmount: BN, + ) { + const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); + + return this.program.methods + .removeLiquidity({ + lpTokensToBurn, + minBaseAmount, + minQuoteAmount, + }) + .accounts({ + user: this.provider.publicKey, + amm: ammAddr, + lpMint, + userLpAccount: getAssociatedTokenAddressSync( + lpMint, + this.provider.publicKey, + ), + userBaseAccount: getAssociatedTokenAddressSync( + baseMint, + this.provider.publicKey, + ), + userQuoteAccount: getAssociatedTokenAddressSync( + quoteMint, + this.provider.publicKey, + ), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), + }); + } + + async swap( + amm: PublicKey, + swapType: SwapType, + inputAmount: number, + outputAmountMin: number, + ) { + const storedAmm = await this.getAmm(amm); + + let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); + let baseDecimals = await this.getDecimals(storedAmm.baseMint); + + let inputAmountScaled: BN; + let outputAmountMinScaled: BN; + if (swapType.buy) { + inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); + } else { + inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); + outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); + } + + return await this.swapIx( + amm, + storedAmm.baseMint, + storedAmm.quoteMint, + swapType, + inputAmountScaled, + outputAmountMinScaled, + ).rpc(); + } + + swapIx( + amm: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + swapType: SwapType, + inputAmount: BN, + outputAmountMin: BN, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const receivingToken = swapType.buy ? baseMint : quoteMint; + + return this.program.methods + .swap({ + swapType, + inputAmount, + outputAmountMin, + }) + .accounts({ + user, + amm, + userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), + userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), + vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), + vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + getAssociatedTokenAddressSync(receivingToken, user), + user, + receivingToken, + ), + ]); + } + + async crankThatTwap(amm: PublicKey) { + return this.crankThatTwapIx(amm).rpc(); + } + + crankThatTwapIx(amm: PublicKey) { + return this.program.methods.crankThatTwap().accounts({ + amm, + }); + } + + async getAmm(amm: PublicKey): Promise { + return await this.program.account.amm.fetch(amm); + } + + async getDecimals(mint: PublicKey): Promise { + return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) + .decimals; + } +} diff --git a/sdk2/src/amm/v0.3/index.ts b/sdk2/src/amm/v0.3/index.ts new file mode 100644 index 000000000..cf8af7f89 --- /dev/null +++ b/sdk2/src/amm/v0.3/index.ts @@ -0,0 +1,3 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./AmmClient.js"; diff --git a/sdk2/src/amm/v0.3/pda.ts b/sdk2/src/amm/v0.3/pda.ts new file mode 100644 index 000000000..6fdba69a8 --- /dev/null +++ b/sdk2/src/amm/v0.3/pda.ts @@ -0,0 +1,28 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { AMM_V0_3_PROGRAM_ID } from "../../constants.js"; + +export const getAmmAddr = ( + programId: PublicKey = AMM_V0_3_PROGRAM_ID, + baseMint: PublicKey, + quoteMint: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("amm__"), + baseMint.toBuffer(), + quoteMint.toBuffer(), + ], + programId, + ); +}; + +export const getAmmLpMintAddr = ( + programId: PublicKey = AMM_V0_3_PROGRAM_ID, + amm: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/amm/v0.3/types/amm.ts b/sdk2/src/amm/v0.3/types/amm.ts new file mode 100644 index 000000000..6e5bcf53a --- /dev/null +++ b/sdk2/src/amm/v0.3/types/amm.ts @@ -0,0 +1,1083 @@ +export type Amm = { + version: "0.3.0"; + name: "amm"; + instructions: [ + { + name: "createAmm"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "CreateAmmArgs"; + }; + }, + ]; + }, + { + name: "addLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddLiquidityArgs"; + }; + }, + ]; + }, + { + name: "removeLiquidity"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "lpMint"; + isMut: true; + isSigner: false; + }, + { + name: "userLpAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "RemoveLiquidityArgs"; + }; + }, + ]; + }, + { + name: "swap"; + accounts: [ + { + name: "user"; + isMut: true; + isSigner: true; + }, + { + name: "amm"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaBase"; + isMut: true; + isSigner: false; + }, + { + name: "vaultAtaQuote"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "SwapArgs"; + }; + }, + ]; + }, + { + name: "crankThatTwap"; + accounts: [ + { + name: "amm"; + isMut: true; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "amm"; + type: { + kind: "struct"; + fields: [ + { + name: "bump"; + type: "u8"; + }, + { + name: "createdAtSlot"; + type: "u64"; + }, + { + name: "lpMint"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "baseMintDecimals"; + type: "u8"; + }, + { + name: "quoteMintDecimals"; + type: "u8"; + }, + { + name: "baseAmount"; + type: "u64"; + }, + { + name: "quoteAmount"; + type: "u64"; + }, + { + name: "oracle"; + type: { + defined: "TwapOracle"; + }; + }, + ]; + }; + }, + ]; + types: [ + { + name: "AddLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "quoteAmount"; + docs: ["How much quote token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "maxBaseAmount"; + docs: ["The maximum base token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "minLpTokens"; + docs: ["The minimum LP token you will get back"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "CreateAmmArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + ]; + }; + }, + { + name: "RemoveLiquidityArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "lpTokensToBurn"; + type: "u64"; + }, + { + name: "minQuoteAmount"; + type: "u64"; + }, + { + name: "minBaseAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "SwapArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "outputAmountMin"; + type: "u64"; + }, + ]; + }; + }, + { + name: "TwapOracle"; + type: { + kind: "struct"; + fields: [ + { + name: "lastUpdatedSlot"; + type: "u64"; + }, + { + name: "lastPrice"; + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ]; + type: "u128"; + }, + { + name: "lastObservation"; + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ]; + type: "u128"; + }, + { + name: "aggregator"; + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at t2 being smaller than an aggregator at t1.", + ]; + type: "u128"; + }, + { + name: "maxObservationChangePerUpdate"; + docs: ["The most that an observation can change per update."]; + type: "u128"; + }, + { + name: "initialObservation"; + docs: ["What the initial `latest_observation` is set to."]; + type: "u128"; + }, + ]; + }; + }, + { + name: "SwapType"; + type: { + kind: "enum"; + variants: [ + { + name: "Buy"; + }, + { + name: "Sell"; + }, + ]; + }; + }, + ]; + errors: [ + { + code: 6000; + name: "NoSlotsPassed"; + msg: "Can't get a TWAP before some observations have been stored"; + }, + { + code: 6001; + name: "NoReserves"; + msg: "Can't swap through a pool without token reserves on either side"; + }, + { + code: 6002; + name: "InputAmountOverflow"; + msg: "Input token amount is too large for a swap, causes overflow"; + }, + { + code: 6003; + name: "AddLiquidityCalculationError"; + msg: "Add liquidity calculation error"; + }, + { + code: 6004; + name: "DecimalScaleError"; + msg: "Error in decimal scale conversion"; + }, + { + code: 6005; + name: "SameTokenMints"; + msg: "You can't create an AMM pool where the token mints are the same"; + }, + { + code: 6006; + name: "SwapSlippageExceeded"; + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; + }, + { + code: 6007; + name: "InsufficientBalance"; + msg: "The user had insufficient balance to do this"; + }, + { + code: 6008; + name: "ZeroLiquidityRemove"; + msg: "Must remove a non-zero amount of liquidity"; + }, + { + code: 6009; + name: "ZeroLiquidityToAdd"; + msg: "Cannot add liquidity with 0 tokens on either side"; + }, + { + code: 6010; + name: "ZeroMinLpTokens"; + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; + }, + { + code: 6011; + name: "AddLiquiditySlippageExceeded"; + msg: "LP wouldn't have gotten back `lp_token_min`"; + }, + { + code: 6012; + name: "AddLiquidityMaxBaseExceeded"; + msg: "LP would have spent more than `max_base_amount`"; + }, + { + code: 6013; + name: "InsufficientQuoteAmount"; + msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; + }, + { + code: 6014; + name: "ZeroSwapAmount"; + msg: "Users must swap a non-zero amount"; + }, + { + code: 6015; + name: "ConstantProductInvariantFailed"; + msg: "K should always be increasing"; + }, + { + code: 6016; + name: "CastingOverflow"; + msg: "Casting has caused an overflow"; + }, + ]; +}; + +export const IDL: Amm = { + version: "0.3.0", + name: "amm", + instructions: [ + { + name: "createAmm", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "CreateAmmArgs", + }, + }, + ], + }, + { + name: "addLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddLiquidityArgs", + }, + }, + ], + }, + { + name: "removeLiquidity", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "lpMint", + isMut: true, + isSigner: false, + }, + { + name: "userLpAccount", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "RemoveLiquidityArgs", + }, + }, + ], + }, + { + name: "swap", + accounts: [ + { + name: "user", + isMut: true, + isSigner: true, + }, + { + name: "amm", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaBase", + isMut: true, + isSigner: false, + }, + { + name: "vaultAtaQuote", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "SwapArgs", + }, + }, + ], + }, + { + name: "crankThatTwap", + accounts: [ + { + name: "amm", + isMut: true, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "amm", + type: { + kind: "struct", + fields: [ + { + name: "bump", + type: "u8", + }, + { + name: "createdAtSlot", + type: "u64", + }, + { + name: "lpMint", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "baseMintDecimals", + type: "u8", + }, + { + name: "quoteMintDecimals", + type: "u8", + }, + { + name: "baseAmount", + type: "u64", + }, + { + name: "quoteAmount", + type: "u64", + }, + { + name: "oracle", + type: { + defined: "TwapOracle", + }, + }, + ], + }, + }, + ], + types: [ + { + name: "AddLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "quoteAmount", + docs: ["How much quote token you will deposit to the pool"], + type: "u64", + }, + { + name: "maxBaseAmount", + docs: ["The maximum base token you will deposit to the pool"], + type: "u64", + }, + { + name: "minLpTokens", + docs: ["The minimum LP token you will get back"], + type: "u64", + }, + ], + }, + }, + { + name: "CreateAmmArgs", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + ], + }, + }, + { + name: "RemoveLiquidityArgs", + type: { + kind: "struct", + fields: [ + { + name: "lpTokensToBurn", + type: "u64", + }, + { + name: "minQuoteAmount", + type: "u64", + }, + { + name: "minBaseAmount", + type: "u64", + }, + ], + }, + }, + { + name: "SwapArgs", + type: { + kind: "struct", + fields: [ + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "inputAmount", + type: "u64", + }, + { + name: "outputAmountMin", + type: "u64", + }, + ], + }, + }, + { + name: "TwapOracle", + type: { + kind: "struct", + fields: [ + { + name: "lastUpdatedSlot", + type: "u64", + }, + { + name: "lastPrice", + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ], + type: "u128", + }, + { + name: "lastObservation", + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ], + type: "u128", + }, + { + name: "aggregator", + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at t2 being smaller than an aggregator at t1.", + ], + type: "u128", + }, + { + name: "maxObservationChangePerUpdate", + docs: ["The most that an observation can change per update."], + type: "u128", + }, + { + name: "initialObservation", + docs: ["What the initial `latest_observation` is set to."], + type: "u128", + }, + ], + }, + }, + { + name: "SwapType", + type: { + kind: "enum", + variants: [ + { + name: "Buy", + }, + { + name: "Sell", + }, + ], + }, + }, + ], + errors: [ + { + code: 6000, + name: "NoSlotsPassed", + msg: "Can't get a TWAP before some observations have been stored", + }, + { + code: 6001, + name: "NoReserves", + msg: "Can't swap through a pool without token reserves on either side", + }, + { + code: 6002, + name: "InputAmountOverflow", + msg: "Input token amount is too large for a swap, causes overflow", + }, + { + code: 6003, + name: "AddLiquidityCalculationError", + msg: "Add liquidity calculation error", + }, + { + code: 6004, + name: "DecimalScaleError", + msg: "Error in decimal scale conversion", + }, + { + code: 6005, + name: "SameTokenMints", + msg: "You can't create an AMM pool where the token mints are the same", + }, + { + code: 6006, + name: "SwapSlippageExceeded", + msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", + }, + { + code: 6007, + name: "InsufficientBalance", + msg: "The user had insufficient balance to do this", + }, + { + code: 6008, + name: "ZeroLiquidityRemove", + msg: "Must remove a non-zero amount of liquidity", + }, + { + code: 6009, + name: "ZeroLiquidityToAdd", + msg: "Cannot add liquidity with 0 tokens on either side", + }, + { + code: 6010, + name: "ZeroMinLpTokens", + msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", + }, + { + code: 6011, + name: "AddLiquiditySlippageExceeded", + msg: "LP wouldn't have gotten back `lp_token_min`", + }, + { + code: 6012, + name: "AddLiquidityMaxBaseExceeded", + msg: "LP would have spent more than `max_base_amount`", + }, + { + code: 6013, + name: "InsufficientQuoteAmount", + msg: "`quote_amount` must be greater than 100000000 when initializing a pool", + }, + { + code: 6014, + name: "ZeroSwapAmount", + msg: "Users must swap a non-zero amount", + }, + { + code: 6015, + name: "ConstantProductInvariantFailed", + msg: "K should always be increasing", + }, + { + code: 6016, + name: "CastingOverflow", + msg: "Casting has caused an overflow", + }, + ], +}; diff --git a/sdk2/src/amm/v0.3/types/index.ts b/sdk2/src/amm/v0.3/types/index.ts new file mode 100644 index 000000000..66251d5f8 --- /dev/null +++ b/sdk2/src/amm/v0.3/types/index.ts @@ -0,0 +1,6 @@ +import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; +export { AmmProgram, AmmIDL }; + +import type { IdlAccounts } from "@coral-xyz/anchor"; + +export type Amm = IdlAccounts["amm"]; diff --git a/sdk2/src/autocrat/v0.3/AutocratClient.ts b/sdk2/src/autocrat/v0.3/AutocratClient.ts new file mode 100644 index 000000000..ad058f541 --- /dev/null +++ b/sdk2/src/autocrat/v0.3/AutocratClient.ts @@ -0,0 +1,717 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { + AccountMeta, + AddressLookupTableAccount, + ComputeBudgetProgram, + Keypair, + PublicKey, + Transaction, + TransactionInstruction, +} from "@solana/web3.js"; +import { PriceMath } from "../../priceMath.js"; +import { + Autocrat as AutocratIDLType, + IDL as AutocratIDL, +} from "./types/autocrat.js"; +import { + Dao, + InitializeDaoParams, + Proposal, + ProposalInstruction, +} from "./types/index.js"; + +import BN from "bn.js"; +import { + AMM_V0_3_PROGRAM_ID, + AUTOCRAT_V0_3_PROGRAM_ID, + CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + MAINNET_USDC, + USDC_DECIMALS, +} from "../../constants.js"; +import { InstructionUtils } from "../../utils.js"; +import { DEFAULT_CU_PRICE, MaxCUs } from "./cu.js"; +import { getDaoTreasuryAddr, getProposalAddr } from "./pda.js"; +import { getAmmAddr, getAmmLpMintAddr } from "../../amm/v0.3/pda.js"; +import { + getVaultAddr, + getVaultFinalizeMintAddr, + getVaultRevertMintAddr, +} from "../../conditional_vault/v0.3/pda.js"; +import { ConditionalVaultClient } from "../../conditional_vault/v0.3/index.js"; +import { AmmClient } from "../../amm/v0.3/index.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, + unpackMint, +} from "@solana/spl-token"; + +export type CreateClientParams = { + provider: AnchorProvider; + autocratProgramId?: PublicKey; + conditionalVaultProgramId?: PublicKey; + ammProgramId?: PublicKey; +}; + +export type ProposalVaults = { + baseVault: PublicKey; + quoteVault: PublicKey; +}; + +export class AutocratClient { + public readonly provider: AnchorProvider; + public readonly autocrat: Program; + public readonly vaultClient: ConditionalVaultClient; + public readonly ammClient: AmmClient; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + autocratProgramId: PublicKey, + conditionalVaultProgramId: PublicKey, + ammProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.autocrat = new Program( + AutocratIDL, + autocratProgramId, + provider, + ); + this.vaultClient = ConditionalVaultClient.createClient({ + provider, + conditionalVaultProgramId, + }); + this.ammClient = AmmClient.createClient({ provider, ammProgramId }); + this.luts = luts; + } + + public static createClient( + createAutocratClientParams: CreateClientParams, + ): AutocratClient { + let { + provider, + autocratProgramId, + conditionalVaultProgramId, + ammProgramId, + } = createAutocratClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new AutocratClient( + provider, + autocratProgramId || AUTOCRAT_V0_3_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + ammProgramId || AMM_V0_3_PROGRAM_ID, + luts, + ); + } + + async getProposal(proposal: PublicKey): Promise { + return this.autocrat.account.proposal.fetch(proposal); + } + + async getDao(dao: PublicKey): Promise { + return this.autocrat.account.dao.fetch(dao); + } + + getProposalPdas( + proposal: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + dao: PublicKey, + ): { + baseVault: PublicKey; + quoteVault: PublicKey; + passBaseMint: PublicKey; + passQuoteMint: PublicKey; + failBaseMint: PublicKey; + failQuoteMint: PublicKey; + passAmm: PublicKey; + failAmm: PublicKey; + passLp: PublicKey; + failLp: PublicKey; + } { + let vaultProgramId = this.vaultClient.vaultProgram.programId; + const [baseVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + proposal, + baseMint, + ); + const [quoteVault] = getVaultAddr( + this.vaultClient.vaultProgram.programId, + proposal, + quoteMint, + ); + + const [passBaseMint] = getVaultFinalizeMintAddr(vaultProgramId, baseVault); + const [passQuoteMint] = getVaultFinalizeMintAddr( + vaultProgramId, + quoteVault, + ); + + const [failBaseMint] = getVaultRevertMintAddr(vaultProgramId, baseVault); + const [failQuoteMint] = getVaultRevertMintAddr(vaultProgramId, quoteVault); + + const [passAmm] = getAmmAddr( + this.ammClient.program.programId, + passBaseMint, + passQuoteMint, + ); + const [failAmm] = getAmmAddr( + this.ammClient.program.programId, + failBaseMint, + failQuoteMint, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + return { + baseVault, + quoteVault, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + passAmm, + failAmm, + passLp, + failLp, + }; + } + + async initializeDao( + tokenMint: PublicKey, + tokenPriceUiAmount: number, + minBaseFutarchicLiquidity: number, + minQuoteFutarchicLiquidity: number, + usdcMint: PublicKey = MAINNET_USDC, + daoKeypair: Keypair = Keypair.generate(), + ): Promise { + let tokenDecimals = unpackMint( + tokenMint, + await this.provider.connection.getAccountInfo(tokenMint), + ).decimals; + + let scaledPrice = PriceMath.getAmmPrice( + tokenPriceUiAmount, + tokenDecimals, + USDC_DECIMALS, + ); + + await this.initializeDaoIx( + daoKeypair, + tokenMint, + { + twapInitialObservation: scaledPrice, + twapMaxObservationChangePerUpdate: scaledPrice.divn(50), + minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( + new BN(10).pow(new BN(USDC_DECIMALS)), + ), + minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( + new BN(10).pow(new BN(tokenDecimals)), + ), + passThresholdBps: null, + slotsPerProposal: null, + }, + usdcMint, + ) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ + units: MaxCUs.initializeDao, + }), + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: DEFAULT_CU_PRICE, + }), + ]) + .rpc({ maxRetries: 5 }); + + return daoKeypair.publicKey; + } + + initializeDaoIx( + daoKeypair: Keypair, + tokenMint: PublicKey, + params: InitializeDaoParams, + usdcMint: PublicKey = MAINNET_USDC, + payer: PublicKey = this.provider.publicKey, + ) { + return this.autocrat.methods + .initializeDao(params) + .accounts({ + dao: daoKeypair.publicKey, + tokenMint, + usdcMint, + payer, + }) + .signers([daoKeypair]); + } + + async initializeProposal( + dao: PublicKey, + descriptionUrl: string, + instruction: ProposalInstruction, + baseTokensToLP: BN, + quoteTokensToLP: BN, + ): Promise { + const storedDao = await this.getDao(dao); + + const nonce = new BN(Math.random() * 2 ** 50); + + let [proposal] = getProposalAddr( + this.autocrat.programId, + this.provider.publicKey, + nonce, + ); + + const { + baseVault, + quoteVault, + passAmm, + failAmm, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + } = this.getProposalPdas( + proposal, + storedDao.tokenMint, + storedDao.usdcMint, + dao, + ); + + // it's important that these happen in a single atomic transaction + await this.vaultClient + .initializeVaultIx(proposal, storedDao.tokenMint) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), + this.ammClient.createAmmIx( + passBaseMint, + passQuoteMint, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + this.ammClient.createAmmIx( + failBaseMint, + failQuoteMint, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + ), + ) + .rpc(); + + await this.vaultClient + .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.mintConditionalTokensIx( + quoteVault, + storedDao.usdcMint, + quoteTokensToLP, + ), + ), + ) + .rpc(); + + await this.ammClient + .addLiquidityIx( + passAmm, + passBaseMint, + passQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ) + .postInstructions( + await InstructionUtils.getInstructions( + this.ammClient.addLiquidityIx( + failAmm, + failBaseMint, + failQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ), + ), + ) + .rpc(); + + // this is how many original tokens are created + const lpTokens = quoteTokensToLP; + + await this.initializeProposalIx( + descriptionUrl, + instruction, + dao, + storedDao.tokenMint, + storedDao.usdcMint, + lpTokens, + lpTokens, + nonce, + ).rpc(); + + return proposal; + } + + async createProposalTxAndPDAs( + dao: PublicKey, + descriptionUrl: string, + instruction: ProposalInstruction, + baseTokensToLP: BN, + quoteTokensToLP: BN, + ): Promise< + [ + Transaction[], + { + proposalAcct: PublicKey; + baseCondVaultAcct: PublicKey; + quoteCondVaultAcct: PublicKey; + passMarketAcct: PublicKey; + failMarketAcct: PublicKey; + }, + ] + > { + const storedDao = await this.getDao(dao); + + const nonce = new BN(Math.random() * 2 ** 50); + + let [proposal] = getProposalAddr( + this.autocrat.programId, + this.provider.publicKey, + nonce, + ); + + const { + baseVault, + quoteVault, + passAmm, + failAmm, + passBaseMint, + passQuoteMint, + failBaseMint, + failQuoteMint, + } = this.getProposalPdas( + proposal, + storedDao.tokenMint, + storedDao.usdcMint, + dao, + ); + + // it's important that these happen in a single atomic transaction + const initVaultTx = await this.vaultClient + .initializeVaultIx(proposal, storedDao.tokenMint) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), + this.ammClient.createAmmIx( + passBaseMint, + passQuoteMint, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + this.ammClient.createAmmIx( + failBaseMint, + failQuoteMint, + storedDao.twapInitialObservation, + storedDao.twapMaxObservationChangePerUpdate, + ), + ), + ) + .transaction(); + + const mintConditionalTokensTx = await this.vaultClient + .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) + .postInstructions( + await InstructionUtils.getInstructions( + this.vaultClient.mintConditionalTokensIx( + quoteVault, + storedDao.usdcMint, + quoteTokensToLP, + ), + ), + ) + .transaction(); + + const addLiquidityTx = await this.ammClient + .addLiquidityIx( + passAmm, + passBaseMint, + passQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ) + .postInstructions( + await InstructionUtils.getInstructions( + this.ammClient.addLiquidityIx( + failAmm, + failBaseMint, + failQuoteMint, + quoteTokensToLP, + baseTokensToLP, + new BN(0), + ), + ), + ) + .transaction(); + + // this is how many original tokens are created + const lpTokens = quoteTokensToLP; + + const initTx = await this.initializeProposalIx( + descriptionUrl, + instruction, + dao, + storedDao.tokenMint, + storedDao.usdcMint, + lpTokens, + lpTokens, + nonce, + ).transaction(); + + return [ + [initVaultTx, mintConditionalTokensTx, addLiquidityTx, initTx], + { + baseCondVaultAcct: baseVault, + quoteCondVaultAcct: quoteVault, + failMarketAcct: failAmm, + passMarketAcct: passAmm, + proposalAcct: proposal, + }, + ]; + } + + initializeProposalIx( + descriptionUrl: string, + instruction: ProposalInstruction, + dao: PublicKey, + baseMint: PublicKey, + quoteMint: PublicKey, + passLpTokensToLock: BN, + failLpTokensToLock: BN, + nonce: BN, + ) { + let [proposal] = getProposalAddr( + this.autocrat.programId, + this.provider.publicKey, + nonce, + ); + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( + proposal, + baseMint, + quoteMint, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + const passLpVaultAccount = getAssociatedTokenAddressSync( + passLp, + daoTreasury, + true, + ); + const failLpVaultAccount = getAssociatedTokenAddressSync( + failLp, + daoTreasury, + true, + ); + + return this.autocrat.methods + .initializeProposal({ + descriptionUrl, + instruction, + passLpTokensToLock, + failLpTokensToLock, + nonce, + }) + .accounts({ + proposal, + dao, + baseVault, + quoteVault, + passAmm, + failAmm, + passLpMint: passLp, + failLpMint: failLp, + passLpUserAccount: getAssociatedTokenAddressSync( + passLp, + this.provider.publicKey, + ), + failLpUserAccount: getAssociatedTokenAddressSync( + failLp, + this.provider.publicKey, + ), + passLpVaultAccount, + failLpVaultAccount, + proposer: this.provider.publicKey, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + passLpVaultAccount, + daoTreasury, + passLp, + ), + createAssociatedTokenAccountIdempotentInstruction( + this.provider.publicKey, + failLpVaultAccount, + daoTreasury, + failLp, + ), + ]); + } + + async finalizeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + let storedDao = await this.getDao(storedProposal.dao); + + return this.finalizeProposalIx( + proposal, + storedProposal.instruction, + storedProposal.dao, + storedDao.tokenMint, + storedDao.usdcMint, + storedProposal.proposer, + ).rpc(); + } + + finalizeProposalIx( + proposal: PublicKey, + instruction: any, + dao: PublicKey, + daoToken: PublicKey, + usdc: PublicKey, + proposer: PublicKey, + ) { + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( + proposal, + daoToken, + usdc, + dao, + ); + + const [passLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + passAmm, + ); + const [failLp] = getAmmLpMintAddr( + this.ammClient.program.programId, + failAmm, + ); + + return this.autocrat.methods.finalizeProposal().accounts({ + proposal, + passAmm, + failAmm, + dao, + baseVault, + quoteVault, + passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer), + failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer), + passLpVaultAccount: getAssociatedTokenAddressSync( + passLp, + daoTreasury, + true, + ), + failLpVaultAccount: getAssociatedTokenAddressSync( + failLp, + daoTreasury, + true, + ), + vaultProgram: this.vaultClient.vaultProgram.programId, + treasury: daoTreasury, + }); + } + + async executeProposal(proposal: PublicKey) { + let storedProposal = await this.getProposal(proposal); + + return this.executeProposalIx( + proposal, + storedProposal.dao, + storedProposal.instruction, + ).rpc(); + } + + executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { + const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); + return this.autocrat.methods + .executeProposal() + .accounts({ + proposal, + dao, + }) + .remainingAccounts( + instruction.accounts + .concat({ + pubkey: instruction.programId, + isWritable: false, + isSigner: false, + }) + .map((meta: AccountMeta) => + meta.pubkey.equals(daoTreasury) + ? { ...meta, isSigner: false } + : meta, + ), + ); + } + + // cranks the TWAPs of multiple proposals' markets. there's a limit on the + // number of proposals you can pass in, which I can't determine rn because + // there aren't enough proposals on devnet + async crankProposalMarkets( + proposals: PublicKey[], + priorityFeeMicroLamports: number, + ) { + const amms: PublicKey[] = []; + + for (const proposal of proposals) { + const storedProposal = await this.getProposal(proposal); + amms.push(storedProposal.passAmm); + amms.push(storedProposal.failAmm); + } + + while (true) { + let ixs: TransactionInstruction[] = []; + + for (const amm of amms) { + ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); + } + + let tx = new Transaction(); + tx.add( + ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), + ); + tx.add( + ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: priorityFeeMicroLamports, + }), + ); + tx.add(...ixs); + try { + await this.provider.sendAndConfirm(tx); + } catch (err) { + console.log("err", err); + } + + await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds + } + } +} diff --git a/sdk2/src/autocrat/v0.3/cu.ts b/sdk2/src/autocrat/v0.3/cu.ts new file mode 100644 index 000000000..086df7c24 --- /dev/null +++ b/sdk2/src/autocrat/v0.3/cu.ts @@ -0,0 +1,11 @@ +export const MaxCUs = { + initializeDao: 20_000, + createIdempotent: 25_000, + initializeConditionalVault: 45_000, + mintConditionalTokens: 35_000, + initializeAmm: 120_000, + addLiquidity: 120_000, + initializeProposal: 60_000, +}; + +export const DEFAULT_CU_PRICE = 1; diff --git a/sdk2/src/autocrat/v0.3/index.ts b/sdk2/src/autocrat/v0.3/index.ts new file mode 100644 index 000000000..aae73865c --- /dev/null +++ b/sdk2/src/autocrat/v0.3/index.ts @@ -0,0 +1,4 @@ +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./cu.js"; +export * from "./AutocratClient.js"; diff --git a/sdk2/src/autocrat/v0.3/pda.ts b/sdk2/src/autocrat/v0.3/pda.ts new file mode 100644 index 000000000..1b1f01bc7 --- /dev/null +++ b/sdk2/src/autocrat/v0.3/pda.ts @@ -0,0 +1,26 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import BN from "bn.js"; +import { AUTOCRAT_V0_3_PROGRAM_ID } from "../../constants.js"; + +export const getDaoTreasuryAddr = ( + programId: PublicKey = AUTOCRAT_V0_3_PROGRAM_ID, + dao: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); +}; + +export const getProposalAddr = ( + programId: PublicKey = AUTOCRAT_V0_3_PROGRAM_ID, + proposer: PublicKey, + nonce: BN, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("proposal"), + proposer.toBuffer(), + nonce.toArrayLike(Buffer, "le", 8), + ], + programId, + ); +}; diff --git a/sdk2/src/autocrat/v0.3/types/autocrat.ts b/sdk2/src/autocrat/v0.3/types/autocrat.ts new file mode 100644 index 000000000..e39706bc1 --- /dev/null +++ b/sdk2/src/autocrat/v0.3/types/autocrat.ts @@ -0,0 +1,1263 @@ +export type Autocrat = { + version: "0.3.0"; + name: "autocrat"; + instructions: [ + { + name: "initializeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMint"; + isMut: false; + isSigner: false; + }, + { + name: "usdcMint"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeDaoParams"; + }; + }, + ]; + }, + { + name: "initializeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failLpMint"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeProposalParams"; + }; + }, + ]; + }, + { + name: "finalizeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "passAmm"; + isMut: false; + isSigner: false; + }, + { + name: "failAmm"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasury"; + isMut: false; + isSigner: false; + }, + { + name: "passLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpUserAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "failLpVaultAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "executeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "treasury"; + isMut: false; + isSigner: true; + }, + ]; + args: [ + { + name: "daoParams"; + type: { + defined: "UpdateDaoParams"; + }; + }, + ]; + }, + ]; + accounts: [ + { + name: "dao"; + type: { + kind: "struct"; + fields: [ + { + name: "treasuryPdaBump"; + type: "u8"; + }, + { + name: "treasury"; + type: "publicKey"; + }, + { + name: "tokenMint"; + type: "publicKey"; + }, + { + name: "usdcMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "slotsPerProposal"; + type: "u64"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + ]; + }; + }, + { + name: "proposal"; + type: { + kind: "struct"; + fields: [ + { + name: "number"; + type: "u32"; + }, + { + name: "proposer"; + type: "publicKey"; + }, + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "slotEnqueued"; + type: "u64"; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + }, + { + name: "instruction"; + type: { + defined: "ProposalInstruction"; + }; + }, + { + name: "passAmm"; + type: "publicKey"; + }, + { + name: "failAmm"; + type: "publicKey"; + }, + { + name: "baseVault"; + type: "publicKey"; + }, + { + name: "quoteVault"; + type: "publicKey"; + }, + { + name: "dao"; + type: "publicKey"; + }, + { + name: "passLpTokensLocked"; + type: "u64"; + }, + { + name: "failLpTokensLocked"; + type: "u64"; + }, + { + name: "nonce"; + docs: [ + "We need to include a per-proposer nonce to prevent some weird proposal", + "front-running edge cases. Using a `u64` means that proposers are unlikely", + "to run into collisions, even if they generate nonces randomly - I've run", + "the math :D", + ]; + type: "u64"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "InitializeDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "slotsPerProposal"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "InitializeProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "descriptionUrl"; + type: "string"; + }, + { + name: "instruction"; + type: { + defined: "ProposalInstruction"; + }; + }, + { + name: "passLpTokensToLock"; + type: "u64"; + }, + { + name: "failLpTokensToLock"; + type: "u64"; + }, + { + name: "nonce"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "slotsPerProposal"; + type: { + option: "u64"; + }; + }, + { + name: "twapInitialObservation"; + type: { + option: "u128"; + }; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: { + option: "u128"; + }; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "minBaseFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "ProposalAccount"; + type: { + kind: "struct"; + fields: [ + { + name: "pubkey"; + type: "publicKey"; + }, + { + name: "isSigner"; + type: "bool"; + }, + { + name: "isWritable"; + type: "bool"; + }, + ]; + }; + }, + { + name: "ProposalInstruction"; + type: { + kind: "struct"; + fields: [ + { + name: "programId"; + type: "publicKey"; + }, + { + name: "accounts"; + type: { + vec: { + defined: "ProposalAccount"; + }; + }; + }, + { + name: "data"; + type: "bytes"; + }, + ]; + }; + }, + { + name: "ProposalState"; + type: { + kind: "enum"; + variants: [ + { + name: "Pending"; + }, + { + name: "Passed"; + }, + { + name: "Failed"; + }, + { + name: "Executed"; + }, + ]; + }; + }, + ]; + errors: [ + { + code: 6000; + name: "AmmTooOld"; + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; + }, + { + code: 6001; + name: "InvalidInitialObservation"; + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; + }, + { + code: 6002; + name: "InvalidMaxObservationChange"; + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; + }, + { + code: 6003; + name: "InvalidSettlementAuthority"; + msg: "One of the vaults has an invalid `settlement_authority`"; + }, + { + code: 6004; + name: "ProposalTooYoung"; + msg: "Proposal is too young to be executed or rejected"; + }, + { + code: 6005; + name: "MarketsTooYoung"; + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; + }, + { + code: 6006; + name: "ProposalAlreadyFinalized"; + msg: "This proposal has already been finalized"; + }, + { + code: 6007; + name: "InvalidVaultNonce"; + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; + }, + { + code: 6008; + name: "ProposalNotPassed"; + msg: "This proposal can't be executed because it isn't in the passed state"; + }, + { + code: 6009; + name: "InsufficientLpTokenBalance"; + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; + }, + { + code: 6010; + name: "InsufficientLpTokenLock"; + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; + }, + ]; +}; + +export const IDL: Autocrat = { + version: "0.3.0", + name: "autocrat", + instructions: [ + { + name: "initializeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMint", + isMut: false, + isSigner: false, + }, + { + name: "usdcMint", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeDaoParams", + }, + }, + ], + }, + { + name: "initializeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failLpMint", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeProposalParams", + }, + }, + ], + }, + { + name: "finalizeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "passAmm", + isMut: false, + isSigner: false, + }, + { + name: "failAmm", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "treasury", + isMut: false, + isSigner: false, + }, + { + name: "passLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpUserAccount", + isMut: true, + isSigner: false, + }, + { + name: "passLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "failLpVaultAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "executeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "treasury", + isMut: false, + isSigner: true, + }, + ], + args: [ + { + name: "daoParams", + type: { + defined: "UpdateDaoParams", + }, + }, + ], + }, + ], + accounts: [ + { + name: "dao", + type: { + kind: "struct", + fields: [ + { + name: "treasuryPdaBump", + type: "u8", + }, + { + name: "treasury", + type: "publicKey", + }, + { + name: "tokenMint", + type: "publicKey", + }, + { + name: "usdcMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "slotsPerProposal", + type: "u64", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + ], + }, + }, + { + name: "proposal", + type: { + kind: "struct", + fields: [ + { + name: "number", + type: "u32", + }, + { + name: "proposer", + type: "publicKey", + }, + { + name: "descriptionUrl", + type: "string", + }, + { + name: "slotEnqueued", + type: "u64", + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + }, + { + name: "instruction", + type: { + defined: "ProposalInstruction", + }, + }, + { + name: "passAmm", + type: "publicKey", + }, + { + name: "failAmm", + type: "publicKey", + }, + { + name: "baseVault", + type: "publicKey", + }, + { + name: "quoteVault", + type: "publicKey", + }, + { + name: "dao", + type: "publicKey", + }, + { + name: "passLpTokensLocked", + type: "u64", + }, + { + name: "failLpTokensLocked", + type: "u64", + }, + { + name: "nonce", + docs: [ + "We need to include a per-proposer nonce to prevent some weird proposal", + "front-running edge cases. Using a `u64` means that proposers are unlikely", + "to run into collisions, even if they generate nonces randomly - I've run", + "the math :D", + ], + type: "u64", + }, + { + name: "pdaBump", + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "InitializeDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "slotsPerProposal", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "InitializeProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "descriptionUrl", + type: "string", + }, + { + name: "instruction", + type: { + defined: "ProposalInstruction", + }, + }, + { + name: "passLpTokensToLock", + type: "u64", + }, + { + name: "failLpTokensToLock", + type: "u64", + }, + { + name: "nonce", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "slotsPerProposal", + type: { + option: "u64", + }, + }, + { + name: "twapInitialObservation", + type: { + option: "u128", + }, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: { + option: "u128", + }, + }, + { + name: "minQuoteFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "minBaseFutarchicLiquidity", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "ProposalAccount", + type: { + kind: "struct", + fields: [ + { + name: "pubkey", + type: "publicKey", + }, + { + name: "isSigner", + type: "bool", + }, + { + name: "isWritable", + type: "bool", + }, + ], + }, + }, + { + name: "ProposalInstruction", + type: { + kind: "struct", + fields: [ + { + name: "programId", + type: "publicKey", + }, + { + name: "accounts", + type: { + vec: { + defined: "ProposalAccount", + }, + }, + }, + { + name: "data", + type: "bytes", + }, + ], + }, + }, + { + name: "ProposalState", + type: { + kind: "enum", + variants: [ + { + name: "Pending", + }, + { + name: "Passed", + }, + { + name: "Failed", + }, + { + name: "Executed", + }, + ], + }, + }, + ], + errors: [ + { + code: 6000, + name: "AmmTooOld", + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", + }, + { + code: 6001, + name: "InvalidInitialObservation", + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", + }, + { + code: 6002, + name: "InvalidMaxObservationChange", + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", + }, + { + code: 6003, + name: "InvalidSettlementAuthority", + msg: "One of the vaults has an invalid `settlement_authority`", + }, + { + code: 6004, + name: "ProposalTooYoung", + msg: "Proposal is too young to be executed or rejected", + }, + { + code: 6005, + name: "MarketsTooYoung", + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", + }, + { + code: 6006, + name: "ProposalAlreadyFinalized", + msg: "This proposal has already been finalized", + }, + { + code: 6007, + name: "InvalidVaultNonce", + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", + }, + { + code: 6008, + name: "ProposalNotPassed", + msg: "This proposal can't be executed because it isn't in the passed state", + }, + { + code: 6009, + name: "InsufficientLpTokenBalance", + msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", + }, + { + code: 6010, + name: "InsufficientLpTokenLock", + msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", + }, + ], +}; diff --git a/sdk2/src/autocrat/v0.3/types/index.ts b/sdk2/src/autocrat/v0.3/types/index.ts new file mode 100644 index 000000000..57d628b56 --- /dev/null +++ b/sdk2/src/autocrat/v0.3/types/index.ts @@ -0,0 +1,13 @@ +import { Autocrat as AutocratProgram, IDL as AutocratIDL } from "./autocrat.js"; +export { AutocratProgram, AutocratIDL }; + +import type { IdlAccounts, IdlTypes } from "@coral-xyz/anchor"; + +export type InitializeDaoParams = + IdlTypes["InitializeDaoParams"]; +export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; +export type ProposalInstruction = + IdlTypes["ProposalInstruction"]; + +export type Dao = IdlAccounts["dao"]; +export type Proposal = IdlAccounts["proposal"]; diff --git a/sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts b/sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts new file mode 100644 index 000000000..c87043c75 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts @@ -0,0 +1,341 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { AddressLookupTableAccount, Keypair, PublicKey } from "@solana/web3.js"; + +import { + ConditionalVault as ConditionalVaultIDLType, + IDL as ConditionalVaultIDL, +} from "./types/conditional_vault.js"; + +import BN from "bn.js"; +import { + CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + MPL_TOKEN_METADATA_PROGRAM_ID, +} from "../../constants.js"; +import { getMetadataAddr } from "../../pda.js"; +import { + getVaultAddr, + getVaultFinalizeMintAddr, + getVaultRevertMintAddr, +} from "./pda.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; + +export type CreateVaultClientParams = { + provider: AnchorProvider; + conditionalVaultProgramId?: PublicKey; +}; + +export class ConditionalVaultClient { + public readonly provider: AnchorProvider; + public readonly vaultProgram: Program; + public readonly luts: AddressLookupTableAccount[]; + + constructor( + provider: AnchorProvider, + conditionalVaultProgramId: PublicKey, + luts: AddressLookupTableAccount[], + ) { + this.provider = provider; + this.vaultProgram = new Program( + ConditionalVaultIDL, + conditionalVaultProgramId, + provider, + ); + this.luts = luts; + } + + public static createClient( + createVaultClientParams: CreateVaultClientParams, + ): ConditionalVaultClient { + let { provider, conditionalVaultProgramId } = createVaultClientParams; + + const luts: AddressLookupTableAccount[] = []; + + return new ConditionalVaultClient( + provider, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + luts, + ); + } + + async getVault(vault: PublicKey) { + return this.vaultProgram.account.conditionalVault.fetch(vault); + } + + async mintConditionalTokens( + vault: PublicKey, + uiAmount: number, + user: PublicKey = this.provider.publicKey, + ) { + const storedVault = await this.getVault(vault); + + return this.mintConditionalTokensIx( + vault, + storedVault.underlyingTokenMint, + new BN(uiAmount).mul(new BN(10).pow(new BN(storedVault.decimals))), + user, + ).rpc(); + } + + mintConditionalTokensIx( + vault: PublicKey, + underlyingTokenMint: PublicKey, + amount: BN, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( + this.vaultProgram.programId, + vault, + ); + const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( + this.vaultProgram.programId, + vault, + ); + + let userConditionalOnFinalizeTokenAccount = getAssociatedTokenAddressSync( + conditionalOnFinalizeTokenMint, + user, + ); + + let userConditionalOnRevertTokenAccount = getAssociatedTokenAddressSync( + conditionalOnRevertTokenMint, + user, + ); + + let ix = this.vaultProgram.methods + .mintConditionalTokens(amount) + .accounts({ + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + conditionalOnFinalizeTokenMint, + userConditionalOnFinalizeTokenAccount, + conditionalOnRevertTokenMint, + userConditionalOnRevertTokenAccount, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + userConditionalOnFinalizeTokenAccount, + user, + conditionalOnFinalizeTokenMint, + ), + createAssociatedTokenAccountIdempotentInstruction( + payer, + userConditionalOnRevertTokenAccount, + user, + conditionalOnRevertTokenMint, + ), + ]); + + return ix; + } + + initializeVaultIx( + settlementAuthority: PublicKey, + underlyingTokenMint: PublicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const [vault] = getVaultAddr( + this.vaultProgram.programId, + settlementAuthority, + underlyingTokenMint, + ); + + const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( + this.vaultProgram.programId, + vault, + ); + const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( + this.vaultProgram.programId, + vault, + ); + + const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ); + + return this.vaultProgram.methods + .initializeConditionalVault({ settlementAuthority }) + .accounts({ + vault, + underlyingTokenMint, + vaultUnderlyingTokenAccount, + conditionalOnFinalizeTokenMint, + conditionalOnRevertTokenMint, + }) + .preInstructions([ + createAssociatedTokenAccountIdempotentInstruction( + payer, + vaultUnderlyingTokenAccount, + vault, + underlyingTokenMint, + ), + ]); + } + + addMetadataToConditionalTokensIx( + vault: PublicKey, + underlyingTokenMint: PublicKey, + proposalNumber: number, + onFinalizeUri: string, + onRevertUri: string, + payer: PublicKey = this.provider.publicKey, + ) { + const [underlyingTokenMetadata] = getMetadataAddr(underlyingTokenMint); + + const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( + this.vaultProgram.programId, + vault, + ); + const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( + this.vaultProgram.programId, + vault, + ); + + const [conditionalOnFinalizeTokenMetadata] = getMetadataAddr( + conditionalOnFinalizeTokenMint, + ); + + const [conditionalOnRevertTokenMetadata] = getMetadataAddr( + conditionalOnRevertTokenMint, + ); + + return this.vaultProgram.methods + .addMetadataToConditionalTokens({ + proposalNumber: new BN(proposalNumber), + onFinalizeUri, + onRevertUri, + }) + .accounts({ + payer, + vault, + underlyingTokenMint, + underlyingTokenMetadata, + conditionalOnFinalizeTokenMint, + conditionalOnRevertTokenMint, + conditionalOnFinalizeTokenMetadata, + conditionalOnRevertTokenMetadata, + tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, + }); + } + + redeemConditionalTokensIx( + vault: PublicKey, + underlyingTokenMint: PublicKey, + user: PublicKey = this.provider.publicKey, + ) { + const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( + this.vaultProgram.programId, + vault, + ); + const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( + this.vaultProgram.programId, + vault, + ); + + return this.vaultProgram.methods + .redeemConditionalTokensForUnderlyingTokens() + .accounts({ + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + conditionalOnFinalizeTokenMint, + userConditionalOnFinalizeTokenAccount: getAssociatedTokenAddressSync( + conditionalOnFinalizeTokenMint, + user, + ), + conditionalOnRevertTokenMint, + userConditionalOnRevertTokenAccount: getAssociatedTokenAddressSync( + conditionalOnRevertTokenMint, + user, + ), + }); + } + + mergeConditionalTokensIx( + vault: PublicKey, + underlyingTokenMint: PublicKey, + amount: BN, + user: PublicKey = this.provider.publicKey, + ) { + const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( + this.vaultProgram.programId, + vault, + ); + const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( + this.vaultProgram.programId, + vault, + ); + + return this.vaultProgram.methods + .mergeConditionalTokensForUnderlyingTokens(amount) + .accounts({ + authority: user, + vault, + vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + vault, + true, + ), + userUnderlyingTokenAccount: getAssociatedTokenAddressSync( + underlyingTokenMint, + user, + true, + ), + conditionalOnFinalizeTokenMint, + userConditionalOnFinalizeTokenAccount: getAssociatedTokenAddressSync( + conditionalOnFinalizeTokenMint, + user, + ), + conditionalOnRevertTokenMint, + userConditionalOnRevertTokenAccount: getAssociatedTokenAddressSync( + conditionalOnRevertTokenMint, + user, + ), + }); + } + + async initializeVault( + settlementAuthority: PublicKey, + underlyingTokenMint: PublicKey, + payer: PublicKey = this.provider.publicKey, + ): Promise { + const [vault] = getVaultAddr( + this.vaultProgram.programId, + settlementAuthority, + underlyingTokenMint, + ); + + await this.initializeVaultIx( + settlementAuthority, + underlyingTokenMint, + payer, + ).rpc(); + + return vault; + } +} diff --git a/sdk2/src/conditional_vault/v0.3/index.ts b/sdk2/src/conditional_vault/v0.3/index.ts new file mode 100644 index 000000000..1aa6810cf --- /dev/null +++ b/sdk2/src/conditional_vault/v0.3/index.ts @@ -0,0 +1,8 @@ +// Note: v0.3's vault PDA is derived from a (settlementAuthority, mint) pair and +// has binary pass/fail mints (`getVaultFinalizeMintAddr`/`getVaultRevertMintAddr`). +// v0.4+ replaced this with a multi-outcome `Question` model where the vault is +// derived from (question, mint) and conditional tokens are addressed by index. +// The two are not interchangeable. +export * from "./types/index.js"; +export * from "./pda.js"; +export * from "./ConditionalVaultClient.js"; diff --git a/sdk2/src/conditional_vault/v0.3/pda.ts b/sdk2/src/conditional_vault/v0.3/pda.ts new file mode 100644 index 000000000..e93bec9af --- /dev/null +++ b/sdk2/src/conditional_vault/v0.3/pda.ts @@ -0,0 +1,43 @@ +import { PublicKey } from "@solana/web3.js"; +import { utils } from "@coral-xyz/anchor"; +import { CONDITIONAL_VAULT_V0_3_PROGRAM_ID } from "../../constants.js"; + +export const getVaultAddr = ( + programId: PublicKey = CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + settlementAuthority: PublicKey, + underlyingTokenMint: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + utils.bytes.utf8.encode("conditional_vault"), + settlementAuthority.toBuffer(), + underlyingTokenMint.toBuffer(), + ], + programId, + ); +}; + +export const getVaultFinalizeMintAddr = ( + programId: PublicKey = CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + vault: PublicKey, +): [PublicKey, number] => { + return getVaultMintAddr(programId, vault, "conditional_on_finalize_mint"); +}; + +export const getVaultRevertMintAddr = ( + programId: PublicKey = CONDITIONAL_VAULT_V0_3_PROGRAM_ID, + vault: PublicKey, +): [PublicKey, number] => { + return getVaultMintAddr(programId, vault, "conditional_on_revert_mint"); +}; + +const getVaultMintAddr = ( + programId: PublicKey, + vault: PublicKey, + seed: string, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [utils.bytes.utf8.encode(seed), vault.toBuffer()], + programId, + ); +}; diff --git a/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts b/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts new file mode 100644 index 000000000..4f7d69b99 --- /dev/null +++ b/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts @@ -0,0 +1,895 @@ +export type ConditionalVault = { + version: "0.3.0"; + name: "conditional_vault"; + instructions: [ + { + name: "initializeConditionalVault"; + accounts: [ + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "underlyingTokenMint"; + isMut: false; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: false; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeConditionalVaultArgs"; + }; + }, + ]; + }, + { + name: "addMetadataToConditionalTokens"; + accounts: [ + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + { + name: "underlyingTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "underlyingTokenMetadata"; + isMut: false; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "AddMetadataToConditionalTokensArgs"; + }; + }, + ]; + }, + { + name: "settleConditionalVault"; + accounts: [ + { + name: "settlementAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "vault"; + isMut: true; + isSigner: false; + }, + ]; + args: [ + { + name: "newStatus"; + type: { + defined: "VaultStatus"; + }; + }, + ]; + }, + { + name: "mergeConditionalTokensForUnderlyingTokens"; + accounts: [ + { + name: "vault"; + isMut: false; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userConditionalOnFinalizeTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userConditionalOnRevertTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "mintConditionalTokens"; + accounts: [ + { + name: "vault"; + isMut: false; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userConditionalOnFinalizeTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userConditionalOnRevertTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "redeemConditionalTokensForUnderlyingTokens"; + accounts: [ + { + name: "vault"; + isMut: false; + isSigner: false; + }, + { + name: "conditionalOnFinalizeTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalOnRevertTokenMint"; + isMut: true; + isSigner: false; + }, + { + name: "vaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "authority"; + isMut: false; + isSigner: true; + }, + { + name: "userConditionalOnFinalizeTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userConditionalOnRevertTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "conditionalVault"; + type: { + kind: "struct"; + fields: [ + { + name: "status"; + type: { + defined: "VaultStatus"; + }; + }, + { + name: "settlementAuthority"; + docs: [ + "The account that can either finalize the vault to make conditional tokens", + "redeemable for underlying tokens or revert the vault to make deposit", + "slips redeemable for underlying tokens.", + ]; + type: "publicKey"; + }, + { + name: "underlyingTokenMint"; + docs: ["The mint of the tokens that are deposited into the vault."]; + type: "publicKey"; + }, + { + name: "underlyingTokenAccount"; + docs: ["The vault's storage account for deposited funds."]; + type: "publicKey"; + }, + { + name: "conditionalOnFinalizeTokenMint"; + type: "publicKey"; + }, + { + name: "conditionalOnRevertTokenMint"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "decimals"; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "AddMetadataToConditionalTokensArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "proposalNumber"; + type: "u64"; + }, + { + name: "onFinalizeUri"; + type: "string"; + }, + { + name: "onRevertUri"; + type: "string"; + }, + ]; + }; + }, + { + name: "InitializeConditionalVaultArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "settlementAuthority"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "VaultStatus"; + type: { + kind: "enum"; + variants: [ + { + name: "Active"; + }, + { + name: "Finalized"; + }, + { + name: "Reverted"; + }, + ]; + }; + }, + ]; + errors: [ + { + code: 6000; + name: "InsufficientUnderlyingTokens"; + msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; + }, + { + code: 6001; + name: "InvalidVaultUnderlyingTokenAccount"; + msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; + }, + { + code: 6002; + name: "InvalidConditionalTokenMint"; + msg: "This conditional token mint is not this vault's conditional token mint"; + }, + { + code: 6003; + name: "CantRedeemConditionalTokens"; + msg: "Vault needs to be settled as finalized before users can redeem conditional tokens for underlying tokens"; + }, + { + code: 6004; + name: "VaultAlreadySettled"; + msg: "Once a vault has been settled, its status as either finalized or reverted cannot be changed"; + }, + ]; +}; + +export const IDL: ConditionalVault = { + version: "0.3.0", + name: "conditional_vault", + instructions: [ + { + name: "initializeConditionalVault", + accounts: [ + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "underlyingTokenMint", + isMut: false, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: false, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeConditionalVaultArgs", + }, + }, + ], + }, + { + name: "addMetadataToConditionalTokens", + accounts: [ + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + { + name: "underlyingTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "underlyingTokenMetadata", + isMut: false, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "AddMetadataToConditionalTokensArgs", + }, + }, + ], + }, + { + name: "settleConditionalVault", + accounts: [ + { + name: "settlementAuthority", + isMut: false, + isSigner: true, + }, + { + name: "vault", + isMut: true, + isSigner: false, + }, + ], + args: [ + { + name: "newStatus", + type: { + defined: "VaultStatus", + }, + }, + ], + }, + { + name: "mergeConditionalTokensForUnderlyingTokens", + accounts: [ + { + name: "vault", + isMut: false, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userConditionalOnFinalizeTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userConditionalOnRevertTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "mintConditionalTokens", + accounts: [ + { + name: "vault", + isMut: false, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userConditionalOnFinalizeTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userConditionalOnRevertTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "redeemConditionalTokensForUnderlyingTokens", + accounts: [ + { + name: "vault", + isMut: false, + isSigner: false, + }, + { + name: "conditionalOnFinalizeTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalOnRevertTokenMint", + isMut: true, + isSigner: false, + }, + { + name: "vaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "authority", + isMut: false, + isSigner: true, + }, + { + name: "userConditionalOnFinalizeTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userConditionalOnRevertTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "userUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "conditionalVault", + type: { + kind: "struct", + fields: [ + { + name: "status", + type: { + defined: "VaultStatus", + }, + }, + { + name: "settlementAuthority", + docs: [ + "The account that can either finalize the vault to make conditional tokens", + "redeemable for underlying tokens or revert the vault to make deposit", + "slips redeemable for underlying tokens.", + ], + type: "publicKey", + }, + { + name: "underlyingTokenMint", + docs: ["The mint of the tokens that are deposited into the vault."], + type: "publicKey", + }, + { + name: "underlyingTokenAccount", + docs: ["The vault's storage account for deposited funds."], + type: "publicKey", + }, + { + name: "conditionalOnFinalizeTokenMint", + type: "publicKey", + }, + { + name: "conditionalOnRevertTokenMint", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "decimals", + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "AddMetadataToConditionalTokensArgs", + type: { + kind: "struct", + fields: [ + { + name: "proposalNumber", + type: "u64", + }, + { + name: "onFinalizeUri", + type: "string", + }, + { + name: "onRevertUri", + type: "string", + }, + ], + }, + }, + { + name: "InitializeConditionalVaultArgs", + type: { + kind: "struct", + fields: [ + { + name: "settlementAuthority", + type: "publicKey", + }, + ], + }, + }, + { + name: "VaultStatus", + type: { + kind: "enum", + variants: [ + { + name: "Active", + }, + { + name: "Finalized", + }, + { + name: "Reverted", + }, + ], + }, + }, + ], + errors: [ + { + code: 6000, + name: "InsufficientUnderlyingTokens", + msg: "Insufficient underlying token balance to mint this amount of conditional tokens", + }, + { + code: 6001, + name: "InvalidVaultUnderlyingTokenAccount", + msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", + }, + { + code: 6002, + name: "InvalidConditionalTokenMint", + msg: "This conditional token mint is not this vault's conditional token mint", + }, + { + code: 6003, + name: "CantRedeemConditionalTokens", + msg: "Vault needs to be settled as finalized before users can redeem conditional tokens for underlying tokens", + }, + { + code: 6004, + name: "VaultAlreadySettled", + msg: "Once a vault has been settled, its status as either finalized or reverted cannot be changed", + }, + ], +}; diff --git a/sdk2/src/conditional_vault/v0.3/types/index.ts b/sdk2/src/conditional_vault/v0.3/types/index.ts new file mode 100644 index 000000000..17d3471ab --- /dev/null +++ b/sdk2/src/conditional_vault/v0.3/types/index.ts @@ -0,0 +1,10 @@ +import { + ConditionalVault as ConditionalVaultProgram, + IDL as ConditionalVaultIDL, +} from "./conditional_vault.js"; +export { ConditionalVaultProgram, ConditionalVaultIDL }; + +import type { IdlAccounts } from "@coral-xyz/anchor"; + +export type ConditionalVault = + IdlAccounts["conditionalVault"]; diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index 9aebc0669..3de3f7b6d 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -2,6 +2,16 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; import { BN } from "bn.js"; +export const AUTOCRAT_V0_3_PROGRAM_ID = new PublicKey( + "autoQP9RmUNkzzKRXsMkWicDVZ3h29vvyMDcAYjCxxg", +); +export const AMM_V0_3_PROGRAM_ID = new PublicKey( + "AMM5G2nxuKUwCLRYTW7qqEwuoqCtNSjtbipwEmm2g8bH", +); +export const CONDITIONAL_VAULT_V0_3_PROGRAM_ID = new PublicKey( + "VAU1T7S5UuEHmMvXtXMVmpEoQtZ2ya7eRb7gcN47wDp", +); + export const AUTOCRAT_V0_4_PROGRAM_ID = new PublicKey( "autowMzCbM29YXMgVG3T62Hkgo7RcyrvgQQkd54fDQL", ); From 02014af49b83b201cbe80feeb8abe3809b42af1b Mon Sep 17 00:00:00 2001 From: Pileks Date: Sat, 25 Apr 2026 01:38:41 +0200 Subject: [PATCH 091/100] update scripts --- scripts/setupFutarchyAmm.ts | 2 + scripts/v0.3/crankTwap.ts | 3 +- scripts/v0.3/finalizeProposal.ts | 2 +- scripts/v0.3/initializeDao.ts | 2 +- scripts/v0.3/initializeProposal.ts | 2 +- scripts/v0.3/initializeVault.ts | 2 +- scripts/v0.3/main.ts | 2 + scripts/v0.3/uploadMetadata.ts | 6 +- scripts/v0.4/claimAllLaunch.ts | 3 +- scripts/v0.4/finalizeLaunch.ts | 2 +- scripts/v0.4/initializeDao.ts | 2 +- scripts/v0.4/initializeLaunch.ts | 2 +- scripts/v0.4/initializeMetricMarket.ts | 10 +- scripts/v0.4/initializeProposal.ts | 8 +- scripts/v0.4/startLaunch.ts | 2 +- scripts/v0.4/uploadMetadata.ts | 6 +- scripts/v0.5/assignPermissionlessAccount.ts | 6 +- scripts/v0.5/claimAllLaunch.ts | 3 +- scripts/v0.5/executeProposal.ts | 10 +- scripts/v0.5/finalizeLaunch.ts | 4 +- scripts/v0.5/initializeDao.ts | 8 +- scripts/v0.5/initializeLaunch.ts | 2 +- scripts/v0.5/initializeProposal.ts | 12 +- scripts/v0.5/migrateMeta.ts | 8 +- scripts/v0.5/recoverProposalFunds.ts | 10 +- scripts/v0.5/squads/executeProposal.ts | 2 +- .../v0.5/squads/initalizeTransferProposal.ts | 6 +- scripts/v0.5/squads/removeSpendingLimit.ts | 4 +- scripts/v0.5/squads/updateSpendingLimit.ts | 6 +- scripts/v0.5/squads/useSpendingLimit.ts | 4 +- scripts/v0.5/startLaunch.ts | 2 +- scripts/v0.6/burnPerformancePackage.ts | 6 +- scripts/v0.6/claimAllLaunch.ts | 2 +- scripts/v0.6/collectMeteoraDammFees.ts | 14 +-- scripts/v0.6/createDao.ts | 4 +- scripts/v0.6/dumpDaos.ts | 2 +- scripts/v0.6/dumpDaosProposals.ts | 15 +-- scripts/v0.6/executeGeneralProposal.ts | 6 +- scripts/v0.6/executeProposal.ts | 4 +- scripts/v0.6/finalizeLaunch.ts | 5 +- scripts/v0.6/finalizeProposal.ts | 2 +- scripts/v0.6/initializeDao.ts | 9 +- scripts/v0.6/launch.ts | 3 +- scripts/v0.6/launchLoyal.ts | 3 +- scripts/v0.6/launchPaystream.ts | 3 +- scripts/v0.6/launchSOLO.ts | 3 +- scripts/v0.6/launchZKLSOL.ts | 3 +- scripts/v0.6/migrateDaos.ts | 2 +- scripts/v0.6/provideLiquidity.ts | 7 +- scripts/v0.6/returnFunds.ts | 11 +- scripts/v0.7/burnPerformancePackage.ts | 2 +- scripts/v0.7/claimAllLaunch.ts | 2 +- scripts/v0.7/claimLaunchAdditionalTokens.ts | 2 +- scripts/v0.7/closeLaunch.ts | 2 +- scripts/v0.7/collectAllFees.ts | 24 ++-- scripts/v0.7/collectFees.ts | 32 ++--- scripts/v0.7/collectLpFees.ts | 110 ------------------ scripts/v0.7/collectMeteoraDammFees.ts | 17 +-- scripts/v0.7/completeLaunch.ts | 2 +- scripts/v0.7/dumpDaos.ts | 2 +- scripts/v0.7/dumpLaunches.ts | 2 +- scripts/v0.7/dumpLaunchesAndFundingRecords.ts | 2 +- scripts/v0.7/extendLaunch.ts | 6 +- scripts/v0.7/hurupay/setupLaunch.ts | 3 +- scripts/v0.7/initializePerformancePackage.ts | 2 +- scripts/v0.7/launchP2P.ts | 3 +- scripts/v0.7/launchRNGR.ts | 3 +- scripts/v0.7/launchTemplate.ts | 3 +- .../approveWithPointsWeightedPhase.ts | 2 +- scripts/v0.7/removeProposal.ts | 14 +-- scripts/v0.7/resizeDaos.ts | 2 +- scripts/v0.7/resizeLaunches.ts | 2 +- .../v0.7/resizeLaunchesAndFundingRecords.ts | 2 +- scripts/v0.7/startLaunch.ts | 2 +- sdk2/src/amm/v0.5/AmmClient.ts | 4 +- sdk2/src/amm/v0.5/pda.ts | 6 +- sdk2/src/autocrat/v0.4/AutocratClient.ts | 4 +- sdk2/src/autocrat/v0.5/AutocratClient.ts | 8 +- .../v0.4/ConditionalVaultClient.ts | 4 +- sdk2/src/constants.ts | 10 +- sdk2/src/futarchy/v0.6/FutarchyClient.ts | 4 +- .../v0.5/SharedLiquidityManagerClient.ts | 4 +- tests/conditionalVault/unit.ts | 4 +- .../futarchy/unit/adminCancelProposal.test.ts | 10 +- tsconfig.json | 1 + 85 files changed, 209 insertions(+), 340 deletions(-) delete mode 100644 scripts/v0.7/collectLpFees.ts diff --git a/scripts/setupFutarchyAmm.ts b/scripts/setupFutarchyAmm.ts index 0554c455c..8802ad284 100644 --- a/scripts/setupFutarchyAmm.ts +++ b/scripts/setupFutarchyAmm.ts @@ -1,3 +1,5 @@ +// @ts-nocheck +// Legacy script import * as anchor from "@coral-xyz/anchor"; import { AutocratClient, getDaoAddr } from "@metadaoproject/futarchy/v0.6"; import { Keypair, PublicKey } from "@solana/web3.js"; diff --git a/scripts/v0.3/crankTwap.ts b/scripts/v0.3/crankTwap.ts index 229dcbefb..fdea3242d 100644 --- a/scripts/v0.3/crankTwap.ts +++ b/scripts/v0.3/crankTwap.ts @@ -1,5 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { AmmClient, AutocratClient } from "@metadaoproject/futarchy/v0.3"; +import { AmmClient } from "@metadaoproject/futarchy/amm/v0.3"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; import { PublicKey } from "@solana/web3.js"; const proposal1 = new PublicKey("Dssb1oTTqKjWJTe8QVrStFXxcMZfd7LTSpTRbuHuNdnW"); diff --git a/scripts/v0.3/finalizeProposal.ts b/scripts/v0.3/finalizeProposal.ts index 828d89d8b..ac917b6da 100644 --- a/scripts/v0.3/finalizeProposal.ts +++ b/scripts/v0.3/finalizeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient } from "@metadaoproject/futarchy/v0.3"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; const { PublicKey } = anchor.web3; diff --git a/scripts/v0.3/initializeDao.ts b/scripts/v0.3/initializeDao.ts index d5711ea8c..1ffb0162c 100644 --- a/scripts/v0.3/initializeDao.ts +++ b/scripts/v0.3/initializeDao.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient } from "@metadaoproject/futarchy/v0.3"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; import { DEAN_DEVNET, DEVNET_DARK, diff --git a/scripts/v0.3/initializeProposal.ts b/scripts/v0.3/initializeProposal.ts index c67606205..d68c3bf51 100644 --- a/scripts/v0.3/initializeProposal.ts +++ b/scripts/v0.3/initializeProposal.ts @@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import * as token from "@solana/spl-token"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; -import { AutocratClient } from "@metadaoproject/futarchy/v0.3"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; const { PublicKey } = anchor.web3; diff --git a/scripts/v0.3/initializeVault.ts b/scripts/v0.3/initializeVault.ts index 8a6ea4ff2..69557396b 100644 --- a/scripts/v0.3/initializeVault.ts +++ b/scripts/v0.3/initializeVault.ts @@ -8,7 +8,7 @@ import { getVaultAddr, getVaultFinalizeMintAddr, getVaultRevertMintAddr, -} from "@metadaoproject/futarchy/v0.3"; +} from "@metadaoproject/futarchy/conditional_vault/v0.3"; const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( "4nCk4qKJSJf8pzJadMnr9LubA6Y7Zw3EacsVqH1TwVXH", diff --git a/scripts/v0.3/main.ts b/scripts/v0.3/main.ts index 04436a530..ecc80852f 100644 --- a/scripts/v0.3/main.ts +++ b/scripts/v0.3/main.ts @@ -1,3 +1,5 @@ +// @ts-nocheck +// Legacy script import * as anchor from "@coral-xyz/anchor"; import * as token from "@solana/spl-token"; const { BN, Program } = anchor; diff --git a/scripts/v0.3/uploadMetadata.ts b/scripts/v0.3/uploadMetadata.ts index c96703255..bc56ef2c0 100644 --- a/scripts/v0.3/uploadMetadata.ts +++ b/scripts/v0.3/uploadMetadata.ts @@ -1,9 +1,7 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { - AutocratClient, - ConditionalVaultClient, -} from "@metadaoproject/futarchy/v0.3"; +import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.3"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.4/claimAllLaunch.ts b/scripts/v0.4/claimAllLaunch.ts index 71e93b104..de933927c 100644 --- a/scripts/v0.4/claimAllLaunch.ts +++ b/scripts/v0.4/claimAllLaunch.ts @@ -5,7 +5,8 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient, LaunchpadClient } from "@metadaoproject/futarchy/v0.4"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; import { homedir } from "os"; import { join } from "path"; import { input } from "@inquirer/prompts"; diff --git a/scripts/v0.4/finalizeLaunch.ts b/scripts/v0.4/finalizeLaunch.ts index c136683b3..1c99262f7 100644 --- a/scripts/v0.4/finalizeLaunch.ts +++ b/scripts/v0.4/finalizeLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.4"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; import { homedir } from "os"; import { join } from "path"; import { input } from "@inquirer/prompts"; diff --git a/scripts/v0.4/initializeDao.ts b/scripts/v0.4/initializeDao.ts index 4b9a91371..65737dbc8 100644 --- a/scripts/v0.4/initializeDao.ts +++ b/scripts/v0.4/initializeDao.ts @@ -1,6 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; import { Keypair } from "@solana/web3.js"; -import { AutocratClient } from "@metadaoproject/futarchy/v0.4"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; import * as token from "@solana/spl-token"; import { BN } from "bn.js"; diff --git a/scripts/v0.4/initializeLaunch.ts b/scripts/v0.4/initializeLaunch.ts index 439559645..38a6c05c8 100644 --- a/scripts/v0.4/initializeLaunch.ts +++ b/scripts/v0.4/initializeLaunch.ts @@ -5,7 +5,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/v0.4"; +} from "@metadaoproject/futarchy/launchpad/v0.4"; import { BN } from "bn.js"; import { homedir } from "os"; import { join } from "path"; diff --git a/scripts/v0.4/initializeMetricMarket.ts b/scripts/v0.4/initializeMetricMarket.ts index 2a6179c7f..29ded17cd 100644 --- a/scripts/v0.4/initializeMetricMarket.ts +++ b/scripts/v0.4/initializeMetricMarket.ts @@ -2,19 +2,17 @@ import * as token from "@solana/spl-token"; import { PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; import { - AmmClient, ConditionalVault, ConditionalVaultClient, - getAmmAddr, getDownAndUpMintAddrs, - getEventAuthorityAddr, getFailAndPassMintAddrs, getQuestionAddr, getVaultAddr, - MAINNET_USDC, -} from "@metadaoproject/futarchy/v0.4"; +} from "@metadaoproject/futarchy/conditional_vault/v0.4"; import { sha256 } from "@metadaoproject/futarchy"; -import { Question, Amm } from "@metadaoproject/futarchy/v0.4"; +import { Question } from "@metadaoproject/futarchy/conditional_vault/v0.4"; +import { Amm, AmmClient, getAmmAddr } from "@metadaoproject/futarchy/amm/v0.4"; +import { MAINNET_USDC } from "@metadaoproject/futarchy/"; import { BN } from "bn.js"; import { homedir } from "os"; import { join } from "path"; diff --git a/scripts/v0.4/initializeProposal.ts b/scripts/v0.4/initializeProposal.ts index 546761b02..a57ef6f20 100644 --- a/scripts/v0.4/initializeProposal.ts +++ b/scripts/v0.4/initializeProposal.ts @@ -3,10 +3,10 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; import { AutocratClient, - AUTOCRAT_PROGRAM_ID, AutocratIDL, - PriceMath, -} from "@metadaoproject/futarchy/v0.4"; +} from "@metadaoproject/futarchy/autocrat/v0.4"; +import { PriceMath } from "@metadaoproject/futarchy"; +import { AUTOCRAT_V0_4_PROGRAM_ID } from "@metadaoproject/futarchy"; async function main() { // Initialize clients @@ -61,7 +61,7 @@ async function main() { const autocrat = new anchor.Program( AutocratIDL, - AUTOCRAT_PROGRAM_ID, + AUTOCRAT_V0_4_PROGRAM_ID, provider, ); diff --git a/scripts/v0.4/startLaunch.ts b/scripts/v0.4/startLaunch.ts index d64f1ae18..f19b877a3 100644 --- a/scripts/v0.4/startLaunch.ts +++ b/scripts/v0.4/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { getLaunchAddr, LaunchpadClient } from "@metadaoproject/futarchy/v0.4"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; import { homedir } from "os"; import { join } from "path"; import fs from "fs"; diff --git a/scripts/v0.4/uploadMetadata.ts b/scripts/v0.4/uploadMetadata.ts index 1f98c9dce..eadbd96b7 100644 --- a/scripts/v0.4/uploadMetadata.ts +++ b/scripts/v0.4/uploadMetadata.ts @@ -1,9 +1,7 @@ import { ComputeBudgetProgram, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { - AutocratClient, - ConditionalVaultClient, -} from "@metadaoproject/futarchy/v0.4"; +import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; const provider = anchor.AnchorProvider.env(); const autocrat: AutocratClient = AutocratClient.createClient({ provider }); diff --git a/scripts/v0.5/assignPermissionlessAccount.ts b/scripts/v0.5/assignPermissionlessAccount.ts index 2e2f68e75..183d2f8c7 100644 --- a/scripts/v0.5/assignPermissionlessAccount.ts +++ b/scripts/v0.5/assignPermissionlessAccount.ts @@ -1,9 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import { SystemProgram, Transaction } from "@solana/web3.js"; -import { - AutocratClient, - PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.5"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.5"; async function main() { const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.5/claimAllLaunch.ts b/scripts/v0.5/claimAllLaunch.ts index 2b29246f8..cd4c44f44 100644 --- a/scripts/v0.5/claimAllLaunch.ts +++ b/scripts/v0.5/claimAllLaunch.ts @@ -5,7 +5,8 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient, LaunchpadClient } from "@metadaoproject/futarchy/v0.4"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.5/executeProposal.ts b/scripts/v0.5/executeProposal.ts index 580440290..0399e4dc6 100644 --- a/scripts/v0.5/executeProposal.ts +++ b/scripts/v0.5/executeProposal.ts @@ -1,12 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { - AutocratClient, - getDaoAddr, - DEVNET_USDC, - MAINNET_USDC, - SQUADS_PROGRAM_CONFIG_TREASURY, - PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy/v0.5"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.5"; import { Keypair, PublicKey, diff --git a/scripts/v0.5/finalizeLaunch.ts b/scripts/v0.5/finalizeLaunch.ts index 16af3d345..3b2c41fa5 100644 --- a/scripts/v0.5/finalizeLaunch.ts +++ b/scripts/v0.5/finalizeLaunch.ts @@ -6,7 +6,7 @@ import { VersionedTransaction, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.5"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.5"; import dotenv from "dotenv"; import { createLookupTableForTransaction } from "../utils/utils.js"; @@ -53,7 +53,7 @@ async function sendAndConfirmTransaction(tx: Transaction, label: string) { const completeLaunchLut = await createLookupTableForTransaction( tx, payer, - provider, + provider.connection, ); console.log("Complete launch lookup table:", completeLaunchLut); diff --git a/scripts/v0.5/initializeDao.ts b/scripts/v0.5/initializeDao.ts index 126970a32..1e3f84859 100644 --- a/scripts/v0.5/initializeDao.ts +++ b/scripts/v0.5/initializeDao.ts @@ -1,11 +1,13 @@ import * as anchor from "@coral-xyz/anchor"; import { - AutocratClient, - getDaoAddr, DEVNET_USDC, MAINNET_USDC, SQUADS_PROGRAM_CONFIG_TREASURY, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy"; +import { + AutocratClient, + getDaoAddr, +} from "@metadaoproject/futarchy/autocrat/v0.5"; import { Keypair, PublicKey, diff --git a/scripts/v0.5/initializeLaunch.ts b/scripts/v0.5/initializeLaunch.ts index 5d4671e5e..416c37a1a 100644 --- a/scripts/v0.5/initializeLaunch.ts +++ b/scripts/v0.5/initializeLaunch.ts @@ -4,7 +4,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy/launchpad/v0.5"; import { BN } from "bn.js"; import { USDC } from "../consts.js"; import { diff --git a/scripts/v0.5/initializeProposal.ts b/scripts/v0.5/initializeProposal.ts index 752abf69c..4847ac794 100644 --- a/scripts/v0.5/initializeProposal.ts +++ b/scripts/v0.5/initializeProposal.ts @@ -1,11 +1,13 @@ +import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; +import { AmmClient } from "@metadaoproject/futarchy/amm/v0.5"; import { - AmmClient, - AUTOCRAT_PROGRAM_ID, AutocratClient, - ConditionalVaultClient, getProposalAddr, +} from "@metadaoproject/futarchy/autocrat/v0.5"; +import { + AUTOCRAT_V0_5_PROGRAM_ID, InstructionUtils, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy"; import { LAMPORTS_PER_SOL, Message, @@ -134,7 +136,7 @@ async function main() { console.log("minQuoteLiquidity", minQuoteLiquidity.toString()); const [metaDaoProposal] = getProposalAddr( - AUTOCRAT_PROGRAM_ID, + AUTOCRAT_V0_5_PROGRAM_ID, SQUADS_PROPOSAL_PDA, ); diff --git a/scripts/v0.5/migrateMeta.ts b/scripts/v0.5/migrateMeta.ts index 0c25e42dd..4066493c2 100644 --- a/scripts/v0.5/migrateMeta.ts +++ b/scripts/v0.5/migrateMeta.ts @@ -17,14 +17,16 @@ import { AuthorityType, } from "@solana/spl-token"; import { - AutocratClient, - getDaoAddr, getMetadataAddr, SQUADS_PROGRAM_CONFIG_TREASURY, MAINNET_USDC, DEVNET_USDC, USDC_DECIMALS, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy"; +import { + AutocratClient, + getDaoAddr, +} from "@metadaoproject/futarchy/autocrat/v0.5"; import { BN } from "bn.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; diff --git a/scripts/v0.5/recoverProposalFunds.ts b/scripts/v0.5/recoverProposalFunds.ts index a9019b566..15aa4df07 100644 --- a/scripts/v0.5/recoverProposalFunds.ts +++ b/scripts/v0.5/recoverProposalFunds.ts @@ -1,10 +1,10 @@ +import { AUTOCRAT_V0_5_PROGRAM_ID } from "@metadaoproject/futarchy"; import { - AmmClient, - AUTOCRAT_PROGRAM_ID, AutocratClient, - ConditionalVaultClient, getProposalAddr, -} from "@metadaoproject/futarchy/v0.5"; +} from "@metadaoproject/futarchy/autocrat/v0.5"; +import { AmmClient } from "@metadaoproject/futarchy/amm/v0.5"; +import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; import { PublicKey } from "@solana/web3.js"; import { BN } from "bn.js"; import * as anchor from "@coral-xyz/anchor"; @@ -26,7 +26,7 @@ async function main() { const dao = await autocratClient.getDao(DAO_KEY); const [metaDaoProposal] = getProposalAddr( - AUTOCRAT_PROGRAM_ID, + AUTOCRAT_V0_5_PROGRAM_ID, SQUADS_PROPOSAL_PDA, ); diff --git a/scripts/v0.5/squads/executeProposal.ts b/scripts/v0.5/squads/executeProposal.ts index 2f3aadc73..1173d2b30 100644 --- a/scripts/v0.5/squads/executeProposal.ts +++ b/scripts/v0.5/squads/executeProposal.ts @@ -1,7 +1,7 @@ import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/"; import { getSquadsPdasFromDao } from "../../utils/squads.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.5/squads/initalizeTransferProposal.ts b/scripts/v0.5/squads/initalizeTransferProposal.ts index f43ca5e8e..2013cecb1 100644 --- a/scripts/v0.5/squads/initalizeTransferProposal.ts +++ b/scripts/v0.5/squads/initalizeTransferProposal.ts @@ -1,14 +1,14 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; import { createTransferInstruction, getAssociatedTokenAddressSync, createAssociatedTokenAccountIdempotentInstruction, } from "@solana/spl-token"; -import { getSquadsPdasFromDao } from "../utils/squads.js"; -import { USDC } from "../consts.js"; +import { getSquadsPdasFromDao } from "../../utils/squads.js"; +import { USDC } from "../../consts.js"; // we want transfer and config authority removal out the gate diff --git a/scripts/v0.5/squads/removeSpendingLimit.ts b/scripts/v0.5/squads/removeSpendingLimit.ts index a4cac30d9..24a234621 100644 --- a/scripts/v0.5/squads/removeSpendingLimit.ts +++ b/scripts/v0.5/squads/removeSpendingLimit.ts @@ -1,8 +1,8 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; -import { getSquadsPdasFromDao } from "../utils/squads.js"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { getSquadsPdasFromDao } from "../../utils/squads.js"; const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; diff --git a/scripts/v0.5/squads/updateSpendingLimit.ts b/scripts/v0.5/squads/updateSpendingLimit.ts index b92fa1ed3..51ceaa320 100644 --- a/scripts/v0.5/squads/updateSpendingLimit.ts +++ b/scripts/v0.5/squads/updateSpendingLimit.ts @@ -2,9 +2,9 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; import { getAssociatedTokenAddress } from "@solana/spl-token"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5"; -import { getSquadsPdasFromDao } from "../utils/squads.js"; -import { USDC } from "../consts.js"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { getSquadsPdasFromDao } from "../../utils/squads.js"; +import { USDC } from "../../consts.js"; const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; diff --git a/scripts/v0.5/squads/useSpendingLimit.ts b/scripts/v0.5/squads/useSpendingLimit.ts index 3d929e99d..d83579086 100644 --- a/scripts/v0.5/squads/useSpendingLimit.ts +++ b/scripts/v0.5/squads/useSpendingLimit.ts @@ -5,8 +5,8 @@ import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, } from "@solana/spl-token"; -import { USDC } from "../consts.js"; -import { getSquadsPdasFromDao } from "../utils/squads.js"; +import { USDC } from "../../consts.js"; +import { getSquadsPdasFromDao } from "../../utils/squads.js"; const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; diff --git a/scripts/v0.5/startLaunch.ts b/scripts/v0.5/startLaunch.ts index afc12e0fe..c243ac915 100644 --- a/scripts/v0.5/startLaunch.ts +++ b/scripts/v0.5/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.5"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.5"; import dotenv from "dotenv"; diff --git a/scripts/v0.6/burnPerformancePackage.ts b/scripts/v0.6/burnPerformancePackage.ts index aa1168bc5..f20514aeb 100644 --- a/scripts/v0.6/burnPerformancePackage.ts +++ b/scripts/v0.6/burnPerformancePackage.ts @@ -1,10 +1,10 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; +import { PriceBasedPerformancePackageClient } from "@metadaoproject/futarchy/price_based_performance_package/v0.6"; import { - PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - PriceBasedPerformancePackageClient, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; + PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, +} from "@metadaoproject/futarchy"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; // Set the performance package address before running the script diff --git a/scripts/v0.6/claimAllLaunch.ts b/scripts/v0.6/claimAllLaunch.ts index 676814652..9cd004924 100644 --- a/scripts/v0.6/claimAllLaunch.ts +++ b/scripts/v0.6/claimAllLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.6/collectMeteoraDammFees.ts b/scripts/v0.6/collectMeteoraDammFees.ts index df9128a40..5fe4d8b8e 100644 --- a/scripts/v0.6/collectMeteoraDammFees.ts +++ b/scripts/v0.6/collectMeteoraDammFees.ts @@ -1,11 +1,11 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - MAINNET_METEORA_CONFIG as V0_6_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy/v0.6"; + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG as V0_6_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/futarchy"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); @@ -15,8 +15,8 @@ const payer = provider.wallet["payer"]; const futarchy: FutarchyClient = new FutarchyClient( provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, [], ); diff --git a/scripts/v0.6/createDao.ts b/scripts/v0.6/createDao.ts index b9bfafdeb..692cfc6c8 100644 --- a/scripts/v0.6/createDao.ts +++ b/scripts/v0.6/createDao.ts @@ -2,12 +2,14 @@ import * as anchor from "@coral-xyz/anchor"; import { FutarchyClient, getDaoAddr, +} from "@metadaoproject/futarchy/futarchy/v0.6"; +import { MAINNET_USDC, SQUADS_PROGRAM_CONFIG_TREASURY, DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, DEVNET_USDC, PriceMath, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/dumpDaos.ts b/scripts/v0.6/dumpDaos.ts index 33bb5d55c..c295c527d 100644 --- a/scripts/v0.6/dumpDaos.ts +++ b/scripts/v0.6/dumpDaos.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.6/dumpDaosProposals.ts b/scripts/v0.6/dumpDaosProposals.ts index d3ee3995d..d393e1304 100644 --- a/scripts/v0.6/dumpDaosProposals.ts +++ b/scripts/v0.6/dumpDaosProposals.ts @@ -1,11 +1,6 @@ -import { - ComputeBudgetProgram, - Keypair, - Transaction, - PublicKey, -} from "@solana/web3.js"; +import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient, FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; @@ -83,10 +78,10 @@ async function main() { console.log( `Proposal discriminator (base58): ${bs58.encode(proposalDiscriminator)}`, ); - console.log(`Program ID: ${futarchy.autocrat.programId.toBase58()}\n`); + console.log(`Program ID: ${futarchy.futarchy.programId.toBase58()}\n`); const daoAccounts = await provider.connection.getProgramAccounts( - futarchy.autocrat.programId, + futarchy.futarchy.programId, { filters: [ { @@ -105,7 +100,7 @@ async function main() { } const proposalAccounts = await provider.connection.getProgramAccounts( - futarchy.autocrat.programId, + futarchy.futarchy.programId, { filters: [ { diff --git a/scripts/v0.6/executeGeneralProposal.ts b/scripts/v0.6/executeGeneralProposal.ts index 47c128d71..8e3dc1277 100644 --- a/scripts/v0.6/executeGeneralProposal.ts +++ b/scripts/v0.6/executeGeneralProposal.ts @@ -1,10 +1,8 @@ import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { - PERMISSIONLESS_ACCOUNT, - FutarchyClient, -} from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; diff --git a/scripts/v0.6/executeProposal.ts b/scripts/v0.6/executeProposal.ts index b20599c9f..b618b8866 100644 --- a/scripts/v0.6/executeProposal.ts +++ b/scripts/v0.6/executeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; @@ -39,7 +39,7 @@ const executeSpendingLimit = async () => { isSigner: false, })); - const executeIx = await futarchy.autocrat.methods + const executeIx = await futarchy.futarchy.methods .executeSpendingLimitChange() .accounts({ proposal: PROPOSAL, diff --git a/scripts/v0.6/finalizeLaunch.ts b/scripts/v0.6/finalizeLaunch.ts index 5bb4253cd..eef078fd0 100644 --- a/scripts/v0.6/finalizeLaunch.ts +++ b/scripts/v0.6/finalizeLaunch.ts @@ -1,5 +1,8 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient, getLaunchAddr } from "@metadaoproject/futarchy/v0.6"; +import { + LaunchpadClient, + getLaunchAddr, +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, TransactionMessage, diff --git a/scripts/v0.6/finalizeProposal.ts b/scripts/v0.6/finalizeProposal.ts index 0719dad15..6780f2bdc 100644 --- a/scripts/v0.6/finalizeProposal.ts +++ b/scripts/v0.6/finalizeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { PublicKey, Transaction } from "@solana/web3.js"; import { BN } from "@coral-xyz/anchor"; diff --git a/scripts/v0.6/initializeDao.ts b/scripts/v0.6/initializeDao.ts index 682f478bd..6b0a4699c 100644 --- a/scripts/v0.6/initializeDao.ts +++ b/scripts/v0.6/initializeDao.ts @@ -2,10 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { FutarchyClient, getDaoAddr, - DEVNET_USDC, - MAINNET_USDC, - SQUADS_PROGRAM_CONFIG_TREASURY, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/futarchy/v0.6"; import { Keypair, PublicKey, @@ -15,7 +12,7 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "@metadaoproject/futarchy/v0.6"; +import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "@metadaoproject/futarchy"; import * as token from "@solana/spl-token"; // DAO DETAILS @@ -92,6 +89,8 @@ export const initializeDao = async () => { initialSpendingLimit: null, baseToStake: new BN(0), secondsPerProposal: 60 * 60 * 24 * 3, + teamAddress: PublicKey.default, + teamSponsoredPassThresholdBps: 0, }, }) .rpc(); diff --git a/scripts/v0.6/launch.ts b/scripts/v0.6/launch.ts index 73da2feb8..18087c179 100644 --- a/scripts/v0.6/launch.ts +++ b/scripts/v0.6/launch.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -78,6 +78,7 @@ export const launch = async () => { performancePackageTokenAmount: new BN(10), monthsUntilInsidersCanUnlock: 18, secondsForLaunch: fourDays, + teamAddress: PublicKey.default, }) .rpc(); diff --git a/scripts/v0.6/launchLoyal.ts b/scripts/v0.6/launchLoyal.ts index 0e12b2cc0..d8241b9e6 100644 --- a/scripts/v0.6/launchLoyal.ts +++ b/scripts/v0.6/launchLoyal.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -85,6 +85,7 @@ export const launch = async () => { ), monthsUntilInsidersCanUnlock: PERFORMANCE_PACKAGE_UNLOCK_TIME, secondsForLaunch: fourDays, + teamAddress: PublicKey.default, }) .rpc(); diff --git a/scripts/v0.6/launchPaystream.ts b/scripts/v0.6/launchPaystream.ts index 09167cb9c..ea3225dfc 100644 --- a/scripts/v0.6/launchPaystream.ts +++ b/scripts/v0.6/launchPaystream.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -86,6 +86,7 @@ export const launch = async () => { ), monthsUntilInsidersCanUnlock: PERFORMANCE_PACKAGE_UNLOCK_TIME, secondsForLaunch: fourDays, + teamAddress: PublicKey.default, }) .rpc(); diff --git a/scripts/v0.6/launchSOLO.ts b/scripts/v0.6/launchSOLO.ts index 0ec11ec52..3c51e899d 100644 --- a/scripts/v0.6/launchSOLO.ts +++ b/scripts/v0.6/launchSOLO.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -85,6 +85,7 @@ export const launch = async () => { ), monthsUntilInsidersCanUnlock: PERFORMANCE_PACKAGE_UNLOCK_TIME, secondsForLaunch: fourDays, + teamAddress: PublicKey.default, }) .rpc(); diff --git a/scripts/v0.6/launchZKLSOL.ts b/scripts/v0.6/launchZKLSOL.ts index 118bfbb12..d83ca76cd 100644 --- a/scripts/v0.6/launchZKLSOL.ts +++ b/scripts/v0.6/launchZKLSOL.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.6"; +} from "@metadaoproject/futarchy/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -85,6 +85,7 @@ export const launch = async () => { ), monthsUntilInsidersCanUnlock: PERFORMANCE_PACKAGE_UNLOCK_TIME, secondsForLaunch: fourDays, + teamAddress: PublicKey.default, }) .rpc(); diff --git a/scripts/v0.6/migrateDaos.ts b/scripts/v0.6/migrateDaos.ts index 427b3f7a1..9c99ebd43 100644 --- a/scripts/v0.6/migrateDaos.ts +++ b/scripts/v0.6/migrateDaos.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.6/provideLiquidity.ts b/scripts/v0.6/provideLiquidity.ts index df2c82247..3c66eb860 100644 --- a/scripts/v0.6/provideLiquidity.ts +++ b/scripts/v0.6/provideLiquidity.ts @@ -1,9 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { - FutarchyClient, - MAINNET_USDC, - DEVNET_USDC, -} from "@metadaoproject/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { MAINNET_USDC, DEVNET_USDC } from "@metadaoproject/futarchy"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/returnFunds.ts b/scripts/v0.6/returnFunds.ts index e232e2262..adaaa6624 100644 --- a/scripts/v0.6/returnFunds.ts +++ b/scripts/v0.6/returnFunds.ts @@ -1,14 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - LaunchpadClient, - MAINNET_USDC, - METADAO_MULTISIG_VAULT, - MAINNET_METEORA_CONFIG as V0_6_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy/v0.6"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; +import { MAINNET_USDC, METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { BN } from "bn.js"; diff --git a/scripts/v0.7/burnPerformancePackage.ts b/scripts/v0.7/burnPerformancePackage.ts index aa1168bc5..d65ca4cc0 100644 --- a/scripts/v0.7/burnPerformancePackage.ts +++ b/scripts/v0.7/burnPerformancePackage.ts @@ -4,7 +4,7 @@ import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, PriceBasedPerformancePackageClient, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; // Set the performance package address before running the script diff --git a/scripts/v0.7/claimAllLaunch.ts b/scripts/v0.7/claimAllLaunch.ts index 5e11dba3c..004843d3c 100644 --- a/scripts/v0.7/claimAllLaunch.ts +++ b/scripts/v0.7/claimAllLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.7/claimLaunchAdditionalTokens.ts b/scripts/v0.7/claimLaunchAdditionalTokens.ts index e29090f45..5036f55d4 100644 --- a/scripts/v0.7/claimLaunchAdditionalTokens.ts +++ b/scripts/v0.7/claimLaunchAdditionalTokens.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.7/closeLaunch.ts b/scripts/v0.7/closeLaunch.ts index 6d985a770..e06eece6e 100644 --- a/scripts/v0.7/closeLaunch.ts +++ b/scripts/v0.7/closeLaunch.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient, getLaunchAddr } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.7/collectAllFees.ts b/scripts/v0.7/collectAllFees.ts index aba7c880d..7513e8907 100644 --- a/scripts/v0.7/collectAllFees.ts +++ b/scripts/v0.7/collectAllFees.ts @@ -1,13 +1,13 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; +import { BidWallClient } from "@metadaoproject/futarchy/bid_wall/v0.7"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - MAINNET_METEORA_CONFIG, - BidWallClient, - BID_WALL_PROGRAM_ID, -} from "@metadaoproject/futarchy/v0.7"; + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + BID_WALL_V0_7_PROGRAM_ID, +} from "@metadaoproject/futarchy"; import { PublicKey } from "@solana/web3.js"; import { getAssociatedTokenAddressSync, @@ -28,14 +28,14 @@ const payer = provider.wallet["payer"]; const futarchy: FutarchyClient = new FutarchyClient( provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, [], ); const bidWallClient: BidWallClient = BidWallClient.createClient({ provider, - bidWallProgramId: BID_WALL_PROGRAM_ID, + bidWallProgramId: BID_WALL_V0_7_PROGRAM_ID, }); interface FeeCollectionResult { @@ -53,7 +53,7 @@ interface FeeCollectionResult { const collectAllFees = async () => { // Fetch all DAOs console.log("[1] Fetching all DAOs..."); - const allDaos = await futarchy.autocrat.account.dao.all(); + const allDaos = await futarchy.futarchy.account.dao.all(); console.log(`Found ${allDaos.length} DAOs`); // Fetch all bid walls @@ -153,7 +153,7 @@ const collectAllFees = async () => { quoteMint: dao.account.quoteMint, transactionIndex: BigInt(squadsMultisigAccount.transactionIndex.toString()) + 1n, - meteoraConfig: MAINNET_METEORA_CONFIG, + meteoraConfig: LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, }) .preInstructions([createBaseAtaIx, createQuoteAtaIx]) .rpc(); diff --git a/scripts/v0.7/collectFees.ts b/scripts/v0.7/collectFees.ts index 723a8b6ac..4534b41f0 100644 --- a/scripts/v0.7/collectFees.ts +++ b/scripts/v0.7/collectFees.ts @@ -1,13 +1,12 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - FEE_RECIPIENT, -} from "@metadaoproject/futarchy/v0.7"; + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + METADAO_MULTISIG_VAULT, +} from "@metadaoproject/futarchy"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; // Set the DAO address before running the script const dao = new PublicKey(""); @@ -19,8 +18,8 @@ const payer = provider.wallet["payer"]; const futarchy: FutarchyClient = new FutarchyClient( provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, [], ); @@ -28,7 +27,7 @@ const futarchy: FutarchyClient = new FutarchyClient( const metadaoSquadsMultisig = new PublicKey( "8N3Tvc6B1wEVKVC6iD4s6eyaCNqX2ovj2xze2q3Q9DWH", ); -const metadaoSquadsMultisigVault = FEE_RECIPIENT; +const metadaoSquadsMultisigVault = METADAO_MULTISIG_VAULT; export const collectFees = async () => { const daoAccount = await futarchy.fetchDao(dao); @@ -41,27 +40,12 @@ export const collectFees = async () => { metadaoSquadsMultisig, ); - // We want to receive the fees in the Metadao DAO's multisig vault - const feeRecipientBaseTokenAccount = getAssociatedTokenAddressSync( - daoAccount.baseMint, - metadaoSquadsMultisigVault, - true, - ); - - const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( - daoAccount.quoteMint, - metadaoSquadsMultisigVault, - true, - ); - // Prepare transaction message const collectFeesIx = await futarchy .collectFeesIx({ dao, baseMint: daoAccount.baseMint, quoteMint: daoAccount.quoteMint, - baseTokenAccount: feeRecipientBaseTokenAccount, - quoteTokenAccount: feeRecipientQuoteTokenAccount, }) .instruction(); diff --git a/scripts/v0.7/collectLpFees.ts b/scripts/v0.7/collectLpFees.ts deleted file mode 100644 index c96210d1e..000000000 --- a/scripts/v0.7/collectLpFees.ts +++ /dev/null @@ -1,110 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import * as multisig from "@sqds/multisig"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - FEE_RECIPIENT, -} from "@metadaoproject/futarchy/v0.7"; -import { PublicKey, TransactionMessage } from "@solana/web3.js"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { BN } from "@coral-xyz/anchor"; - -// Set the DAO address before running the script -const dao = new PublicKey(""); - -// Set the target K before running the script -const initialBaseReserves = new BN(0); -const initialQuoteReserves = new BN(0); -const targetK = new BN(initialBaseReserves.mul(initialQuoteReserves)); - -const provider = anchor.AnchorProvider.env(); - -// Payer MUST be the non-Squads signer - tSTp6B6kE9o6ZaTmHm2ZwnJBBtgd3x112tapxFhmBEQ -const payer = provider.wallet["payer"]; - -const futarchy: FutarchyClient = new FutarchyClient( - provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - [], -); - -// We need both the multisig and vault addresses for the Metadao DAO -const metadaoSquadsMultisig = new PublicKey( - "8N3Tvc6B1wEVKVC6iD4s6eyaCNqX2ovj2xze2q3Q9DWH", -); -const metadaoSquadsMultisigVault = FEE_RECIPIENT; - -// This should only be run once per DAO/AMM -// It's meant to be a one-off operation that reduces liquidity to a target K (the inital pool's liquidity) and collect it as "fees" -// We're using this because we didn't track LP fee collection in the pool state, nor did we exclude those fees from liquidity -export const collectLpFees = async () => { - if (targetK.isZero()) { - throw new Error( - "Target K is zero. Please set initial base and quote reserves before running the script.", - ); - } - - const daoAccount = await futarchy.fetchDao(dao); - - // We call the collect fees instruction from Metadao DAO's multisig account - // It's the only one that can call the collect fees instruction - const metaDaoSquadsMultisigAccount = - await multisig.accounts.Multisig.fromAccountAddress( - anchor.getProvider().connection, - metadaoSquadsMultisig, - ); - - // We want to receive the fees in the Metadao DAO's multisig vault - const feeRecipientBaseTokenAccount = getAssociatedTokenAddressSync( - daoAccount.baseMint, - metadaoSquadsMultisigVault, - true, - ); - - const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( - daoAccount.quoteMint, - metadaoSquadsMultisigVault, - true, - ); - - // Prepare transaction message - const collectLpFeesIx = await futarchy - .collectLpFeesIx({ - dao, - baseMint: daoAccount.baseMint, - quoteMint: daoAccount.quoteMint, - baseTokenAccount: feeRecipientBaseTokenAccount, - quoteTokenAccount: feeRecipientQuoteTokenAccount, - targetK: targetK, - }) - .instruction(); - - const transactionMessage = new TransactionMessage({ - instructions: [collectLpFeesIx], - payerKey: metadaoSquadsMultisigVault, - recentBlockhash: (await provider.connection.getLatestBlockhash()).blockhash, - }); - - // Create vault transaction - const vaultTxCreateSignature = await multisig.rpc.vaultTransactionCreate({ - connection: anchor.getProvider().connection, - creator: payer.publicKey, - feePayer: payer.publicKey, - ephemeralSigners: 0, - multisigPda: metadaoSquadsMultisig, - transactionIndex: - BigInt(metaDaoSquadsMultisigAccount.transactionIndex.toString()) + 1n, - vaultIndex: 0, - transactionMessage, - }); - - console.log( - "Vault collect fees transaction create signature:", - vaultTxCreateSignature, - ); - console.log("Go ahead and execute the transaction through Squads."); -}; - -collectLpFees().catch(console.error); diff --git a/scripts/v0.7/collectMeteoraDammFees.ts b/scripts/v0.7/collectMeteoraDammFees.ts index ad00aaeea..bbea3d3c6 100644 --- a/scripts/v0.7/collectMeteoraDammFees.ts +++ b/scripts/v0.7/collectMeteoraDammFees.ts @@ -1,11 +1,12 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, - MAINNET_METEORA_CONFIG as V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy/v0.7"; + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/futarchy"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; + import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); @@ -15,8 +16,8 @@ const payer = provider.wallet["payer"]; const futarchy: FutarchyClient = new FutarchyClient( provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, [], ); @@ -39,7 +40,7 @@ export const collectMeteoraDammFees = async () => { quoteMint: daoAccount.quoteMint, transactionIndex: BigInt(squadsMultisigAccount.transactionIndex.toString()) + 1n, - meteoraConfig: V0_7_MAINNET_METEORA_CONFIG, + meteoraConfig: LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, }) .signers([payer]) .rpc(); diff --git a/scripts/v0.7/completeLaunch.ts b/scripts/v0.7/completeLaunch.ts index a471513a0..13a549ecc 100644 --- a/scripts/v0.7/completeLaunch.ts +++ b/scripts/v0.7/completeLaunch.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient, getLaunchAddr } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey, TransactionMessage, diff --git a/scripts/v0.7/dumpDaos.ts b/scripts/v0.7/dumpDaos.ts index 64bebc6a3..976005dbc 100644 --- a/scripts/v0.7/dumpDaos.ts +++ b/scripts/v0.7/dumpDaos.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.7"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/dumpLaunches.ts b/scripts/v0.7/dumpLaunches.ts index 4dbac8902..e2485d801 100644 --- a/scripts/v0.7/dumpLaunches.ts +++ b/scripts/v0.7/dumpLaunches.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/dumpLaunchesAndFundingRecords.ts b/scripts/v0.7/dumpLaunchesAndFundingRecords.ts index 81db03e50..7ba6b723b 100644 --- a/scripts/v0.7/dumpLaunchesAndFundingRecords.ts +++ b/scripts/v0.7/dumpLaunchesAndFundingRecords.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/extendLaunch.ts b/scripts/v0.7/extendLaunch.ts index 8d94cfa46..5e764cc06 100644 --- a/scripts/v0.7/extendLaunch.ts +++ b/scripts/v0.7/extendLaunch.ts @@ -1,9 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { - LaunchpadClient, - METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; // Set the launch address before running the script diff --git a/scripts/v0.7/hurupay/setupLaunch.ts b/scripts/v0.7/hurupay/setupLaunch.ts index 730d96dc2..921b325d7 100644 --- a/scripts/v0.7/hurupay/setupLaunch.ts +++ b/scripts/v0.7/hurupay/setupLaunch.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy/launchpad/v0.7"; import { ComputeBudgetProgram, PublicKey, @@ -110,6 +110,7 @@ export const launch = async () => { : undefined, additionalTokensRecipient: ADDITIONAL_CARVEOUT_RECIPIENT, launchAuthority: LAUNCH_AUTHORITY, + hasBidWall: false, }) .instruction(); diff --git a/scripts/v0.7/initializePerformancePackage.ts b/scripts/v0.7/initializePerformancePackage.ts index b1faf5a02..20c726aee 100644 --- a/scripts/v0.7/initializePerformancePackage.ts +++ b/scripts/v0.7/initializePerformancePackage.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const LAUNCH_TO_COMPLETE: PublicKey | undefined = new PublicKey( diff --git a/scripts/v0.7/launchP2P.ts b/scripts/v0.7/launchP2P.ts index 5713e5021..4ce60c972 100644 --- a/scripts/v0.7/launchP2P.ts +++ b/scripts/v0.7/launchP2P.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy/launchpad/v0.7"; import { ComputeBudgetProgram, PublicKey, @@ -107,6 +107,7 @@ export const launch = async () => { : undefined, additionalTokensRecipient: ADDITIONAL_CARVEOUT_RECIPIENT, launchAuthority: LAUNCH_AUTHORITY, + hasBidWall: false, }) .instruction(); diff --git a/scripts/v0.7/launchRNGR.ts b/scripts/v0.7/launchRNGR.ts index 5c0381ee3..a59b172ed 100644 --- a/scripts/v0.7/launchRNGR.ts +++ b/scripts/v0.7/launchRNGR.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -105,6 +105,7 @@ export const launch = async () => { : undefined, additionalTokensRecipient: ADDITIONAL_CARVEOUT_RECIPIENT, launchAuthority: LAUNCH_AUTHORITY, + hasBidWall: true, }) .rpc(); diff --git a/scripts/v0.7/launchTemplate.ts b/scripts/v0.7/launchTemplate.ts index e72ca5358..bcd59e57e 100644 --- a/scripts/v0.7/launchTemplate.ts +++ b/scripts/v0.7/launchTemplate.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/v0.7"; +} from "@metadaoproject/futarchy/launchpad/v0.7"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; @@ -95,6 +95,7 @@ export const launch = async () => { : undefined, additionalTokensRecipient: ADDITIONAL_CARVEOUT_RECIPIENT, launchAuthority: LAUNCH_AUTHORITY, + hasBidWall: false, }) .instruction(); diff --git a/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts b/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts index 667b806b4..02136ec70 100644 --- a/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts +++ b/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts @@ -8,7 +8,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; import fs from "fs"; import path from "path"; diff --git a/scripts/v0.7/removeProposal.ts b/scripts/v0.7/removeProposal.ts index 1c48e80d1..df59b513c 100644 --- a/scripts/v0.7/removeProposal.ts +++ b/scripts/v0.7/removeProposal.ts @@ -1,9 +1,9 @@ import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import { - CONDITIONAL_VAULT_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - FutarchyClient, -} from "@metadaoproject/futarchy/v0.7"; + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, +} from "@metadaoproject/futarchy"; import { PublicKey } from "@solana/web3.js"; // Set the proposal address before running the script @@ -16,8 +16,8 @@ const payer = provider.wallet["payer"]; const futarchy: FutarchyClient = new FutarchyClient( provider, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, + FUTARCHY_V0_6_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, [], ); @@ -29,7 +29,7 @@ export const removeProposal = async () => { console.log(`DAO: ${proposalAccount.dao.toBase58()}`); console.log(`Current state: ${JSON.stringify(proposalAccount.state)}`); - const tx = await futarchy.autocrat.methods + const tx = await futarchy.futarchy.methods .adminRemoveProposal() .accounts({ proposal, diff --git a/scripts/v0.7/resizeDaos.ts b/scripts/v0.7/resizeDaos.ts index 73f829f5a..e0974b042 100644 --- a/scripts/v0.7/resizeDaos.ts +++ b/scripts/v0.7/resizeDaos.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/v0.7"; +import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/resizeLaunches.ts b/scripts/v0.7/resizeLaunches.ts index 9014b7715..583289f54 100644 --- a/scripts/v0.7/resizeLaunches.ts +++ b/scripts/v0.7/resizeLaunches.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/resizeLaunchesAndFundingRecords.ts b/scripts/v0.7/resizeLaunchesAndFundingRecords.ts index 927926703..f239e7130 100644 --- a/scripts/v0.7/resizeLaunchesAndFundingRecords.ts +++ b/scripts/v0.7/resizeLaunchesAndFundingRecords.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/startLaunch.ts b/scripts/v0.7/startLaunch.ts index e898dcd8d..229f0dafa 100644 --- a/scripts/v0.7/startLaunch.ts +++ b/scripts/v0.7/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; +import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; import dotenv from "dotenv"; diff --git a/sdk2/src/amm/v0.5/AmmClient.ts b/sdk2/src/amm/v0.5/AmmClient.ts index 57e090246..55217368f 100644 --- a/sdk2/src/amm/v0.5/AmmClient.ts +++ b/sdk2/src/amm/v0.5/AmmClient.ts @@ -9,7 +9,7 @@ import { import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; import BN from "bn.js"; -import { AMM_PROGRAM_ID } from "../../constants.js"; +import { AMM_V0_5_PROGRAM_ID } from "../../constants.js"; import { Amm } from "./types/index.js"; import { LowercaseKeys } from "../../utils.js"; import { getAmmLpMintAddr, getAmmAddr } from "./pda.js"; @@ -50,7 +50,7 @@ export class AmmClient { const luts: AddressLookupTableAccount[] = []; - return new AmmClient(provider, programId || AMM_PROGRAM_ID, luts); + return new AmmClient(provider, programId || AMM_V0_5_PROGRAM_ID, luts); } getProgramId(): PublicKey { diff --git a/sdk2/src/amm/v0.5/pda.ts b/sdk2/src/amm/v0.5/pda.ts index d8adea698..24f861c6b 100644 --- a/sdk2/src/amm/v0.5/pda.ts +++ b/sdk2/src/amm/v0.5/pda.ts @@ -1,9 +1,9 @@ import { PublicKey } from "@solana/web3.js"; import { utils } from "@coral-xyz/anchor"; -import { AMM_PROGRAM_ID } from "../../constants.js"; +import { AMM_V0_5_PROGRAM_ID } from "../../constants.js"; export const getAmmAddr = ( - programId: PublicKey = AMM_PROGRAM_ID, + programId: PublicKey = AMM_V0_5_PROGRAM_ID, baseMint: PublicKey, quoteMint: PublicKey, ): [PublicKey, number] => { @@ -18,7 +18,7 @@ export const getAmmAddr = ( }; export const getAmmLpMintAddr = ( - programId: PublicKey = AMM_PROGRAM_ID, + programId: PublicKey = AMM_V0_5_PROGRAM_ID, amm: PublicKey, ): [PublicKey, number] => { return PublicKey.findProgramAddressSync( diff --git a/sdk2/src/autocrat/v0.4/AutocratClient.ts b/sdk2/src/autocrat/v0.4/AutocratClient.ts index ae3e8c231..3ab6384c2 100644 --- a/sdk2/src/autocrat/v0.4/AutocratClient.ts +++ b/sdk2/src/autocrat/v0.4/AutocratClient.ts @@ -19,7 +19,7 @@ import BN from "bn.js"; import { AMM_V0_4_PROGRAM_ID, AUTOCRAT_V0_4_PROGRAM_ID, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, MAINNET_USDC, USDC_DECIMALS, } from "../../constants.js"; @@ -97,7 +97,7 @@ export class AutocratClient { return new AutocratClient( provider, autocratProgramId || AUTOCRAT_V0_4_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_4_PROGRAM_ID, ammProgramId || AMM_V0_4_PROGRAM_ID, luts, ); diff --git a/sdk2/src/autocrat/v0.5/AutocratClient.ts b/sdk2/src/autocrat/v0.5/AutocratClient.ts index 31d7bae4a..bcc93140d 100644 --- a/sdk2/src/autocrat/v0.5/AutocratClient.ts +++ b/sdk2/src/autocrat/v0.5/AutocratClient.ts @@ -16,9 +16,9 @@ import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; import BN from "bn.js"; import { - AMM_PROGRAM_ID, + AMM_V0_5_PROGRAM_ID, AUTOCRAT_V0_5_PROGRAM_ID, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, MAINNET_USDC, SQUADS_PROGRAM_CONFIG, SQUADS_PROGRAM_CONFIG_TREASURY, @@ -101,8 +101,8 @@ export class AutocratClient { return new AutocratClient( provider, autocratProgramId || AUTOCRAT_V0_5_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, - ammProgramId || AMM_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + ammProgramId || AMM_V0_5_PROGRAM_ID, luts, ); } diff --git a/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts b/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts index 4aa216fe7..a0d8c9c12 100644 --- a/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts +++ b/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts @@ -5,7 +5,7 @@ import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; import BN from "bn.js"; import { - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, MPL_TOKEN_METADATA_PROGRAM_ID, } from "../../constants.js"; import { getMetadataAddr } from "../../pda.js"; @@ -46,7 +46,7 @@ export class ConditionalVaultClient { return new ConditionalVaultClient( provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_4_PROGRAM_ID, ); } diff --git a/sdk2/src/constants.ts b/sdk2/src/constants.ts index 3de3f7b6d..8701b71bc 100644 --- a/sdk2/src/constants.ts +++ b/sdk2/src/constants.ts @@ -28,14 +28,14 @@ export const AUTOCRAT_V0_5_PROGRAM_ID = new PublicKey( export const LAUNCHPAD_V0_5_PROGRAM_ID = new PublicKey( "mooNhciQJi1LqHDmse2JPic2NqG2PXCanbE3ZYzP3qA", ); +export const AMM_V0_5_PROGRAM_ID = new PublicKey( + "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", +); export const FUTARCHY_V0_6_PROGRAM_ID = new PublicKey( "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq", ); -export const AMM_PROGRAM_ID = new PublicKey( - "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", -); -export const CONDITIONAL_VAULT_v0_4_PROGRAM_ID = new PublicKey( +export const CONDITIONAL_VAULT_V0_4_PROGRAM_ID = new PublicKey( "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", ); export const LAUNCHPAD_V0_6_PROGRAM_ID = new PublicKey( @@ -76,7 +76,7 @@ export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( ); export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", + "METAwkXcqyXKy1AtsSgJ8JiUHwGCafnZL38n3vYmeta", ); export const MAINNET_USDC = new PublicKey( "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk2/src/futarchy/v0.6/FutarchyClient.ts index e8067769c..ca82d6403 100644 --- a/sdk2/src/futarchy/v0.6/FutarchyClient.ts +++ b/sdk2/src/futarchy/v0.6/FutarchyClient.ts @@ -21,7 +21,7 @@ import * as multisig from "@sqds/multisig"; import { FUTARCHY_V0_6_PROGRAM_ID, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, SQUADS_PROGRAM_CONFIG, @@ -104,7 +104,7 @@ export class FutarchyClient { return new FutarchyClient( provider, futarchyProgramId || FUTARCHY_V0_6_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + conditionalVaultProgramId || CONDITIONAL_VAULT_V0_4_PROGRAM_ID, luts, ); } diff --git a/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts b/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts index 168e1599c..367075bd1 100644 --- a/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts +++ b/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts @@ -29,8 +29,8 @@ import { SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, RAYDIUM_CP_SWAP_PROGRAM_ID, RAYDIUM_AUTHORITY, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, - AMM_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, + AMM_V0_5_PROGRAM_ID, AUTOCRAT_V0_5_PROGRAM_ID, LOW_FEE_RAYDIUM_CONFIG, RAYDIUM_CREATE_POOL_FEE_RECEIVE, diff --git a/tests/conditionalVault/unit.ts b/tests/conditionalVault/unit.ts index bff9c27b7..9a2a1aeb0 100644 --- a/tests/conditionalVault/unit.ts +++ b/tests/conditionalVault/unit.ts @@ -27,7 +27,7 @@ import { IDL as ConditionalVaultIDL, } from "../../target/types/conditional_vault.js"; import { - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, ConditionalVaultClient, getConditionalTokenMintAddr, getQuestionAddr, @@ -97,7 +97,7 @@ describe("conditional_vault", async function () { vaultProgram = new Program( ConditionalVaultIDL, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, provider, ); diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index a3ad1c2b6..6d03d11d6 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -1,6 +1,6 @@ import { PERMISSIONLESS_ACCOUNT, - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, SQUADS_PROGRAM_ID, getEventAuthorityAddr, } from "@metadaoproject/futarchy"; @@ -152,7 +152,7 @@ export default function suite() { const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const [vaultEventAuthority] = getEventAuthorityAddr( - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, ); await this.futarchy.futarchy.methods @@ -195,7 +195,7 @@ export default function suite() { dao, true, ), - vaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + vaultProgram: CONDITIONAL_VAULT_V0_4_PROGRAM_ID, vaultEventAuthority, quoteVault, quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( @@ -250,7 +250,7 @@ export default function suite() { const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; const [vaultEventAuthority] = getEventAuthorityAddr( - CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + CONDITIONAL_VAULT_V0_4_PROGRAM_ID, ); const accounts = { @@ -283,7 +283,7 @@ export default function suite() { dao, true, ), - vaultProgram: CONDITIONAL_VAULT_v0_4_PROGRAM_ID, + vaultProgram: CONDITIONAL_VAULT_V0_4_PROGRAM_ID, vaultEventAuthority, quoteVault, quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( diff --git a/tsconfig.json b/tsconfig.json index f1dd71d77..f7ad19bd9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "moduleResolution": "nodenext", "esModuleInterop": true, "resolveJsonModule": true, + "skipLibCheck": true, "paths": { "@solana/spl-token": [ "./node_modules/@solana/spl-token" From 71a317bee0589dfe988d17ddd78ad37feb323960 Mon Sep 17 00:00:00 2001 From: Pileks Date: Mon, 27 Apr 2026 23:30:38 +0200 Subject: [PATCH 092/100] restore legacy v0.6.0 IDLs and v0.5 simulateSwap helper --- sdk2/src/amm/v0.5/index.ts | 1 + sdk2/src/amm/v0.5/priceMath.ts | 57 + sdk2/src/futarchy/v0.6/FutarchyClient.ts | 10 + sdk2/src/futarchy/v0.6/types/index.ts | 43 + .../futarchy/v0.6/types/v0.6.0-futarchy.ts | 5133 +++++++++++++++++ sdk2/src/launchpad/index.ts | 13 + sdk2/src/launchpad/v0.6/LaunchpadClient.ts | 2 +- sdk2/src/launchpad/v0.6/types/index.ts | 29 + .../launchpad/v0.6/types/v0.6.0-launchpad.ts | 2553 ++++++++ sdk2/src/priceMath.ts | 7 - 10 files changed, 7840 insertions(+), 8 deletions(-) create mode 100644 sdk2/src/amm/v0.5/priceMath.ts create mode 100644 sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts create mode 100644 sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts diff --git a/sdk2/src/amm/v0.5/index.ts b/sdk2/src/amm/v0.5/index.ts index cf8af7f89..97359d824 100644 --- a/sdk2/src/amm/v0.5/index.ts +++ b/sdk2/src/amm/v0.5/index.ts @@ -1,3 +1,4 @@ export * from "./types/index.js"; export * from "./pda.js"; export * from "./AmmClient.js"; +export * from "./priceMath.js"; diff --git a/sdk2/src/amm/v0.5/priceMath.ts b/sdk2/src/amm/v0.5/priceMath.ts new file mode 100644 index 000000000..4e78b1f0d --- /dev/null +++ b/sdk2/src/amm/v0.5/priceMath.ts @@ -0,0 +1,57 @@ +import BN from "bn.js"; +import { PriceMath } from "../../priceMath.js"; +import { SwapType } from "./AmmClient.js"; + +export type SwapSimulation = { + expectedOut: BN; + newBaseReserves: BN; + newQuoteReserves: BN; + minExpectedOut?: BN; +}; + +// Only applies to legacy v0.4/v0.5 AMMs (1% fee, simple x*y=k). +// The v0.6+ on-DAO conditional AMM uses different mechanics. +export function simulateSwap( + inputAmount: BN, + swapType: SwapType, + baseReserves: BN, + quoteReserves: BN, + slippageBps?: BN, +): SwapSimulation { + let inputReserves: BN; + let outputReserves: BN; + if (swapType.buy) { + inputReserves = quoteReserves; + outputReserves = baseReserves; + } else { + inputReserves = baseReserves; + outputReserves = quoteReserves; + } + + const expectedOut = PriceMath.simulateSwapInner( + inputAmount, + inputReserves, + outputReserves, + ); + + const minExpectedOut = slippageBps + ? PriceMath.subtractSlippage(expectedOut, slippageBps) + : undefined; + + let newBaseReserves: BN; + let newQuoteReserves: BN; + if (swapType.buy) { + newBaseReserves = baseReserves.sub(expectedOut); + newQuoteReserves = quoteReserves.add(inputAmount); + } else { + newBaseReserves = baseReserves.add(inputAmount); + newQuoteReserves = quoteReserves.sub(expectedOut); + } + + return { + expectedOut, + newBaseReserves, + newQuoteReserves, + minExpectedOut, + }; +} diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk2/src/futarchy/v0.6/FutarchyClient.ts index ca82d6403..125843dff 100644 --- a/sdk2/src/futarchy/v0.6/FutarchyClient.ts +++ b/sdk2/src/futarchy/v0.6/FutarchyClient.ts @@ -43,6 +43,10 @@ import { UpdateDaoParams, } from "./types/index.js"; import { Futarchy, IDL as FutarchyIDL } from "./types/futarchy.js"; +import { + Futarchy as v0_6_0_futarchy, + IDL as v0_6_0_futarchyIDL, +} from "./types/v0.6.0-futarchy.js"; import { getDaoAddr, getProposalAddr, @@ -71,6 +75,7 @@ export type ProposalVaults = { export class FutarchyClient { public readonly provider: AnchorProvider; public readonly futarchy: Program; + public readonly v0_6_0_futarchy: Program; public readonly vaultClient: ConditionalVaultClient; public readonly luts: AddressLookupTableAccount[]; @@ -86,6 +91,11 @@ export class FutarchyClient { futarchyProgramId, provider, ); + this.v0_6_0_futarchy = new Program( + v0_6_0_futarchyIDL, + futarchyProgramId, + provider, + ); this.vaultClient = ConditionalVaultClient.createClient({ provider, conditionalVaultProgramId, diff --git a/sdk2/src/futarchy/v0.6/types/index.ts b/sdk2/src/futarchy/v0.6/types/index.ts index 240cf5c94..7738fb8f3 100644 --- a/sdk2/src/futarchy/v0.6/types/index.ts +++ b/sdk2/src/futarchy/v0.6/types/index.ts @@ -1,6 +1,12 @@ import { Futarchy as FutarchyProgram, IDL as FutarchyIDL } from "./futarchy.js"; export { FutarchyProgram, FutarchyIDL }; +import { + Futarchy as v0_6_0_Futarchy, + IDL as v0_6_0_FutarchyIDL, +} from "./v0.6.0-futarchy.js"; +export { v0_6_0_Futarchy, v0_6_0_FutarchyIDL }; + export { LowercaseKeys } from "../../../utils.js"; import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; @@ -55,3 +61,40 @@ export type FutarchyEvent = | SponsorProposalEvent | InitiateVaultSpendOptimisticProposalEvent | FinalizeOptimisticProposalEvent; + +export type v0_6_0_CollectFeesEvent = + IdlEvents["CollectFeesEvent"]; +export type v0_6_0_InitializeDaoEvent = + IdlEvents["InitializeDaoEvent"]; +export type v0_6_0_UpdateDaoEvent = + IdlEvents["UpdateDaoEvent"]; +export type v0_6_0_InitializeProposalEvent = + IdlEvents["InitializeProposalEvent"]; +export type v0_6_0_StakeToProposalEvent = + IdlEvents["StakeToProposalEvent"]; +export type v0_6_0_UnstakeFromProposalEvent = + IdlEvents["UnstakeFromProposalEvent"]; +export type v0_6_0_LaunchProposalEvent = + IdlEvents["LaunchProposalEvent"]; +export type v0_6_0_FinalizeProposalEvent = + IdlEvents["FinalizeProposalEvent"]; +export type v0_6_0_SpotSwapEvent = IdlEvents["SpotSwapEvent"]; +export type v0_6_0_ConditionalSwapEvent = + IdlEvents["ConditionalSwapEvent"]; +export type v0_6_0_ProvideLiquidityEvent = + IdlEvents["ProvideLiquidityEvent"]; +export type v0_6_0_WithdrawLiquidityEvent = + IdlEvents["WithdrawLiquidityEvent"]; +export type v0_6_0_FutarchyEvent = + | v0_6_0_CollectFeesEvent + | v0_6_0_InitializeDaoEvent + | v0_6_0_UpdateDaoEvent + | v0_6_0_InitializeProposalEvent + | v0_6_0_StakeToProposalEvent + | v0_6_0_UnstakeFromProposalEvent + | v0_6_0_LaunchProposalEvent + | v0_6_0_FinalizeProposalEvent + | v0_6_0_SpotSwapEvent + | v0_6_0_ConditionalSwapEvent + | v0_6_0_ProvideLiquidityEvent + | v0_6_0_WithdrawLiquidityEvent; diff --git a/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts b/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts new file mode 100644 index 000000000..210888785 --- /dev/null +++ b/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts @@ -0,0 +1,5133 @@ +export type Futarchy = { + version: "0.6.0"; + name: "futarchy"; + instructions: [ + { + name: "initializeDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "daoCreator"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "InitializeDaoParams"; + }; + }, + ]; + }, + { + name: "initializeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "proposer"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "stakeToProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "stakerBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposalBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "stakeAccount"; + isMut: true; + isSigner: false; + }, + { + name: "staker"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "StakeToProposalParams"; + }; + }, + ]; + }, + { + name: "unstakeFromProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "stakerBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "proposalBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "stakeAccount"; + isMut: true; + isSigner: false; + }, + { + name: "staker"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "UnstakeFromProposalParams"; + }; + }, + ]; + }, + { + name: "launchProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: false; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: false; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: false; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "finalizeProposal"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "question"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "vaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "updateDao"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "daoParams"; + type: { + defined: "UpdateDaoParams"; + }; + }, + ]; + }, + { + name: "spotSwap"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "userBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "user"; + isMut: false; + isSigner: true; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "SpotSwapParams"; + }; + }, + ]; + }, + { + name: "conditionalSwap"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "proposal"; + isMut: false; + isSigner: false; + }, + { + name: "ammPassBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPassQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammFailQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "trader"; + isMut: false; + isSigner: true; + }, + { + name: "userInputAccount"; + isMut: true; + isSigner: false; + }, + { + name: "userOutputAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "quoteVaultUnderlyingTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "passBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "failBaseMint"; + isMut: true; + isSigner: false; + }, + { + name: "passQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "failQuoteMint"; + isMut: true; + isSigner: false; + }, + { + name: "conditionalVaultProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "question"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ConditionalSwapParams"; + }; + }, + ]; + }, + { + name: "provideLiquidity"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProvider"; + isMut: false; + isSigner: true; + }, + { + name: "liquidityProviderBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProviderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPosition"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "ProvideLiquidityParams"; + }; + }, + ]; + }, + { + name: "withdrawLiquidity"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "positionAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "liquidityProviderBaseAccount"; + isMut: true; + isSigner: false; + }, + { + name: "liquidityProviderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammPosition"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "params"; + type: { + defined: "WithdrawLiquidityParams"; + }; + }, + ]; + }, + { + name: "collectFees"; + accounts: [ + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "admin"; + isMut: false; + isSigner: true; + }, + { + name: "baseTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "quoteTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "ammBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "ammQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "executeSpendingLimitChange"; + accounts: [ + { + name: "proposal"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsProposal"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsMultisigProgram"; + isMut: false; + isSigner: false; + }, + { + name: "vaultTransaction"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "ammPosition"; + type: { + kind: "struct"; + fields: [ + { + name: "dao"; + type: "publicKey"; + }, + { + name: "positionAuthority"; + type: "publicKey"; + }, + { + name: "liquidity"; + type: "u128"; + }, + ]; + }; + }, + { + name: "dao"; + type: { + kind: "struct"; + fields: [ + { + name: "amm"; + docs: ["Embedded FutarchyAmm - 1:1 relationship"]; + type: { + defined: "FutarchyAmm"; + }; + }, + { + name: "nonce"; + docs: ["`nonce` + `dao_creator` are PDA seeds"]; + type: "u64"; + }, + { + name: "daoCreator"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "proposalCount"; + type: "u32"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "twapInitialObservation"; + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ]; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ]; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ]; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ]; + type: "u64"; + }, + { + name: "seqNum"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + ]; + }; + }, + { + name: "proposal"; + type: { + kind: "struct"; + fields: [ + { + name: "number"; + type: "u32"; + }, + { + name: "proposer"; + type: "publicKey"; + }, + { + name: "timestampEnqueued"; + type: "i64"; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + }, + { + name: "baseVault"; + type: "publicKey"; + }, + { + name: "quoteVault"; + type: "publicKey"; + }, + { + name: "dao"; + type: "publicKey"; + }, + { + name: "pdaBump"; + type: "u8"; + }, + { + name: "question"; + type: "publicKey"; + }, + { + name: "durationInSeconds"; + type: "u32"; + }, + { + name: "squadsProposal"; + type: "publicKey"; + }, + { + name: "passBaseMint"; + type: "publicKey"; + }, + { + name: "passQuoteMint"; + type: "publicKey"; + }, + { + name: "failBaseMint"; + type: "publicKey"; + }, + { + name: "failQuoteMint"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "stakeAccount"; + type: { + kind: "struct"; + fields: [ + { + name: "proposal"; + type: "publicKey"; + }, + { + name: "staker"; + type: "publicKey"; + }, + { + name: "amount"; + type: "u64"; + }, + { + name: "bump"; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "daoSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "ConditionalSwapParams"; + type: { + kind: "struct"; + fields: [ + { + name: "market"; + type: { + defined: "Market"; + }; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "minOutputAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitializeDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "twapInitialObservation"; + type: "u128"; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + }, + { + name: "twapStartDelaySeconds"; + type: "u32"; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + }, + { + name: "baseToStake"; + type: "u64"; + }, + { + name: "passThresholdBps"; + type: "u16"; + }, + { + name: "secondsPerProposal"; + type: "u32"; + }, + { + name: "nonce"; + type: "u64"; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + }, + ]; + }; + }, + { + name: "ProvideLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "quoteAmount"; + docs: ["How much quote token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "maxBaseAmount"; + docs: ["The maximum base token you will deposit to the pool"]; + type: "u64"; + }, + { + name: "minLiquidity"; + docs: ["The minimum liquidity you will be assigned"]; + type: "u128"; + }, + { + name: "positionAuthority"; + docs: [ + "The account that will own the LP position, usually the same as the", + "liquidity provider", + ]; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "SpotSwapParams"; + type: { + kind: "struct"; + fields: [ + { + name: "inputAmount"; + type: "u64"; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + }, + { + name: "minOutputAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "StakeToProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UnstakeFromProposalParams"; + type: { + kind: "struct"; + fields: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "UpdateDaoParams"; + type: { + kind: "struct"; + fields: [ + { + name: "passThresholdBps"; + type: { + option: "u16"; + }; + }, + { + name: "secondsPerProposal"; + type: { + option: "u32"; + }; + }, + { + name: "twapInitialObservation"; + type: { + option: "u128"; + }; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: { + option: "u128"; + }; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "minBaseFutarchicLiquidity"; + type: { + option: "u64"; + }; + }, + { + name: "baseToStake"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "WithdrawLiquidityParams"; + type: { + kind: "struct"; + fields: [ + { + name: "liquidityToWithdraw"; + docs: ["How much liquidity to withdraw"]; + type: "u128"; + }, + { + name: "minBaseAmount"; + docs: ["Minimum base tokens to receive"]; + type: "u64"; + }, + { + name: "minQuoteAmount"; + docs: ["Minimum quote tokens to receive"]; + type: "u64"; + }, + ]; + }; + }, + { + name: "InitialSpendingLimit"; + type: { + kind: "struct"; + fields: [ + { + name: "amountPerMonth"; + type: "u64"; + }, + { + name: "members"; + type: { + vec: "publicKey"; + }; + }, + ]; + }; + }, + { + name: "FutarchyAmm"; + type: { + kind: "struct"; + fields: [ + { + name: "state"; + type: { + defined: "PoolState"; + }; + }, + { + name: "totalLiquidity"; + type: "u128"; + }, + { + name: "baseMint"; + type: "publicKey"; + }, + { + name: "quoteMint"; + type: "publicKey"; + }, + { + name: "ammBaseVault"; + type: "publicKey"; + }, + { + name: "ammQuoteVault"; + type: "publicKey"; + }, + ]; + }; + }, + { + name: "TwapOracle"; + type: { + kind: "struct"; + fields: [ + { + name: "aggregator"; + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ]; + type: "u128"; + }, + { + name: "lastUpdatedTimestamp"; + type: "i64"; + }, + { + name: "createdAtTimestamp"; + type: "i64"; + }, + { + name: "lastPrice"; + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ]; + type: "u128"; + }, + { + name: "lastObservation"; + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ]; + type: "u128"; + }, + { + name: "maxObservationChangePerUpdate"; + docs: ["The most that an observation can change per update."]; + type: "u128"; + }, + { + name: "initialObservation"; + docs: ["What the initial `latest_observation` is set to."]; + type: "u128"; + }, + { + name: "startDelaySeconds"; + docs: [ + "Number of seconds after amm.created_at_slot to start recording TWAP", + ]; + type: "u32"; + }, + ]; + }; + }, + { + name: "Pool"; + type: { + kind: "struct"; + fields: [ + { + name: "oracle"; + type: { + defined: "TwapOracle"; + }; + }, + { + name: "quoteReserves"; + type: "u64"; + }, + { + name: "baseReserves"; + type: "u64"; + }, + { + name: "quoteProtocolFeeBalance"; + type: "u64"; + }, + { + name: "baseProtocolFeeBalance"; + type: "u64"; + }, + ]; + }; + }, + { + name: "PoolState"; + type: { + kind: "enum"; + variants: [ + { + name: "Spot"; + fields: [ + { + name: "spot"; + type: { + defined: "Pool"; + }; + }, + ]; + }, + { + name: "Futarchy"; + fields: [ + { + name: "spot"; + type: { + defined: "Pool"; + }; + }, + { + name: "pass"; + type: { + defined: "Pool"; + }; + }, + { + name: "fail"; + type: { + defined: "Pool"; + }; + }, + ]; + }, + ]; + }; + }, + { + name: "Market"; + type: { + kind: "enum"; + variants: [ + { + name: "Spot"; + }, + { + name: "Pass"; + }, + { + name: "Fail"; + }, + ]; + }; + }, + { + name: "SwapType"; + type: { + kind: "enum"; + variants: [ + { + name: "Buy"; + }, + { + name: "Sell"; + }, + ]; + }; + }, + { + name: "Token"; + type: { + kind: "enum"; + variants: [ + { + name: "Base"; + }, + { + name: "Quote"; + }, + ]; + }; + }, + { + name: "ProposalState"; + type: { + kind: "enum"; + variants: [ + { + name: "Draft"; + fields: [ + { + name: "amountStaked"; + type: "u64"; + }, + ]; + }, + { + name: "Pending"; + }, + { + name: "Passed"; + }, + { + name: "Failed"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "CollectFeesEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "baseTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "quoteTokenAccount"; + type: "publicKey"; + index: false; + }, + { + name: "ammBaseVault"; + type: "publicKey"; + index: false; + }, + { + name: "ammQuoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteFeesCollected"; + type: "u64"; + index: false; + }, + { + name: "baseFeesCollected"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "InitializeDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "secondsPerProposal"; + type: "u32"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "baseToStake"; + type: "u64"; + index: false; + }, + { + name: "initialSpendingLimit"; + type: { + option: { + defined: "InitialSpendingLimit"; + }; + }; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "UpdateDaoEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passThresholdBps"; + type: "u16"; + index: false; + }, + { + name: "secondsPerProposal"; + type: "u32"; + index: false; + }, + { + name: "twapInitialObservation"; + type: "u128"; + index: false; + }, + { + name: "twapMaxObservationChangePerUpdate"; + type: "u128"; + index: false; + }, + { + name: "minQuoteFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "minBaseFutarchicLiquidity"; + type: "u64"; + index: false; + }, + { + name: "baseToStake"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "InitializeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "question"; + type: "publicKey"; + index: false; + }, + { + name: "quoteVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseVault"; + type: "publicKey"; + index: false; + }, + { + name: "proposer"; + type: "publicKey"; + index: false; + }, + { + name: "number"; + type: "u32"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "durationInSeconds"; + type: "u32"; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisigVault"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "StakeToProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "staker"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "UnstakeFromProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "staker"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "totalStaked"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "FinalizeProposalEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "passMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "failMarketTwap"; + type: "u128"; + index: false; + }, + { + name: "threshold"; + type: "u128"; + index: false; + }, + { + name: "state"; + type: { + defined: "ProposalState"; + }; + index: false; + }, + { + name: "squadsProposal"; + type: "publicKey"; + index: false; + }, + { + name: "squadsMultisig"; + type: "publicKey"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "SpotSwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "user"; + type: "publicKey"; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "minOutputAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "ConditionalSwapEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "proposal"; + type: "publicKey"; + index: false; + }, + { + name: "trader"; + type: "publicKey"; + index: false; + }, + { + name: "market"; + type: { + defined: "Market"; + }; + index: false; + }, + { + name: "swapType"; + type: { + defined: "SwapType"; + }; + index: false; + }, + { + name: "inputAmount"; + type: "u64"; + index: false; + }, + { + name: "outputAmount"; + type: "u64"; + index: false; + }, + { + name: "minOutputAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "ProvideLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityProvider"; + type: "publicKey"; + index: false; + }, + { + name: "positionAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "liquidityMinted"; + type: "u128"; + index: false; + }, + { + name: "minLiquidity"; + type: "u128"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + { + name: "WithdrawLiquidityEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "dao"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityProvider"; + type: "publicKey"; + index: false; + }, + { + name: "liquidityWithdrawn"; + type: "u128"; + index: false; + }, + { + name: "minBaseAmount"; + type: "u64"; + index: false; + }, + { + name: "minQuoteAmount"; + type: "u64"; + index: false; + }, + { + name: "baseAmount"; + type: "u64"; + index: false; + }, + { + name: "quoteAmount"; + type: "u64"; + index: false; + }, + { + name: "postAmmState"; + type: { + defined: "FutarchyAmm"; + }; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "AmmTooOld"; + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; + }, + { + code: 6001; + name: "InvalidInitialObservation"; + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; + }, + { + code: 6002; + name: "InvalidMaxObservationChange"; + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; + }, + { + code: 6003; + name: "InvalidStartDelaySlots"; + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; + }, + { + code: 6004; + name: "InvalidSettlementAuthority"; + msg: "One of the vaults has an invalid `settlement_authority`"; + }, + { + code: 6005; + name: "ProposalTooYoung"; + msg: "Proposal is too young to be executed or rejected"; + }, + { + code: 6006; + name: "MarketsTooYoung"; + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; + }, + { + code: 6007; + name: "ProposalAlreadyFinalized"; + msg: "This proposal has already been finalized"; + }, + { + code: 6008; + name: "InvalidVaultNonce"; + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; + }, + { + code: 6009; + name: "ProposalNotPassed"; + msg: "This proposal can't be executed because it isn't in the passed state"; + }, + { + code: 6010; + name: "InsufficientLiquidity"; + msg: "More liquidity needs to be in the AMM to launch this proposal"; + }, + { + code: 6011; + name: "ProposalDurationTooShort"; + msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay"; + }, + { + code: 6012; + name: "PassThresholdTooHigh"; + msg: "Pass threshold must be less than 10%"; + }, + { + code: 6013; + name: "QuestionMustBeBinary"; + msg: "Question must have exactly 2 outcomes for binary futarchy"; + }, + { + code: 6014; + name: "InvalidSquadsProposalStatus"; + msg: "Squads proposal must be in Draft status"; + }, + { + code: 6015; + name: "CastingOverflow"; + msg: "Casting overflow. If you're seeing this, please report this"; + }, + { + code: 6016; + name: "InsufficientBalance"; + msg: "Insufficient balance"; + }, + { + code: 6017; + name: "ZeroLiquidityRemove"; + msg: "Cannot remove zero liquidity"; + }, + { + code: 6018; + name: "SwapSlippageExceeded"; + msg: "Swap slippage exceeded"; + }, + { + code: 6019; + name: "AssertFailed"; + msg: "Assert failed"; + }, + { + code: 6020; + name: "InvalidAdmin"; + msg: "Invalid admin"; + }, + { + code: 6021; + name: "ProposalNotInDraftState"; + msg: "Proposal is not in draft state"; + }, + { + code: 6022; + name: "InsufficientTokenBalance"; + msg: "Insufficient token balance"; + }, + { + code: 6023; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6024; + name: "InsufficientStakeToLaunch"; + msg: "Insufficient stake to launch proposal"; + }, + { + code: 6025; + name: "StakerNotFound"; + msg: "Staker not found in proposal"; + }, + { + code: 6026; + name: "PoolNotInSpotState"; + msg: "Pool must be in spot state"; + }, + { + code: 6027; + name: "InvalidDaoCreateLiquidity"; + msg: "If you're providing liquidity, you must provide both base and quote token accounts"; + }, + { + code: 6028; + name: "InvalidStakeAccount"; + msg: "Invalid stake account"; + }, + { + code: 6029; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6030; + name: "ProposalNotActive"; + msg: "Proposal needs to be active to perform a conditional swap"; + }, + { + code: 6031; + name: "InvalidTransaction"; + msg: "This Squads transaction should only contain calls to update spending limits"; + }, + ]; +}; + +export const IDL: Futarchy = { + version: "0.6.0", + name: "futarchy", + instructions: [ + { + name: "initializeDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "daoCreator", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "InitializeDaoParams", + }, + }, + ], + }, + { + name: "initializeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "proposer", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "stakeToProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "stakerBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposalBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "stakeAccount", + isMut: true, + isSigner: false, + }, + { + name: "staker", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "StakeToProposalParams", + }, + }, + ], + }, + { + name: "unstakeFromProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "stakerBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "proposalBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "stakeAccount", + isMut: true, + isSigner: false, + }, + { + name: "staker", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "UnstakeFromProposalParams", + }, + }, + ], + }, + { + name: "launchProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: false, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: false, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: false, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: false, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: false, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "finalizeProposal", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "question", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "vaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "updateDao", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "daoParams", + type: { + defined: "UpdateDaoParams", + }, + }, + ], + }, + { + name: "spotSwap", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "userBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "userQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "user", + isMut: false, + isSigner: true, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "SpotSwapParams", + }, + }, + ], + }, + { + name: "conditionalSwap", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "proposal", + isMut: false, + isSigner: false, + }, + { + name: "ammPassBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPassQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammFailQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "trader", + isMut: false, + isSigner: true, + }, + { + name: "userInputAccount", + isMut: true, + isSigner: false, + }, + { + name: "userOutputAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "quoteVaultUnderlyingTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "passBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "failBaseMint", + isMut: true, + isSigner: false, + }, + { + name: "passQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "failQuoteMint", + isMut: true, + isSigner: false, + }, + { + name: "conditionalVaultProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "question", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ConditionalSwapParams", + }, + }, + ], + }, + { + name: "provideLiquidity", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProvider", + isMut: false, + isSigner: true, + }, + { + name: "liquidityProviderBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProviderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPosition", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "ProvideLiquidityParams", + }, + }, + ], + }, + { + name: "withdrawLiquidity", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "positionAuthority", + isMut: false, + isSigner: true, + }, + { + name: "liquidityProviderBaseAccount", + isMut: true, + isSigner: false, + }, + { + name: "liquidityProviderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "ammPosition", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "params", + type: { + defined: "WithdrawLiquidityParams", + }, + }, + ], + }, + { + name: "collectFees", + accounts: [ + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "admin", + isMut: false, + isSigner: true, + }, + { + name: "baseTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "quoteTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "ammBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "ammQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "executeSpendingLimitChange", + accounts: [ + { + name: "proposal", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsProposal", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: false, + isSigner: false, + }, + { + name: "squadsMultisigProgram", + isMut: false, + isSigner: false, + }, + { + name: "vaultTransaction", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "ammPosition", + type: { + kind: "struct", + fields: [ + { + name: "dao", + type: "publicKey", + }, + { + name: "positionAuthority", + type: "publicKey", + }, + { + name: "liquidity", + type: "u128", + }, + ], + }, + }, + { + name: "dao", + type: { + kind: "struct", + fields: [ + { + name: "amm", + docs: ["Embedded FutarchyAmm - 1:1 relationship"], + type: { + defined: "FutarchyAmm", + }, + }, + { + name: "nonce", + docs: ["`nonce` + `dao_creator` are PDA seeds"], + type: "u64", + }, + { + name: "daoCreator", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "squadsMultisig", + type: "publicKey", + }, + { + name: "squadsMultisigVault", + type: "publicKey", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "proposalCount", + type: "u32", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "twapInitialObservation", + docs: [ + "For manipulation-resistance the TWAP is a time-weighted average observation,", + "where observation tries to approximate price but can only move by", + "`twap_max_observation_change_per_update` per update. Because it can only move", + "a little bit per update, you need to check that it has a good initial observation.", + "Otherwise, an attacker could create a very high initial observation in the pass", + "market and a very low one in the fail market to force the proposal to pass.", + "", + "We recommend setting an initial observation around the spot price of the token,", + "and max observation change per update around 2% the spot price of the token.", + "For example, if the spot price of META is $400, we'd recommend setting an initial", + "observation of 400 (converted into the AMM prices) and a max observation change per", + "update of 8 (also converted into the AMM prices). Observations can be updated once", + "a minute, so 2% allows the proposal market to reach double the spot price or 0", + "in 50 minutes.", + ], + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + docs: [ + "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", + ], + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + docs: [ + "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", + "in both futarchic markets in order to create a proposal.", + "", + "For example, for META, we can use a `min_quote_futarchic_liquidity` of", + "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", + "10 * 1_000_000_000 (10 META).", + ], + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + docs: [ + "Minimum amount of base tokens that must be staked to launch a proposal", + ], + type: "u64", + }, + { + name: "seqNum", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + ], + }, + }, + { + name: "proposal", + type: { + kind: "struct", + fields: [ + { + name: "number", + type: "u32", + }, + { + name: "proposer", + type: "publicKey", + }, + { + name: "timestampEnqueued", + type: "i64", + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + }, + { + name: "baseVault", + type: "publicKey", + }, + { + name: "quoteVault", + type: "publicKey", + }, + { + name: "dao", + type: "publicKey", + }, + { + name: "pdaBump", + type: "u8", + }, + { + name: "question", + type: "publicKey", + }, + { + name: "durationInSeconds", + type: "u32", + }, + { + name: "squadsProposal", + type: "publicKey", + }, + { + name: "passBaseMint", + type: "publicKey", + }, + { + name: "passQuoteMint", + type: "publicKey", + }, + { + name: "failBaseMint", + type: "publicKey", + }, + { + name: "failQuoteMint", + type: "publicKey", + }, + ], + }, + }, + { + name: "stakeAccount", + type: { + kind: "struct", + fields: [ + { + name: "proposal", + type: "publicKey", + }, + { + name: "staker", + type: "publicKey", + }, + { + name: "amount", + type: "u64", + }, + { + name: "bump", + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "daoSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "ConditionalSwapParams", + type: { + kind: "struct", + fields: [ + { + name: "market", + type: { + defined: "Market", + }, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "inputAmount", + type: "u64", + }, + { + name: "minOutputAmount", + type: "u64", + }, + ], + }, + }, + { + name: "InitializeDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "twapInitialObservation", + type: "u128", + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + }, + { + name: "twapStartDelaySeconds", + type: "u32", + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + }, + { + name: "baseToStake", + type: "u64", + }, + { + name: "passThresholdBps", + type: "u16", + }, + { + name: "secondsPerProposal", + type: "u32", + }, + { + name: "nonce", + type: "u64", + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + }, + ], + }, + }, + { + name: "ProvideLiquidityParams", + type: { + kind: "struct", + fields: [ + { + name: "quoteAmount", + docs: ["How much quote token you will deposit to the pool"], + type: "u64", + }, + { + name: "maxBaseAmount", + docs: ["The maximum base token you will deposit to the pool"], + type: "u64", + }, + { + name: "minLiquidity", + docs: ["The minimum liquidity you will be assigned"], + type: "u128", + }, + { + name: "positionAuthority", + docs: [ + "The account that will own the LP position, usually the same as the", + "liquidity provider", + ], + type: "publicKey", + }, + ], + }, + }, + { + name: "SpotSwapParams", + type: { + kind: "struct", + fields: [ + { + name: "inputAmount", + type: "u64", + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + }, + { + name: "minOutputAmount", + type: "u64", + }, + ], + }, + }, + { + name: "StakeToProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "UnstakeFromProposalParams", + type: { + kind: "struct", + fields: [ + { + name: "amount", + type: "u64", + }, + ], + }, + }, + { + name: "UpdateDaoParams", + type: { + kind: "struct", + fields: [ + { + name: "passThresholdBps", + type: { + option: "u16", + }, + }, + { + name: "secondsPerProposal", + type: { + option: "u32", + }, + }, + { + name: "twapInitialObservation", + type: { + option: "u128", + }, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: { + option: "u128", + }, + }, + { + name: "minQuoteFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "minBaseFutarchicLiquidity", + type: { + option: "u64", + }, + }, + { + name: "baseToStake", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "WithdrawLiquidityParams", + type: { + kind: "struct", + fields: [ + { + name: "liquidityToWithdraw", + docs: ["How much liquidity to withdraw"], + type: "u128", + }, + { + name: "minBaseAmount", + docs: ["Minimum base tokens to receive"], + type: "u64", + }, + { + name: "minQuoteAmount", + docs: ["Minimum quote tokens to receive"], + type: "u64", + }, + ], + }, + }, + { + name: "InitialSpendingLimit", + type: { + kind: "struct", + fields: [ + { + name: "amountPerMonth", + type: "u64", + }, + { + name: "members", + type: { + vec: "publicKey", + }, + }, + ], + }, + }, + { + name: "FutarchyAmm", + type: { + kind: "struct", + fields: [ + { + name: "state", + type: { + defined: "PoolState", + }, + }, + { + name: "totalLiquidity", + type: "u128", + }, + { + name: "baseMint", + type: "publicKey", + }, + { + name: "quoteMint", + type: "publicKey", + }, + { + name: "ammBaseVault", + type: "publicKey", + }, + { + name: "ammQuoteVault", + type: "publicKey", + }, + ], + }, + }, + { + name: "TwapOracle", + type: { + kind: "struct", + fields: [ + { + name: "aggregator", + docs: [ + "Running sum of slots_per_last_update * last_observation.", + "", + "Assuming latest observations are as big as possible (u64::MAX * 1e12),", + "we can store 18 million slots worth of observations, which turns out to", + "be ~85 days worth of slots.", + "", + "Assuming that latest observations are 100x smaller than they could theoretically", + "be, we can store 8500 days (23 years) worth of them. Even this is a very", + "very conservative assumption - META/USDC prices should be between 1e9 and", + "1e15, which would overflow after 1e15 years worth of slots.", + "", + "So in the case of an overflow, the aggregator rolls back to 0. It's the", + "client's responsibility to sanity check the assets or to handle an", + "aggregator at T2 being smaller than an aggregator at T1.", + ], + type: "u128", + }, + { + name: "lastUpdatedTimestamp", + type: "i64", + }, + { + name: "createdAtTimestamp", + type: "i64", + }, + { + name: "lastPrice", + docs: [ + "A price is the number of quote units per base unit multiplied by 1e12.", + "You cannot simply divide by 1e12 to get a price you can display in the UI", + "because the base and quote decimals may be different. Instead, do:", + "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", + ], + type: "u128", + }, + { + name: "lastObservation", + docs: [ + "If we did a raw TWAP over prices, someone could push the TWAP heavily with", + "a few extremely large outliers. So we use observations, which can only move", + "by `max_observation_change_per_update` per update.", + ], + type: "u128", + }, + { + name: "maxObservationChangePerUpdate", + docs: ["The most that an observation can change per update."], + type: "u128", + }, + { + name: "initialObservation", + docs: ["What the initial `latest_observation` is set to."], + type: "u128", + }, + { + name: "startDelaySeconds", + docs: [ + "Number of seconds after amm.created_at_slot to start recording TWAP", + ], + type: "u32", + }, + ], + }, + }, + { + name: "Pool", + type: { + kind: "struct", + fields: [ + { + name: "oracle", + type: { + defined: "TwapOracle", + }, + }, + { + name: "quoteReserves", + type: "u64", + }, + { + name: "baseReserves", + type: "u64", + }, + { + name: "quoteProtocolFeeBalance", + type: "u64", + }, + { + name: "baseProtocolFeeBalance", + type: "u64", + }, + ], + }, + }, + { + name: "PoolState", + type: { + kind: "enum", + variants: [ + { + name: "Spot", + fields: [ + { + name: "spot", + type: { + defined: "Pool", + }, + }, + ], + }, + { + name: "Futarchy", + fields: [ + { + name: "spot", + type: { + defined: "Pool", + }, + }, + { + name: "pass", + type: { + defined: "Pool", + }, + }, + { + name: "fail", + type: { + defined: "Pool", + }, + }, + ], + }, + ], + }, + }, + { + name: "Market", + type: { + kind: "enum", + variants: [ + { + name: "Spot", + }, + { + name: "Pass", + }, + { + name: "Fail", + }, + ], + }, + }, + { + name: "SwapType", + type: { + kind: "enum", + variants: [ + { + name: "Buy", + }, + { + name: "Sell", + }, + ], + }, + }, + { + name: "Token", + type: { + kind: "enum", + variants: [ + { + name: "Base", + }, + { + name: "Quote", + }, + ], + }, + }, + { + name: "ProposalState", + type: { + kind: "enum", + variants: [ + { + name: "Draft", + fields: [ + { + name: "amountStaked", + type: "u64", + }, + ], + }, + { + name: "Pending", + }, + { + name: "Passed", + }, + { + name: "Failed", + }, + ], + }, + }, + ], + events: [ + { + name: "CollectFeesEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "baseTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "quoteTokenAccount", + type: "publicKey", + index: false, + }, + { + name: "ammBaseVault", + type: "publicKey", + index: false, + }, + { + name: "ammQuoteVault", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteFeesCollected", + type: "u64", + index: false, + }, + { + name: "baseFeesCollected", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "InitializeDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "secondsPerProposal", + type: "u32", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "baseToStake", + type: "u64", + index: false, + }, + { + name: "initialSpendingLimit", + type: { + option: { + defined: "InitialSpendingLimit", + }, + }, + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "UpdateDaoEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passThresholdBps", + type: "u16", + index: false, + }, + { + name: "secondsPerProposal", + type: "u32", + index: false, + }, + { + name: "twapInitialObservation", + type: "u128", + index: false, + }, + { + name: "twapMaxObservationChangePerUpdate", + type: "u128", + index: false, + }, + { + name: "minQuoteFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "minBaseFutarchicLiquidity", + type: "u64", + index: false, + }, + { + name: "baseToStake", + type: "u64", + index: false, + }, + ], + }, + { + name: "InitializeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "question", + type: "publicKey", + index: false, + }, + { + name: "quoteVault", + type: "publicKey", + index: false, + }, + { + name: "baseVault", + type: "publicKey", + index: false, + }, + { + name: "proposer", + type: "publicKey", + index: false, + }, + { + name: "number", + type: "u32", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "durationInSeconds", + type: "u32", + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisigVault", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "StakeToProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "staker", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + ], + }, + { + name: "UnstakeFromProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "staker", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "totalStaked", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "FinalizeProposalEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "passMarketTwap", + type: "u128", + index: false, + }, + { + name: "failMarketTwap", + type: "u128", + index: false, + }, + { + name: "threshold", + type: "u128", + index: false, + }, + { + name: "state", + type: { + defined: "ProposalState", + }, + index: false, + }, + { + name: "squadsProposal", + type: "publicKey", + index: false, + }, + { + name: "squadsMultisig", + type: "publicKey", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "SpotSwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "user", + type: "publicKey", + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "minOutputAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "ConditionalSwapEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "proposal", + type: "publicKey", + index: false, + }, + { + name: "trader", + type: "publicKey", + index: false, + }, + { + name: "market", + type: { + defined: "Market", + }, + index: false, + }, + { + name: "swapType", + type: { + defined: "SwapType", + }, + index: false, + }, + { + name: "inputAmount", + type: "u64", + index: false, + }, + { + name: "outputAmount", + type: "u64", + index: false, + }, + { + name: "minOutputAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "ProvideLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "liquidityProvider", + type: "publicKey", + index: false, + }, + { + name: "positionAuthority", + type: "publicKey", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "liquidityMinted", + type: "u128", + index: false, + }, + { + name: "minLiquidity", + type: "u128", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + { + name: "WithdrawLiquidityEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "dao", + type: "publicKey", + index: false, + }, + { + name: "liquidityProvider", + type: "publicKey", + index: false, + }, + { + name: "liquidityWithdrawn", + type: "u128", + index: false, + }, + { + name: "minBaseAmount", + type: "u64", + index: false, + }, + { + name: "minQuoteAmount", + type: "u64", + index: false, + }, + { + name: "baseAmount", + type: "u64", + index: false, + }, + { + name: "quoteAmount", + type: "u64", + index: false, + }, + { + name: "postAmmState", + type: { + defined: "FutarchyAmm", + }, + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "AmmTooOld", + msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", + }, + { + code: 6001, + name: "InvalidInitialObservation", + msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", + }, + { + code: 6002, + name: "InvalidMaxObservationChange", + msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", + }, + { + code: 6003, + name: "InvalidStartDelaySlots", + msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", + }, + { + code: 6004, + name: "InvalidSettlementAuthority", + msg: "One of the vaults has an invalid `settlement_authority`", + }, + { + code: 6005, + name: "ProposalTooYoung", + msg: "Proposal is too young to be executed or rejected", + }, + { + code: 6006, + name: "MarketsTooYoung", + msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", + }, + { + code: 6007, + name: "ProposalAlreadyFinalized", + msg: "This proposal has already been finalized", + }, + { + code: 6008, + name: "InvalidVaultNonce", + msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", + }, + { + code: 6009, + name: "ProposalNotPassed", + msg: "This proposal can't be executed because it isn't in the passed state", + }, + { + code: 6010, + name: "InsufficientLiquidity", + msg: "More liquidity needs to be in the AMM to launch this proposal", + }, + { + code: 6011, + name: "ProposalDurationTooShort", + msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay", + }, + { + code: 6012, + name: "PassThresholdTooHigh", + msg: "Pass threshold must be less than 10%", + }, + { + code: 6013, + name: "QuestionMustBeBinary", + msg: "Question must have exactly 2 outcomes for binary futarchy", + }, + { + code: 6014, + name: "InvalidSquadsProposalStatus", + msg: "Squads proposal must be in Draft status", + }, + { + code: 6015, + name: "CastingOverflow", + msg: "Casting overflow. If you're seeing this, please report this", + }, + { + code: 6016, + name: "InsufficientBalance", + msg: "Insufficient balance", + }, + { + code: 6017, + name: "ZeroLiquidityRemove", + msg: "Cannot remove zero liquidity", + }, + { + code: 6018, + name: "SwapSlippageExceeded", + msg: "Swap slippage exceeded", + }, + { + code: 6019, + name: "AssertFailed", + msg: "Assert failed", + }, + { + code: 6020, + name: "InvalidAdmin", + msg: "Invalid admin", + }, + { + code: 6021, + name: "ProposalNotInDraftState", + msg: "Proposal is not in draft state", + }, + { + code: 6022, + name: "InsufficientTokenBalance", + msg: "Insufficient token balance", + }, + { + code: 6023, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6024, + name: "InsufficientStakeToLaunch", + msg: "Insufficient stake to launch proposal", + }, + { + code: 6025, + name: "StakerNotFound", + msg: "Staker not found in proposal", + }, + { + code: 6026, + name: "PoolNotInSpotState", + msg: "Pool must be in spot state", + }, + { + code: 6027, + name: "InvalidDaoCreateLiquidity", + msg: "If you're providing liquidity, you must provide both base and quote token accounts", + }, + { + code: 6028, + name: "InvalidStakeAccount", + msg: "Invalid stake account", + }, + { + code: 6029, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6030, + name: "ProposalNotActive", + msg: "Proposal needs to be active to perform a conditional swap", + }, + { + code: 6031, + name: "InvalidTransaction", + msg: "This Squads transaction should only contain calls to update spending limits", + }, + ], +}; diff --git a/sdk2/src/launchpad/index.ts b/sdk2/src/launchpad/index.ts index 6b187d27b..41f4ed086 100644 --- a/sdk2/src/launchpad/index.ts +++ b/sdk2/src/launchpad/index.ts @@ -1 +1,14 @@ export * from "./v0.7/index.js"; + +export { + v0_6_0_Launchpad, + v0_6_0_LaunchpadIDL, + v0_6_0_LaunchClaimEvent, + v0_6_0_LaunchCompletedEvent, + v0_6_0_LaunchFundedEvent, + v0_6_0_LaunchInitializedEvent, + v0_6_0_LaunchRefundedEvent, + v0_6_0_LaunchStartedEvent, + v0_6_0_LaunchCloseEvent, + v0_6_0_LaunchpadEvent, +} from "./v0.6/index.js"; diff --git a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts index 096e7248f..173b66e49 100644 --- a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts +++ b/sdk2/src/launchpad/v0.6/LaunchpadClient.ts @@ -4,7 +4,7 @@ import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; import { Launchpad as v0_6_0_launchpad, IDL as v0_6_0_launchpadIDL, -} from "./types/launchpad.js"; +} from "./types/v0.6.0-launchpad.js"; import { LAUNCHPAD_V0_6_PROGRAM_ID, MPL_TOKEN_METADATA_PROGRAM_ID, diff --git a/sdk2/src/launchpad/v0.6/types/index.ts b/sdk2/src/launchpad/v0.6/types/index.ts index 40606022c..2e0337f75 100644 --- a/sdk2/src/launchpad/v0.6/types/index.ts +++ b/sdk2/src/launchpad/v0.6/types/index.ts @@ -5,6 +5,12 @@ import { } from "./launchpad.js"; export { LaunchpadProgram, LaunchpadIDL }; +import { + Launchpad as v0_6_0_Launchpad, + IDL as v0_6_0_LaunchpadIDL, +} from "./v0.6.0-launchpad.js"; +export { v0_6_0_Launchpad, v0_6_0_LaunchpadIDL }; + export type Launch = IdlAccounts["launch"]; export type FundingRecord = IdlAccounts["fundingRecord"]; @@ -28,3 +34,26 @@ export type LaunchpadEvent = | LaunchRefundedEvent | LaunchStartedEvent | LaunchCloseEvent; + +export type v0_6_0_LaunchClaimEvent = + IdlEvents["LaunchClaimEvent"]; +export type v0_6_0_LaunchCompletedEvent = + IdlEvents["LaunchCompletedEvent"]; +export type v0_6_0_LaunchFundedEvent = + IdlEvents["LaunchFundedEvent"]; +export type v0_6_0_LaunchInitializedEvent = + IdlEvents["LaunchInitializedEvent"]; +export type v0_6_0_LaunchRefundedEvent = + IdlEvents["LaunchRefundedEvent"]; +export type v0_6_0_LaunchStartedEvent = + IdlEvents["LaunchStartedEvent"]; +export type v0_6_0_LaunchCloseEvent = + IdlEvents["LaunchCloseEvent"]; +export type v0_6_0_LaunchpadEvent = + | v0_6_0_LaunchClaimEvent + | v0_6_0_LaunchCompletedEvent + | v0_6_0_LaunchFundedEvent + | v0_6_0_LaunchInitializedEvent + | v0_6_0_LaunchRefundedEvent + | v0_6_0_LaunchStartedEvent + | v0_6_0_LaunchCloseEvent; diff --git a/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts b/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts new file mode 100644 index 000000000..828949a83 --- /dev/null +++ b/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts @@ -0,0 +1,2553 @@ +export type Launchpad = { + version: "0.6.0"; + name: "launchpad"; + instructions: [ + { + name: "initializeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "quoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "baseVault"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "rent"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "InitializeLaunchArgs"; + }; + }, + ]; + }, + { + name: "startLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "fund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: true; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + { + name: "completeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "launchAuthority"; + isMut: false; + isSigner: true; + isOptional: true; + }, + { + name: "tokenMetadata"; + isMut: true; + isSigner: false; + }, + { + name: "payer"; + isMut: true; + isSigner: true; + }, + { + name: "launchSigner"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "treasuryQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "daoOwnedLpPosition"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "futarchyAmmQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "dao"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisig"; + isMut: true; + isSigner: false; + }, + { + name: "squadsMultisigVault"; + isMut: false; + isSigner: false; + }, + { + name: "spendingLimit"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackage"; + isMut: true; + isSigner: false; + }, + { + name: "performancePackageTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "associatedTokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "staticAccounts"; + accounts: [ + { + name: "futarchyProgram"; + isMut: false; + isSigner: false; + }, + { + name: "tokenMetadataProgram"; + isMut: false; + isSigner: false; + }, + { + name: "autocratEventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgram"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfig"; + isMut: false; + isSigner: false; + }, + { + name: "squadsProgramConfigTreasury"; + isMut: true; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageProgram"; + isMut: false; + isSigner: false; + }, + { + name: "priceBasedPerformancePackageEventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "meteoraAccounts"; + accounts: [ + { + name: "dammV2Program"; + isMut: false; + isSigner: false; + }, + { + name: "config"; + isMut: false; + isSigner: false; + }, + { + name: "token2022Program"; + isMut: false; + isSigner: false; + }, + { + name: "positionNftAccount"; + isMut: true; + isSigner: false; + }, + { + name: "pool"; + isMut: true; + isSigner: false; + }, + { + name: "position"; + isMut: true; + isSigner: false; + }, + { + name: "positionNftMint"; + isMut: true; + isSigner: false; + }, + { + name: "baseMint"; + isMut: false; + isSigner: false; + }, + { + name: "quoteMint"; + isMut: false; + isSigner: false; + }, + { + name: "tokenAVault"; + isMut: true; + isSigner: false; + }, + { + name: "tokenBVault"; + isMut: true; + isSigner: false; + }, + { + name: "poolCreatorAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "poolAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "dammV2EventAuthority"; + isMut: false; + isSigner: false; + }, + ]; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: [ + { + name: "args"; + type: { + defined: "CompleteLaunchArgs"; + }; + }, + ]; + }, + { + name: "refund"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchQuoteVault"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderQuoteAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "claim"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "fundingRecord"; + isMut: true; + isSigner: false; + }, + { + name: "launchSigner"; + isMut: false; + isSigner: false; + }, + { + name: "baseMint"; + isMut: true; + isSigner: false; + }, + { + name: "launchBaseVault"; + isMut: true; + isSigner: false; + }, + { + name: "funder"; + isMut: false; + isSigner: false; + }, + { + name: "funderTokenAccount"; + isMut: true; + isSigner: false; + }, + { + name: "tokenProgram"; + isMut: false; + isSigner: false; + }, + { + name: "systemProgram"; + isMut: false; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + { + name: "closeLaunch"; + accounts: [ + { + name: "launch"; + isMut: true; + isSigner: false; + }, + { + name: "eventAuthority"; + isMut: false; + isSigner: false; + }, + { + name: "program"; + isMut: false; + isSigner: false; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: "fundingRecord"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "funder"; + docs: ["The funder."]; + type: "publicKey"; + }, + { + name: "launch"; + docs: ["The launch."]; + type: "publicKey"; + }, + { + name: "committedAmount"; + docs: ["The amount of USDC that has been committed by the funder."]; + type: "u64"; + }, + { + name: "isTokensClaimed"; + docs: ["Whether the tokens have been claimed."]; + type: "bool"; + }, + { + name: "isUsdcRefunded"; + docs: ["Whether the USDC has been refunded."]; + type: "bool"; + }, + ]; + }; + }, + { + name: "launch"; + type: { + kind: "struct"; + fields: [ + { + name: "pdaBump"; + docs: ["The PDA bump."]; + type: "u8"; + }, + { + name: "minimumRaiseAmount"; + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ]; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + docs: [ + "The wallets that have access to the monthly spending limit.", + ]; + type: { + vec: "publicKey"; + }; + }, + { + name: "launchAuthority"; + docs: ["The account that can start the launch."]; + type: "publicKey"; + }, + { + name: "launchSigner"; + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ]; + type: "publicKey"; + }, + { + name: "launchSignerPdaBump"; + docs: ["The PDA bump for the launch signer."]; + type: "u8"; + }, + { + name: "launchQuoteVault"; + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ]; + type: "publicKey"; + }, + { + name: "launchBaseVault"; + docs: ["The token vault, used to send tokens to Raydium."]; + type: "publicKey"; + }, + { + name: "baseMint"; + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ]; + type: "publicKey"; + }, + { + name: "quoteMint"; + docs: ["The USDC mint."]; + type: "publicKey"; + }, + { + name: "unixTimestampStarted"; + docs: ["The unix timestamp when the launch was started."]; + type: { + option: "i64"; + }; + }, + { + name: "unixTimestampClosed"; + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ]; + type: { + option: "i64"; + }; + }, + { + name: "totalCommittedAmount"; + docs: ["The amount of USDC that has been committed by the users."]; + type: "u64"; + }, + { + name: "finalRaiseAmount"; + docs: ["The final raise amount."]; + type: { + option: "u64"; + }; + }, + { + name: "state"; + docs: ["The state of the launch."]; + type: { + defined: "LaunchState"; + }; + }, + { + name: "seqNum"; + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ]; + type: "u64"; + }, + { + name: "secondsForLaunch"; + docs: ["The number of seconds that the launch will be live for."]; + type: "u32"; + }, + { + name: "dao"; + docs: ["The DAO, if the launch is complete."]; + type: { + option: "publicKey"; + }; + }, + { + name: "daoVault"; + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ]; + type: { + option: "publicKey"; + }; + }, + { + name: "performancePackageGrantee"; + docs: [ + "The address that will receive the performance package tokens.", + ]; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ]; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ]; + type: "u8"; + }, + ]; + }; + }, + ]; + types: [ + { + name: "CommonFields"; + type: { + kind: "struct"; + fields: [ + { + name: "slot"; + type: "u64"; + }, + { + name: "unixTimestamp"; + type: "i64"; + }, + { + name: "launchSeqNum"; + type: "u64"; + }, + ]; + }; + }, + { + name: "CompleteLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "finalRaiseAmount"; + type: { + option: "u64"; + }; + }, + ]; + }; + }, + { + name: "InitializeLaunchArgs"; + type: { + kind: "struct"; + fields: [ + { + name: "minimumRaiseAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitAmount"; + type: "u64"; + }, + { + name: "monthlySpendingLimitMembers"; + type: { + vec: "publicKey"; + }; + }, + { + name: "secondsForLaunch"; + type: "u32"; + }, + { + name: "tokenName"; + type: "string"; + }, + { + name: "tokenSymbol"; + type: "string"; + }, + { + name: "tokenUri"; + type: "string"; + }, + { + name: "performancePackageGrantee"; + type: "publicKey"; + }, + { + name: "performancePackageTokenAmount"; + type: "u64"; + }, + { + name: "monthsUntilInsidersCanUnlock"; + type: "u8"; + }, + ]; + }; + }, + { + name: "LaunchState"; + type: { + kind: "enum"; + variants: [ + { + name: "Initialized"; + }, + { + name: "Live"; + }, + { + name: "Closed"; + }, + { + name: "Complete"; + }, + { + name: "Refunding"; + }, + ]; + }; + }, + ]; + events: [ + { + name: "LaunchInitializedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "minimumRaiseAmount"; + type: "u64"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "launchSigner"; + type: "publicKey"; + index: false; + }, + { + name: "launchSignerPdaBump"; + type: "u8"; + index: false; + }, + { + name: "launchUsdcVault"; + type: "publicKey"; + index: false; + }, + { + name: "launchTokenVault"; + type: "publicKey"; + index: false; + }, + { + name: "baseMint"; + type: "publicKey"; + index: false; + }, + { + name: "quoteMint"; + type: "publicKey"; + index: false; + }, + { + name: "pdaBump"; + type: "u8"; + index: false; + }, + { + name: "secondsForLaunch"; + type: "u32"; + index: false; + }, + ]; + }, + { + name: "LaunchStartedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "launchAuthority"; + type: "publicKey"; + index: false; + }, + { + name: "slotStarted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchFundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "amount"; + type: "u64"; + index: false; + }, + { + name: "totalCommittedByFunder"; + type: "u64"; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + ]; + }, + { + name: "LaunchCompletedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "finalState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + { + name: "totalCommitted"; + type: "u64"; + index: false; + }, + { + name: "dao"; + type: { + option: "publicKey"; + }; + index: false; + }, + { + name: "daoTreasury"; + type: { + option: "publicKey"; + }; + index: false; + }, + ]; + }, + { + name: "LaunchRefundedEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "usdcRefunded"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchClaimEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "funder"; + type: "publicKey"; + index: false; + }, + { + name: "tokensClaimed"; + type: "u64"; + index: false; + }, + { + name: "fundingRecord"; + type: "publicKey"; + index: false; + }, + ]; + }, + { + name: "LaunchCloseEvent"; + fields: [ + { + name: "common"; + type: { + defined: "CommonFields"; + }; + index: false; + }, + { + name: "launch"; + type: "publicKey"; + index: false; + }, + { + name: "newState"; + type: { + defined: "LaunchState"; + }; + index: false; + }, + ]; + }, + ]; + errors: [ + { + code: 6000; + name: "InvalidAmount"; + msg: "Invalid amount"; + }, + { + code: 6001; + name: "SupplyNonZero"; + msg: "Supply must be zero"; + }, + { + code: 6002; + name: "InvalidSecondsForLaunch"; + msg: "Launch period must be between 1 hour and 2 weeks"; + }, + { + code: 6003; + name: "InsufficientFunds"; + msg: "Insufficient funds"; + }, + { + code: 6004; + name: "InvalidTokenKey"; + msg: "Token mint key must end in 'meta'"; + }, + { + code: 6005; + name: "InvalidLaunchState"; + msg: "Invalid launch state"; + }, + { + code: 6006; + name: "LaunchPeriodNotOver"; + msg: "Launch period not over"; + }, + { + code: 6007; + name: "LaunchExpired"; + msg: "Launch is complete, no more funding allowed"; + }, + { + code: 6008; + name: "LaunchNotRefunding"; + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; + }, + { + code: 6009; + name: "LaunchNotInitialized"; + msg: "Launch must be initialized to be started"; + }, + { + code: 6010; + name: "FreezeAuthoritySet"; + msg: "Freeze authority can't be set on launchpad tokens"; + }, + { + code: 6011; + name: "InvalidMonthlySpendingLimit"; + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; + }, + { + code: 6012; + name: "InvalidMonthlySpendingLimitMembers"; + msg: "There can only be at most 10 monthly spending limit members"; + }, + { + code: 6013; + name: "InvalidPriceBasedPremineAmount"; + msg: "Cannot do more than a 50% premine"; + }, + { + code: 6014; + name: "InvalidPerformancePackageMinUnlockTime"; + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; + }, + { + code: 6015; + name: "LaunchAuthorityNotSet"; + msg: "Launch authority must be set to complete the launch until 2 days after closing"; + }, + { + code: 6016; + name: "FinalRaiseAmountTooLow"; + msg: "The final amount raised must be greater than or equal to the minimum raise amount"; + }, + { + code: 6017; + name: "TokensAlreadyClaimed"; + msg: "Tokens already claimed"; + }, + { + code: 6018; + name: "MoneyAlreadyRefunded"; + msg: "Money already refunded"; + }, + { + code: 6019; + name: "InvariantViolated"; + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; + }, + { + code: 6020; + name: "LaunchNotLive"; + msg: "Launch must be live to be closed"; + }, + { + code: 6021; + name: "InvalidMinimumRaiseAmount"; + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; + }, + ]; +}; + +export const IDL: Launchpad = { + version: "0.6.0", + name: "launchpad", + instructions: [ + { + name: "initializeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "quoteVault", + isMut: true, + isSigner: false, + }, + { + name: "baseVault", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "rent", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "InitializeLaunchArgs", + }, + }, + ], + }, + { + name: "startLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "fund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: true, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "amount", + type: "u64", + }, + ], + }, + { + name: "completeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "launchAuthority", + isMut: false, + isSigner: true, + isOptional: true, + }, + { + name: "tokenMetadata", + isMut: true, + isSigner: false, + }, + { + name: "payer", + isMut: true, + isSigner: true, + }, + { + name: "launchSigner", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "treasuryQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "daoOwnedLpPosition", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "futarchyAmmQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "dao", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisig", + isMut: true, + isSigner: false, + }, + { + name: "squadsMultisigVault", + isMut: false, + isSigner: false, + }, + { + name: "spendingLimit", + isMut: true, + isSigner: false, + }, + { + name: "performancePackage", + isMut: true, + isSigner: false, + }, + { + name: "performancePackageTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "associatedTokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "staticAccounts", + accounts: [ + { + name: "futarchyProgram", + isMut: false, + isSigner: false, + }, + { + name: "tokenMetadataProgram", + isMut: false, + isSigner: false, + }, + { + name: "autocratEventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgram", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfig", + isMut: false, + isSigner: false, + }, + { + name: "squadsProgramConfigTreasury", + isMut: true, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageProgram", + isMut: false, + isSigner: false, + }, + { + name: "priceBasedPerformancePackageEventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "meteoraAccounts", + accounts: [ + { + name: "dammV2Program", + isMut: false, + isSigner: false, + }, + { + name: "config", + isMut: false, + isSigner: false, + }, + { + name: "token2022Program", + isMut: false, + isSigner: false, + }, + { + name: "positionNftAccount", + isMut: true, + isSigner: false, + }, + { + name: "pool", + isMut: true, + isSigner: false, + }, + { + name: "position", + isMut: true, + isSigner: false, + }, + { + name: "positionNftMint", + isMut: true, + isSigner: false, + }, + { + name: "baseMint", + isMut: false, + isSigner: false, + }, + { + name: "quoteMint", + isMut: false, + isSigner: false, + }, + { + name: "tokenAVault", + isMut: true, + isSigner: false, + }, + { + name: "tokenBVault", + isMut: true, + isSigner: false, + }, + { + name: "poolCreatorAuthority", + isMut: false, + isSigner: false, + }, + { + name: "poolAuthority", + isMut: false, + isSigner: false, + }, + { + name: "dammV2EventAuthority", + isMut: false, + isSigner: false, + }, + ], + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [ + { + name: "args", + type: { + defined: "CompleteLaunchArgs", + }, + }, + ], + }, + { + name: "refund", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchQuoteVault", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderQuoteAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "claim", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "fundingRecord", + isMut: true, + isSigner: false, + }, + { + name: "launchSigner", + isMut: false, + isSigner: false, + }, + { + name: "baseMint", + isMut: true, + isSigner: false, + }, + { + name: "launchBaseVault", + isMut: true, + isSigner: false, + }, + { + name: "funder", + isMut: false, + isSigner: false, + }, + { + name: "funderTokenAccount", + isMut: true, + isSigner: false, + }, + { + name: "tokenProgram", + isMut: false, + isSigner: false, + }, + { + name: "systemProgram", + isMut: false, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + { + name: "closeLaunch", + accounts: [ + { + name: "launch", + isMut: true, + isSigner: false, + }, + { + name: "eventAuthority", + isMut: false, + isSigner: false, + }, + { + name: "program", + isMut: false, + isSigner: false, + }, + ], + args: [], + }, + ], + accounts: [ + { + name: "fundingRecord", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "funder", + docs: ["The funder."], + type: "publicKey", + }, + { + name: "launch", + docs: ["The launch."], + type: "publicKey", + }, + { + name: "committedAmount", + docs: ["The amount of USDC that has been committed by the funder."], + type: "u64", + }, + { + name: "isTokensClaimed", + docs: ["Whether the tokens have been claimed."], + type: "bool", + }, + { + name: "isUsdcRefunded", + docs: ["Whether the USDC has been refunded."], + type: "bool", + }, + ], + }, + }, + { + name: "launch", + type: { + kind: "struct", + fields: [ + { + name: "pdaBump", + docs: ["The PDA bump."], + type: "u8", + }, + { + name: "minimumRaiseAmount", + docs: [ + "The minimum amount of USDC that must be raised, otherwise", + "everyone can get their USDC back.", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + docs: [ + "The monthly spending limit the DAO allocates to the team. Must be", + "less than 1/6th of the minimum raise amount (so 6 months of burn).", + ], + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + docs: [ + "The wallets that have access to the monthly spending limit.", + ], + type: { + vec: "publicKey", + }, + }, + { + name: "launchAuthority", + docs: ["The account that can start the launch."], + type: "publicKey", + }, + { + name: "launchSigner", + docs: [ + "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", + ], + type: "publicKey", + }, + { + name: "launchSignerPdaBump", + docs: ["The PDA bump for the launch signer."], + type: "u8", + }, + { + name: "launchQuoteVault", + docs: [ + "The USDC vault that will hold the USDC raised until the launch is over.", + ], + type: "publicKey", + }, + { + name: "launchBaseVault", + docs: ["The token vault, used to send tokens to Raydium."], + type: "publicKey", + }, + { + name: "baseMint", + docs: [ + "The token that will be minted to funders and that will control the DAO.", + ], + type: "publicKey", + }, + { + name: "quoteMint", + docs: ["The USDC mint."], + type: "publicKey", + }, + { + name: "unixTimestampStarted", + docs: ["The unix timestamp when the launch was started."], + type: { + option: "i64", + }, + }, + { + name: "unixTimestampClosed", + docs: [ + "The unix timestamp when the launch stopped taking new contributions.", + ], + type: { + option: "i64", + }, + }, + { + name: "totalCommittedAmount", + docs: ["The amount of USDC that has been committed by the users."], + type: "u64", + }, + { + name: "finalRaiseAmount", + docs: ["The final raise amount."], + type: { + option: "u64", + }, + }, + { + name: "state", + docs: ["The state of the launch."], + type: { + defined: "LaunchState", + }, + }, + { + name: "seqNum", + docs: [ + "The sequence number of this launch. Useful for sorting events.", + ], + type: "u64", + }, + { + name: "secondsForLaunch", + docs: ["The number of seconds that the launch will be live for."], + type: "u32", + }, + { + name: "dao", + docs: ["The DAO, if the launch is complete."], + type: { + option: "publicKey", + }, + }, + { + name: "daoVault", + docs: [ + "The DAO treasury that USDC / LP is sent to, if the launch is complete.", + ], + type: { + option: "publicKey", + }, + }, + { + name: "performancePackageGrantee", + docs: [ + "The address that will receive the performance package tokens.", + ], + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + docs: [ + "The amount of tokens to be granted to the performance package grantee.", + ], + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + docs: [ + "The number of months that insiders must wait before unlocking their tokens.", + ], + type: "u8", + }, + ], + }, + }, + ], + types: [ + { + name: "CommonFields", + type: { + kind: "struct", + fields: [ + { + name: "slot", + type: "u64", + }, + { + name: "unixTimestamp", + type: "i64", + }, + { + name: "launchSeqNum", + type: "u64", + }, + ], + }, + }, + { + name: "CompleteLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "finalRaiseAmount", + type: { + option: "u64", + }, + }, + ], + }, + }, + { + name: "InitializeLaunchArgs", + type: { + kind: "struct", + fields: [ + { + name: "minimumRaiseAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitAmount", + type: "u64", + }, + { + name: "monthlySpendingLimitMembers", + type: { + vec: "publicKey", + }, + }, + { + name: "secondsForLaunch", + type: "u32", + }, + { + name: "tokenName", + type: "string", + }, + { + name: "tokenSymbol", + type: "string", + }, + { + name: "tokenUri", + type: "string", + }, + { + name: "performancePackageGrantee", + type: "publicKey", + }, + { + name: "performancePackageTokenAmount", + type: "u64", + }, + { + name: "monthsUntilInsidersCanUnlock", + type: "u8", + }, + ], + }, + }, + { + name: "LaunchState", + type: { + kind: "enum", + variants: [ + { + name: "Initialized", + }, + { + name: "Live", + }, + { + name: "Closed", + }, + { + name: "Complete", + }, + { + name: "Refunding", + }, + ], + }, + }, + ], + events: [ + { + name: "LaunchInitializedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "minimumRaiseAmount", + type: "u64", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "launchSigner", + type: "publicKey", + index: false, + }, + { + name: "launchSignerPdaBump", + type: "u8", + index: false, + }, + { + name: "launchUsdcVault", + type: "publicKey", + index: false, + }, + { + name: "launchTokenVault", + type: "publicKey", + index: false, + }, + { + name: "baseMint", + type: "publicKey", + index: false, + }, + { + name: "quoteMint", + type: "publicKey", + index: false, + }, + { + name: "pdaBump", + type: "u8", + index: false, + }, + { + name: "secondsForLaunch", + type: "u32", + index: false, + }, + ], + }, + { + name: "LaunchStartedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "launchAuthority", + type: "publicKey", + index: false, + }, + { + name: "slotStarted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchFundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "amount", + type: "u64", + index: false, + }, + { + name: "totalCommittedByFunder", + type: "u64", + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + ], + }, + { + name: "LaunchCompletedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "finalState", + type: { + defined: "LaunchState", + }, + index: false, + }, + { + name: "totalCommitted", + type: "u64", + index: false, + }, + { + name: "dao", + type: { + option: "publicKey", + }, + index: false, + }, + { + name: "daoTreasury", + type: { + option: "publicKey", + }, + index: false, + }, + ], + }, + { + name: "LaunchRefundedEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "usdcRefunded", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchClaimEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "funder", + type: "publicKey", + index: false, + }, + { + name: "tokensClaimed", + type: "u64", + index: false, + }, + { + name: "fundingRecord", + type: "publicKey", + index: false, + }, + ], + }, + { + name: "LaunchCloseEvent", + fields: [ + { + name: "common", + type: { + defined: "CommonFields", + }, + index: false, + }, + { + name: "launch", + type: "publicKey", + index: false, + }, + { + name: "newState", + type: { + defined: "LaunchState", + }, + index: false, + }, + ], + }, + ], + errors: [ + { + code: 6000, + name: "InvalidAmount", + msg: "Invalid amount", + }, + { + code: 6001, + name: "SupplyNonZero", + msg: "Supply must be zero", + }, + { + code: 6002, + name: "InvalidSecondsForLaunch", + msg: "Launch period must be between 1 hour and 2 weeks", + }, + { + code: 6003, + name: "InsufficientFunds", + msg: "Insufficient funds", + }, + { + code: 6004, + name: "InvalidTokenKey", + msg: "Token mint key must end in 'meta'", + }, + { + code: 6005, + name: "InvalidLaunchState", + msg: "Invalid launch state", + }, + { + code: 6006, + name: "LaunchPeriodNotOver", + msg: "Launch period not over", + }, + { + code: 6007, + name: "LaunchExpired", + msg: "Launch is complete, no more funding allowed", + }, + { + code: 6008, + name: "LaunchNotRefunding", + msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", + }, + { + code: 6009, + name: "LaunchNotInitialized", + msg: "Launch must be initialized to be started", + }, + { + code: 6010, + name: "FreezeAuthoritySet", + msg: "Freeze authority can't be set on launchpad tokens", + }, + { + code: 6011, + name: "InvalidMonthlySpendingLimit", + msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", + }, + { + code: 6012, + name: "InvalidMonthlySpendingLimitMembers", + msg: "There can only be at most 10 monthly spending limit members", + }, + { + code: 6013, + name: "InvalidPriceBasedPremineAmount", + msg: "Cannot do more than a 50% premine", + }, + { + code: 6014, + name: "InvalidPerformancePackageMinUnlockTime", + msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", + }, + { + code: 6015, + name: "LaunchAuthorityNotSet", + msg: "Launch authority must be set to complete the launch until 2 days after closing", + }, + { + code: 6016, + name: "FinalRaiseAmountTooLow", + msg: "The final amount raised must be greater than or equal to the minimum raise amount", + }, + { + code: 6017, + name: "TokensAlreadyClaimed", + msg: "Tokens already claimed", + }, + { + code: 6018, + name: "MoneyAlreadyRefunded", + msg: "Money already refunded", + }, + { + code: 6019, + name: "InvariantViolated", + msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", + }, + { + code: 6020, + name: "LaunchNotLive", + msg: "Launch must be live to be closed", + }, + { + code: 6021, + name: "InvalidMinimumRaiseAmount", + msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", + }, + ], +}; diff --git a/sdk2/src/priceMath.ts b/sdk2/src/priceMath.ts index 6a39b6969..29ada287d 100644 --- a/sdk2/src/priceMath.ts +++ b/sdk2/src/priceMath.ts @@ -12,13 +12,6 @@ export type AddLiquiditySimulation = { maxBaseAmount?: BN; }; -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - export type RemoveLiquiditySimulation = { expectedBaseOut: BN; expectedQuoteOut: BN; From 2cd2a14787ebdd51b0a2b999346c41dd5c816322 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 28 Apr 2026 18:29:07 +0200 Subject: [PATCH 093/100] replace old SDK dir with new one --- package.json | 3 +- rebuild.sh | 6 +- scripts/v0.5/executeProposal.ts | 6 +- scripts/v0.5/initializeDao.ts | 2 +- sdk/free-account.json | 1 - sdk/package.json | 39 +- {sdk2 => sdk}/permissionless-account.json | 0 {sdk2 => sdk}/src/amm/index.ts | 0 {sdk2 => sdk}/src/amm/v0.3/AmmClient.ts | 0 {sdk2 => sdk}/src/amm/v0.3/index.ts | 0 {sdk2 => sdk}/src/amm/v0.3/pda.ts | 0 sdk/src/{ => amm}/v0.3/types/amm.ts | 0 {sdk2 => sdk}/src/amm/v0.3/types/index.ts | 0 {sdk2 => sdk}/src/amm/v0.4/AmmClient.ts | 0 {sdk2 => sdk}/src/amm/v0.4/index.ts | 0 {sdk2 => sdk}/src/amm/v0.4/pda.ts | 0 sdk/src/{ => amm}/v0.4/types/amm.ts | 0 {sdk2 => sdk}/src/amm/v0.4/types/index.ts | 0 {sdk2 => sdk}/src/amm/v0.5/AmmClient.ts | 0 {sdk2 => sdk}/src/amm/v0.5/index.ts | 0 {sdk2 => sdk}/src/amm/v0.5/pda.ts | 0 {sdk2 => sdk}/src/amm/v0.5/priceMath.ts | 0 sdk/src/{ => amm}/v0.5/types/amm.ts | 0 {sdk2 => sdk}/src/amm/v0.5/types/index.ts | 0 {sdk2 => sdk}/src/autocrat/index.ts | 0 .../src/autocrat/v0.3/AutocratClient.ts | 0 sdk/src/{v0.3/utils => autocrat/v0.3}/cu.ts | 0 {sdk2 => sdk}/src/autocrat/v0.3/index.ts | 0 {sdk2 => sdk}/src/autocrat/v0.3/pda.ts | 0 sdk/src/{ => autocrat}/v0.3/types/autocrat.ts | 0 .../src/autocrat/v0.3/types/index.ts | 0 .../src/autocrat/v0.4/AutocratClient.ts | 0 {sdk2 => sdk}/src/autocrat/v0.4/index.ts | 0 {sdk2 => sdk}/src/autocrat/v0.4/pda.ts | 0 sdk/src/{ => autocrat}/v0.4/types/autocrat.ts | 0 .../src/autocrat/v0.4/types/index.ts | 0 .../src/autocrat/v0.5/AutocratClient.ts | 0 {sdk2 => sdk}/src/autocrat/v0.5/index.ts | 0 {sdk2 => sdk}/src/autocrat/v0.5/pda.ts | 0 sdk/src/{ => autocrat}/v0.5/types/autocrat.ts | 0 .../src/autocrat/v0.5/types/index.ts | 0 {sdk2 => sdk}/src/bid_wall/index.ts | 0 .../src/bid_wall/v0.7/BidWallClient.ts | 0 {sdk2 => sdk}/src/bid_wall/v0.7/index.ts | 0 {sdk2 => sdk}/src/bid_wall/v0.7/pda.ts | 0 sdk/src/{ => bid_wall}/v0.7/types/bid_wall.ts | 0 .../src/bid_wall/v0.7/types/index.ts | 0 {sdk2 => sdk}/src/conditional_vault/index.ts | 0 .../v0.3/ConditionalVaultClient.ts | 0 .../src/conditional_vault/v0.3/index.ts | 0 .../src/conditional_vault/v0.3/pda.ts | 0 .../v0.3/types/conditional_vault.ts | 0 .../src/conditional_vault/v0.3/types/index.ts | 0 .../v0.4/ConditionalVaultClient.ts | 0 .../src/conditional_vault/v0.4/index.ts | 0 .../src/conditional_vault/v0.4/pda.ts | 0 .../v0.4}/types/conditional_vault.ts | 0 .../src/conditional_vault/v0.4/types/index.ts | 0 {sdk2 => sdk}/src/constants.ts | 0 {sdk2 => sdk}/src/futarchy/index.ts | 0 .../src/futarchy/v0.6/FutarchyClient.ts | 0 {sdk2 => sdk}/src/futarchy/v0.6/index.ts | 0 {sdk2 => sdk}/src/futarchy/v0.6/pda.ts | 0 .../{v0.7 => futarchy/v0.6}/types/futarchy.ts | 0 .../src/futarchy/v0.6/types/index.ts | 0 .../v0.6/types/v0.6.0-futarchy.ts | 0 sdk/src/index.ts | 16 + {sdk2 => sdk}/src/launchpad/index.ts | 0 .../src/launchpad/v0.4/LaunchpadClient.ts | 0 {sdk2 => sdk}/src/launchpad/v0.4/index.ts | 0 {sdk2 => sdk}/src/launchpad/v0.4/pda.ts | 0 .../src/launchpad/v0.4/types/index.ts | 0 .../{ => launchpad}/v0.4/types/launchpad.ts | 0 .../src/launchpad/v0.5/LaunchpadClient.ts | 0 {sdk2 => sdk}/src/launchpad/v0.5/index.ts | 0 {sdk2 => sdk}/src/launchpad/v0.5/pda.ts | 0 .../src/launchpad/v0.5/types/index.ts | 0 .../{ => launchpad}/v0.5/types/launchpad.ts | 0 .../src/launchpad/v0.6/LaunchpadClient.ts | 0 {sdk2 => sdk}/src/launchpad/v0.6/index.ts | 0 {sdk2 => sdk}/src/launchpad/v0.6/pda.ts | 0 .../src/launchpad/v0.6/types/index.ts | 0 .../v0.6}/types/launchpad.ts | 0 .../v0.6/types/v0.6.0-launchpad.ts | 0 .../src/launchpad/v0.7/LaunchpadClient.ts | 0 {sdk2 => sdk}/src/launchpad/v0.7/index.ts | 0 {sdk2 => sdk}/src/launchpad/v0.7/pda.ts | 0 .../src/launchpad/v0.7/types/index.ts | 0 .../v0.7/types/launchpad_v7.ts | 0 {sdk2 => sdk}/src/liquidation/index.ts | 0 .../src/liquidation/v0.7/LiquidationClient.ts | 0 {sdk2 => sdk}/src/liquidation/v0.7/index.ts | 0 {sdk2 => sdk}/src/liquidation/v0.7/pda.ts | 0 .../src/liquidation/v0.7/types/index.ts | 0 .../v0.7/types/liquidation.ts | 0 {sdk2 => sdk}/src/mint_governor/index.ts | 0 .../mint_governor/v0.7/MintGovernorClient.ts | 0 {sdk2 => sdk}/src/mint_governor/v0.7/index.ts | 0 {sdk2 => sdk}/src/mint_governor/v0.7/pda.ts | 0 .../src/mint_governor/v0.7/types/index.ts | 0 .../v0.7/types/mint_governor.ts | 0 {sdk2 => sdk}/src/pda.ts | 0 .../src/performance_package_v2/index.ts | 0 .../v0.7/PerformancePackageV2Client.ts | 0 .../src/performance_package_v2/v0.7/index.ts | 0 .../src/performance_package_v2/v0.7/pda.ts | 0 .../v0.7/types/index.ts | 0 .../v0.7/types/performance_package_v2.ts | 0 {sdk2 => sdk}/src/priceMath.ts | 0 .../price_based_performance_package/index.ts | 0 .../PriceBasedPerformancePackageClient.ts | 0 .../v0.6/index.ts | 0 .../v0.6/pda.ts | 0 .../v0.6/types/index.ts | 0 .../types/price_based_performance_package.ts | 0 .../src/shared_liquidity_manager/index.ts | 0 .../v0.5/SharedLiquidityManagerClient.ts | 0 .../shared_liquidity_manager/v0.5/index.ts | 0 .../src/shared_liquidity_manager/v0.5/pda.ts | 0 .../v0.5/types/index.ts | 0 .../v0.5/types/shared_liquidity_manager.ts | 0 {sdk2 => sdk}/src/utils.ts | 0 sdk/src/v0.3/AmmClient.ts | 370 - sdk/src/v0.3/AutocratClient.ts | 723 -- sdk/src/v0.3/ConditionalVaultClient.ts | 348 - sdk/src/v0.3/FutarchyClient.ts | 146 - sdk/src/v0.3/constants.ts | 26 - sdk/src/v0.3/index.ts | 7 - sdk/src/v0.3/types/autocrat_migrator.ts | 237 - sdk/src/v0.3/types/index.ts | 34 - sdk/src/v0.3/types/optimistic_timelock.ts | 1023 --- sdk/src/v0.3/types/utils.ts | 3 - sdk/src/v0.3/utils/ammMath.ts | 249 - sdk/src/v0.3/utils/filters.ts | 21 - sdk/src/v0.3/utils/index.ts | 40 - sdk/src/v0.3/utils/instruction.ts | 16 - sdk/src/v0.3/utils/metadata.ts | 35 - sdk/src/v0.3/utils/pda.ts | 110 - sdk/src/v0.4/AmmClient.ts | 381 - sdk/src/v0.4/AutocratClient.ts | 797 -- sdk/src/v0.4/ConditionalVaultClient.ts | 475 -- sdk/src/v0.4/LaunchpadClient.ts | 411 - sdk/src/v0.4/constants.ts | 74 - sdk/src/v0.4/index.ts | 7 - sdk/src/v0.4/types/autocrat_migrator.ts | 237 - sdk/src/v0.4/types/conditional_vault.ts | 1839 ---- sdk/src/v0.4/types/index.ts | 109 - sdk/src/v0.4/types/optimistic_timelock.ts | 1023 --- .../v0.4/types/shared_liquidity_manager.ts | 3529 -------- sdk/src/v0.4/types/utils.ts | 3 - sdk/src/v0.4/utils/cu.ts | 11 - sdk/src/v0.4/utils/filters.ts | 21 - sdk/src/v0.4/utils/index.ts | 40 - sdk/src/v0.4/utils/instruction.ts | 16 - sdk/src/v0.4/utils/metadata.ts | 35 - sdk/src/v0.4/utils/pda.ts | 217 - sdk/src/v0.4/utils/priceMath.ts | 198 - sdk/src/v0.5/AmmClient.ts | 381 - sdk/src/v0.5/AutocratClient.ts | 675 -- sdk/src/v0.5/ConditionalVaultClient.ts | 475 -- sdk/src/v0.5/LaunchpadClient.ts | 451 - sdk/src/v0.5/SharedLiquidityManagerClient.ts | 863 -- sdk/src/v0.5/constants.ts | 101 - sdk/src/v0.5/index.ts | 8 - sdk/src/v0.5/types/autocrat_migrator.ts | 237 - sdk/src/v0.5/types/conditional_vault.ts | 1849 ---- sdk/src/v0.5/types/futarchy_amm.ts | 1663 ---- sdk/src/v0.5/types/index.ts | 117 - sdk/src/v0.5/types/optimistic_timelock.ts | 1023 --- sdk/src/v0.5/types/utils.ts | 3 - sdk/src/v0.5/utils/cu.ts | 11 - sdk/src/v0.5/utils/filters.ts | 21 - sdk/src/v0.5/utils/index.ts | 40 - sdk/src/v0.5/utils/instruction.ts | 16 - sdk/src/v0.5/utils/metadata.ts | 35 - sdk/src/v0.5/utils/pda.ts | 327 - sdk/src/v0.5/utils/priceMath.ts | 198 - sdk/src/v0.6/ConditionalVaultClient.ts | 475 -- sdk/src/v0.6/FutarchyClient.ts | 1130 --- sdk/src/v0.6/LaunchpadClient.ts | 589 -- .../PriceBasedPerformancePackageClient.ts | 228 - sdk/src/v0.6/constants.ts | 123 - sdk/src/v0.6/index.ts | 7 - sdk/src/v0.6/types/amm.ts | 1663 ---- sdk/src/v0.6/types/autocrat.ts | 2377 ------ sdk/src/v0.6/types/autocrat_migrator.ts | 237 - sdk/src/v0.6/types/bid_wall.ts | 1033 --- sdk/src/v0.6/types/conditional_vault.ts | 1849 ---- sdk/src/v0.6/types/damm_v2_cpi.ts | 747 -- sdk/src/v0.6/types/futarchy.ts | 6913 --------------- sdk/src/v0.6/types/futarchy_amm.ts | 1663 ---- sdk/src/v0.6/types/index.ts | 248 - sdk/src/v0.6/types/launchpad.ts | 2813 ------- sdk/src/v0.6/types/launchpad_v7.ts | 3053 ------- sdk/src/v0.6/types/optimistic_timelock.ts | 1023 --- .../types/price_based_performance_package.ts | 1893 ----- sdk/src/v0.6/types/price_based_token_lock.ts | 887 -- sdk/src/v0.6/types/price_based_unlock.ts | 1717 ---- .../v0.6/types/shared_liquidity_manager.ts | 177 - sdk/src/v0.6/types/utils.ts | 3 - sdk/src/v0.6/utils/cu.ts | 11 - sdk/src/v0.6/utils/filters.ts | 21 - sdk/src/v0.6/utils/index.ts | 40 - sdk/src/v0.6/utils/instruction.ts | 16 - sdk/src/v0.6/utils/metadata.ts | 35 - sdk/src/v0.6/utils/pda.ts | 238 - sdk/src/v0.6/utils/priceMath.ts | 197 - sdk/src/v0.7/BidWallClient.ts | 314 - sdk/src/v0.7/ConditionalVaultClient.ts | 475 -- sdk/src/v0.7/FutarchyClient.ts | 1242 --- sdk/src/v0.7/LaunchpadClient.ts | 766 -- sdk/src/v0.7/LiquidationClient.ts | 338 - sdk/src/v0.7/MintGovernorClient.ts | 251 - sdk/src/v0.7/PerformancePackageV2Client.ts | 310 - .../PriceBasedPerformancePackageClient.ts | 228 - sdk/src/v0.7/constants.ts | 135 - sdk/src/v0.7/index.ts | 11 - sdk/src/v0.7/types/amm.ts | 1663 ---- sdk/src/v0.7/types/autocrat.ts | 2377 ------ sdk/src/v0.7/types/autocrat_migrator.ts | 237 - sdk/src/v0.7/types/damm_v2_cpi.ts | 747 -- sdk/src/v0.7/types/futarchy_amm.ts | 1663 ---- sdk/src/v0.7/types/index.ts | 273 - sdk/src/v0.7/types/optimistic_timelock.ts | 1023 --- sdk/src/v0.7/types/price_based_token_lock.ts | 887 -- sdk/src/v0.7/types/price_based_unlock.ts | 1717 ---- .../v0.7/types/shared_liquidity_manager.ts | 177 - sdk/src/v0.7/types/utils.ts | 3 - sdk/src/v0.7/utils/cu.ts | 11 - sdk/src/v0.7/utils/filters.ts | 21 - sdk/src/v0.7/utils/index.ts | 40 - sdk/src/v0.7/utils/instruction.ts | 16 - sdk/src/v0.7/utils/metadata.ts | 35 - sdk/src/v0.7/utils/pda.ts | 375 - sdk/src/v0.7/utils/priceMath.ts | 197 - {sdk2 => sdk}/sync-types.sh | 0 sdk/tsconfig.json | 38 +- sdk/yarn.lock | 2 +- sdk2/.gitignore | 2 - sdk2/package.json | 90 - sdk2/src/amm/v0.3/types/amm.ts | 1083 --- sdk2/src/amm/v0.4/types/amm.ts | 1647 ---- sdk2/src/amm/v0.5/types/amm.ts | 1663 ---- sdk2/src/autocrat/v0.3/cu.ts | 11 - sdk2/src/autocrat/v0.3/types/autocrat.ts | 1263 --- sdk2/src/autocrat/v0.4/types/autocrat.ts | 2013 ----- sdk2/src/autocrat/v0.5/types/autocrat.ts | 2121 ----- sdk2/src/bid_wall/v0.7/types/bid_wall.ts | 1435 ---- .../v0.3/types/conditional_vault.ts | 895 -- .../v0.4/types/conditional_vault.ts | 1835 ---- sdk2/src/futarchy/v0.6/types/futarchy.ts | 7489 ----------------- .../futarchy/v0.6/types/v0.6.0-futarchy.ts | 5133 ----------- sdk2/src/index.ts | 17 - sdk2/src/launchpad/v0.4/types/launchpad.ts | 1999 ----- sdk2/src/launchpad/v0.5/types/launchpad.ts | 2123 ----- sdk2/src/launchpad/v0.6/types/launchpad.ts | 2813 ------- .../launchpad/v0.6/types/v0.6.0-launchpad.ts | 2553 ------ sdk2/src/launchpad/v0.7/types/launchpad_v7.ts | 4223 ---------- .../src/liquidation/v0.7/types/liquidation.ts | 1515 ---- .../mint_governor/v0.7/types/mint_governor.ts | 1473 ---- .../v0.7/types/performance_package_v2.ts | 2139 ----- .../types/price_based_performance_package.ts | 1941 ----- .../v0.5/types/shared_liquidity_manager.ts | 177 - sdk2/tsconfig.json | 18 - sdk2/yarn.lock | 3331 -------- .../futarchy/integration/futarchyAmm.test.ts | 7 +- tests/futarchy/unit/collectFees.test.ts | 3 +- .../unit/collectMeteoraDammFees.test.ts | 2 +- .../unit/changeLockerAuthority.test.ts | 277 - yarn.lock | 2 +- 270 files changed, 67 insertions(+), 119582 deletions(-) delete mode 100644 sdk/free-account.json rename {sdk2 => sdk}/permissionless-account.json (100%) rename {sdk2 => sdk}/src/amm/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.3/AmmClient.ts (100%) rename {sdk2 => sdk}/src/amm/v0.3/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.3/pda.ts (100%) rename sdk/src/{ => amm}/v0.3/types/amm.ts (100%) rename {sdk2 => sdk}/src/amm/v0.3/types/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.4/AmmClient.ts (100%) rename {sdk2 => sdk}/src/amm/v0.4/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.4/pda.ts (100%) rename sdk/src/{ => amm}/v0.4/types/amm.ts (100%) rename {sdk2 => sdk}/src/amm/v0.4/types/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.5/AmmClient.ts (100%) rename {sdk2 => sdk}/src/amm/v0.5/index.ts (100%) rename {sdk2 => sdk}/src/amm/v0.5/pda.ts (100%) rename {sdk2 => sdk}/src/amm/v0.5/priceMath.ts (100%) rename sdk/src/{ => amm}/v0.5/types/amm.ts (100%) rename {sdk2 => sdk}/src/amm/v0.5/types/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.3/AutocratClient.ts (100%) rename sdk/src/{v0.3/utils => autocrat/v0.3}/cu.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.3/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.3/pda.ts (100%) rename sdk/src/{ => autocrat}/v0.3/types/autocrat.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.3/types/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.4/AutocratClient.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.4/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.4/pda.ts (100%) rename sdk/src/{ => autocrat}/v0.4/types/autocrat.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.4/types/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.5/AutocratClient.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.5/index.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.5/pda.ts (100%) rename sdk/src/{ => autocrat}/v0.5/types/autocrat.ts (100%) rename {sdk2 => sdk}/src/autocrat/v0.5/types/index.ts (100%) rename {sdk2 => sdk}/src/bid_wall/index.ts (100%) rename {sdk2 => sdk}/src/bid_wall/v0.7/BidWallClient.ts (100%) rename {sdk2 => sdk}/src/bid_wall/v0.7/index.ts (100%) rename {sdk2 => sdk}/src/bid_wall/v0.7/pda.ts (100%) rename sdk/src/{ => bid_wall}/v0.7/types/bid_wall.ts (100%) rename {sdk2 => sdk}/src/bid_wall/v0.7/types/index.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/index.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.3/ConditionalVaultClient.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.3/index.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.3/pda.ts (100%) rename sdk/src/{ => conditional_vault}/v0.3/types/conditional_vault.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.3/types/index.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.4/ConditionalVaultClient.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.4/index.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.4/pda.ts (100%) rename sdk/src/{v0.7 => conditional_vault/v0.4}/types/conditional_vault.ts (100%) rename {sdk2 => sdk}/src/conditional_vault/v0.4/types/index.ts (100%) rename {sdk2 => sdk}/src/constants.ts (100%) rename {sdk2 => sdk}/src/futarchy/index.ts (100%) rename {sdk2 => sdk}/src/futarchy/v0.6/FutarchyClient.ts (100%) rename {sdk2 => sdk}/src/futarchy/v0.6/index.ts (100%) rename {sdk2 => sdk}/src/futarchy/v0.6/pda.ts (100%) rename sdk/src/{v0.7 => futarchy/v0.6}/types/futarchy.ts (100%) rename {sdk2 => sdk}/src/futarchy/v0.6/types/index.ts (100%) rename sdk/src/{ => futarchy}/v0.6/types/v0.6.0-futarchy.ts (100%) rename {sdk2 => sdk}/src/launchpad/index.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.4/LaunchpadClient.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.4/index.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.4/pda.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.4/types/index.ts (100%) rename sdk/src/{ => launchpad}/v0.4/types/launchpad.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.5/LaunchpadClient.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.5/index.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.5/pda.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.5/types/index.ts (100%) rename sdk/src/{ => launchpad}/v0.5/types/launchpad.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.6/LaunchpadClient.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.6/index.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.6/pda.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.6/types/index.ts (100%) rename sdk/src/{v0.7 => launchpad/v0.6}/types/launchpad.ts (100%) rename sdk/src/{ => launchpad}/v0.6/types/v0.6.0-launchpad.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.7/LaunchpadClient.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.7/index.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.7/pda.ts (100%) rename {sdk2 => sdk}/src/launchpad/v0.7/types/index.ts (100%) rename sdk/src/{ => launchpad}/v0.7/types/launchpad_v7.ts (100%) rename {sdk2 => sdk}/src/liquidation/index.ts (100%) rename {sdk2 => sdk}/src/liquidation/v0.7/LiquidationClient.ts (100%) rename {sdk2 => sdk}/src/liquidation/v0.7/index.ts (100%) rename {sdk2 => sdk}/src/liquidation/v0.7/pda.ts (100%) rename {sdk2 => sdk}/src/liquidation/v0.7/types/index.ts (100%) rename sdk/src/{ => liquidation}/v0.7/types/liquidation.ts (100%) rename {sdk2 => sdk}/src/mint_governor/index.ts (100%) rename {sdk2 => sdk}/src/mint_governor/v0.7/MintGovernorClient.ts (100%) rename {sdk2 => sdk}/src/mint_governor/v0.7/index.ts (100%) rename {sdk2 => sdk}/src/mint_governor/v0.7/pda.ts (100%) rename {sdk2 => sdk}/src/mint_governor/v0.7/types/index.ts (100%) rename sdk/src/{ => mint_governor}/v0.7/types/mint_governor.ts (100%) rename {sdk2 => sdk}/src/pda.ts (100%) rename {sdk2 => sdk}/src/performance_package_v2/index.ts (100%) rename {sdk2 => sdk}/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts (100%) rename {sdk2 => sdk}/src/performance_package_v2/v0.7/index.ts (100%) rename {sdk2 => sdk}/src/performance_package_v2/v0.7/pda.ts (100%) rename {sdk2 => sdk}/src/performance_package_v2/v0.7/types/index.ts (100%) rename sdk/src/{ => performance_package_v2}/v0.7/types/performance_package_v2.ts (100%) rename {sdk2 => sdk}/src/priceMath.ts (100%) rename {sdk2 => sdk}/src/price_based_performance_package/index.ts (100%) rename {sdk2 => sdk}/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts (100%) rename {sdk2 => sdk}/src/price_based_performance_package/v0.6/index.ts (100%) rename {sdk2 => sdk}/src/price_based_performance_package/v0.6/pda.ts (100%) rename {sdk2 => sdk}/src/price_based_performance_package/v0.6/types/index.ts (100%) rename sdk/src/{v0.7 => price_based_performance_package/v0.6}/types/price_based_performance_package.ts (100%) rename {sdk2 => sdk}/src/shared_liquidity_manager/index.ts (100%) rename {sdk2 => sdk}/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts (100%) rename {sdk2 => sdk}/src/shared_liquidity_manager/v0.5/index.ts (100%) rename {sdk2 => sdk}/src/shared_liquidity_manager/v0.5/pda.ts (100%) rename {sdk2 => sdk}/src/shared_liquidity_manager/v0.5/types/index.ts (100%) rename sdk/src/{ => shared_liquidity_manager}/v0.5/types/shared_liquidity_manager.ts (100%) rename {sdk2 => sdk}/src/utils.ts (100%) delete mode 100644 sdk/src/v0.3/AmmClient.ts delete mode 100644 sdk/src/v0.3/AutocratClient.ts delete mode 100644 sdk/src/v0.3/ConditionalVaultClient.ts delete mode 100644 sdk/src/v0.3/FutarchyClient.ts delete mode 100644 sdk/src/v0.3/constants.ts delete mode 100644 sdk/src/v0.3/index.ts delete mode 100644 sdk/src/v0.3/types/autocrat_migrator.ts delete mode 100644 sdk/src/v0.3/types/index.ts delete mode 100644 sdk/src/v0.3/types/optimistic_timelock.ts delete mode 100644 sdk/src/v0.3/types/utils.ts delete mode 100644 sdk/src/v0.3/utils/ammMath.ts delete mode 100644 sdk/src/v0.3/utils/filters.ts delete mode 100644 sdk/src/v0.3/utils/index.ts delete mode 100644 sdk/src/v0.3/utils/instruction.ts delete mode 100644 sdk/src/v0.3/utils/metadata.ts delete mode 100644 sdk/src/v0.3/utils/pda.ts delete mode 100644 sdk/src/v0.4/AmmClient.ts delete mode 100644 sdk/src/v0.4/AutocratClient.ts delete mode 100644 sdk/src/v0.4/ConditionalVaultClient.ts delete mode 100644 sdk/src/v0.4/LaunchpadClient.ts delete mode 100644 sdk/src/v0.4/constants.ts delete mode 100644 sdk/src/v0.4/index.ts delete mode 100644 sdk/src/v0.4/types/autocrat_migrator.ts delete mode 100644 sdk/src/v0.4/types/conditional_vault.ts delete mode 100644 sdk/src/v0.4/types/index.ts delete mode 100644 sdk/src/v0.4/types/optimistic_timelock.ts delete mode 100644 sdk/src/v0.4/types/shared_liquidity_manager.ts delete mode 100644 sdk/src/v0.4/types/utils.ts delete mode 100644 sdk/src/v0.4/utils/cu.ts delete mode 100644 sdk/src/v0.4/utils/filters.ts delete mode 100644 sdk/src/v0.4/utils/index.ts delete mode 100644 sdk/src/v0.4/utils/instruction.ts delete mode 100644 sdk/src/v0.4/utils/metadata.ts delete mode 100644 sdk/src/v0.4/utils/pda.ts delete mode 100644 sdk/src/v0.4/utils/priceMath.ts delete mode 100644 sdk/src/v0.5/AmmClient.ts delete mode 100644 sdk/src/v0.5/AutocratClient.ts delete mode 100644 sdk/src/v0.5/ConditionalVaultClient.ts delete mode 100644 sdk/src/v0.5/LaunchpadClient.ts delete mode 100644 sdk/src/v0.5/SharedLiquidityManagerClient.ts delete mode 100644 sdk/src/v0.5/constants.ts delete mode 100644 sdk/src/v0.5/index.ts delete mode 100644 sdk/src/v0.5/types/autocrat_migrator.ts delete mode 100644 sdk/src/v0.5/types/conditional_vault.ts delete mode 100644 sdk/src/v0.5/types/futarchy_amm.ts delete mode 100644 sdk/src/v0.5/types/index.ts delete mode 100644 sdk/src/v0.5/types/optimistic_timelock.ts delete mode 100644 sdk/src/v0.5/types/utils.ts delete mode 100644 sdk/src/v0.5/utils/cu.ts delete mode 100644 sdk/src/v0.5/utils/filters.ts delete mode 100644 sdk/src/v0.5/utils/index.ts delete mode 100644 sdk/src/v0.5/utils/instruction.ts delete mode 100644 sdk/src/v0.5/utils/metadata.ts delete mode 100644 sdk/src/v0.5/utils/pda.ts delete mode 100644 sdk/src/v0.5/utils/priceMath.ts delete mode 100644 sdk/src/v0.6/ConditionalVaultClient.ts delete mode 100644 sdk/src/v0.6/FutarchyClient.ts delete mode 100644 sdk/src/v0.6/LaunchpadClient.ts delete mode 100644 sdk/src/v0.6/PriceBasedPerformancePackageClient.ts delete mode 100644 sdk/src/v0.6/constants.ts delete mode 100644 sdk/src/v0.6/index.ts delete mode 100644 sdk/src/v0.6/types/amm.ts delete mode 100644 sdk/src/v0.6/types/autocrat.ts delete mode 100644 sdk/src/v0.6/types/autocrat_migrator.ts delete mode 100644 sdk/src/v0.6/types/bid_wall.ts delete mode 100644 sdk/src/v0.6/types/conditional_vault.ts delete mode 100644 sdk/src/v0.6/types/damm_v2_cpi.ts delete mode 100644 sdk/src/v0.6/types/futarchy.ts delete mode 100644 sdk/src/v0.6/types/futarchy_amm.ts delete mode 100644 sdk/src/v0.6/types/index.ts delete mode 100644 sdk/src/v0.6/types/launchpad.ts delete mode 100644 sdk/src/v0.6/types/launchpad_v7.ts delete mode 100644 sdk/src/v0.6/types/optimistic_timelock.ts delete mode 100644 sdk/src/v0.6/types/price_based_performance_package.ts delete mode 100644 sdk/src/v0.6/types/price_based_token_lock.ts delete mode 100644 sdk/src/v0.6/types/price_based_unlock.ts delete mode 100644 sdk/src/v0.6/types/shared_liquidity_manager.ts delete mode 100644 sdk/src/v0.6/types/utils.ts delete mode 100644 sdk/src/v0.6/utils/cu.ts delete mode 100644 sdk/src/v0.6/utils/filters.ts delete mode 100644 sdk/src/v0.6/utils/index.ts delete mode 100644 sdk/src/v0.6/utils/instruction.ts delete mode 100644 sdk/src/v0.6/utils/metadata.ts delete mode 100644 sdk/src/v0.6/utils/pda.ts delete mode 100644 sdk/src/v0.6/utils/priceMath.ts delete mode 100644 sdk/src/v0.7/BidWallClient.ts delete mode 100644 sdk/src/v0.7/ConditionalVaultClient.ts delete mode 100644 sdk/src/v0.7/FutarchyClient.ts delete mode 100644 sdk/src/v0.7/LaunchpadClient.ts delete mode 100644 sdk/src/v0.7/LiquidationClient.ts delete mode 100644 sdk/src/v0.7/MintGovernorClient.ts delete mode 100644 sdk/src/v0.7/PerformancePackageV2Client.ts delete mode 100644 sdk/src/v0.7/PriceBasedPerformancePackageClient.ts delete mode 100644 sdk/src/v0.7/constants.ts delete mode 100644 sdk/src/v0.7/index.ts delete mode 100644 sdk/src/v0.7/types/amm.ts delete mode 100644 sdk/src/v0.7/types/autocrat.ts delete mode 100644 sdk/src/v0.7/types/autocrat_migrator.ts delete mode 100644 sdk/src/v0.7/types/damm_v2_cpi.ts delete mode 100644 sdk/src/v0.7/types/futarchy_amm.ts delete mode 100644 sdk/src/v0.7/types/index.ts delete mode 100644 sdk/src/v0.7/types/optimistic_timelock.ts delete mode 100644 sdk/src/v0.7/types/price_based_token_lock.ts delete mode 100644 sdk/src/v0.7/types/price_based_unlock.ts delete mode 100644 sdk/src/v0.7/types/shared_liquidity_manager.ts delete mode 100644 sdk/src/v0.7/types/utils.ts delete mode 100644 sdk/src/v0.7/utils/cu.ts delete mode 100644 sdk/src/v0.7/utils/filters.ts delete mode 100644 sdk/src/v0.7/utils/index.ts delete mode 100644 sdk/src/v0.7/utils/instruction.ts delete mode 100644 sdk/src/v0.7/utils/metadata.ts delete mode 100644 sdk/src/v0.7/utils/pda.ts delete mode 100644 sdk/src/v0.7/utils/priceMath.ts rename {sdk2 => sdk}/sync-types.sh (100%) delete mode 100644 sdk2/.gitignore delete mode 100644 sdk2/package.json delete mode 100644 sdk2/src/amm/v0.3/types/amm.ts delete mode 100644 sdk2/src/amm/v0.4/types/amm.ts delete mode 100644 sdk2/src/amm/v0.5/types/amm.ts delete mode 100644 sdk2/src/autocrat/v0.3/cu.ts delete mode 100644 sdk2/src/autocrat/v0.3/types/autocrat.ts delete mode 100644 sdk2/src/autocrat/v0.4/types/autocrat.ts delete mode 100644 sdk2/src/autocrat/v0.5/types/autocrat.ts delete mode 100644 sdk2/src/bid_wall/v0.7/types/bid_wall.ts delete mode 100644 sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts delete mode 100644 sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts delete mode 100644 sdk2/src/futarchy/v0.6/types/futarchy.ts delete mode 100644 sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts delete mode 100644 sdk2/src/index.ts delete mode 100644 sdk2/src/launchpad/v0.4/types/launchpad.ts delete mode 100644 sdk2/src/launchpad/v0.5/types/launchpad.ts delete mode 100644 sdk2/src/launchpad/v0.6/types/launchpad.ts delete mode 100644 sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts delete mode 100644 sdk2/src/launchpad/v0.7/types/launchpad_v7.ts delete mode 100644 sdk2/src/liquidation/v0.7/types/liquidation.ts delete mode 100644 sdk2/src/mint_governor/v0.7/types/mint_governor.ts delete mode 100644 sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts delete mode 100644 sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts delete mode 100644 sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts delete mode 100644 sdk2/tsconfig.json delete mode 100644 sdk2/yarn.lock delete mode 100644 tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts diff --git a/package.json b/package.json index e0d3ba4d6..d3c1bc563 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "scripts": { "lint:fix": "prettier */*{.js,.ts} \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", + "typecheck": "tsc --noEmit", "setup-metric-market": "tsx --tsconfig tsconfig.json scripts/setupMetricMarket.ts", "launch-init": "NODE_OPTIONS=\"--no-deprecation\" tsx --tsconfig tsconfig.json scripts/launchInit.ts", "launch-start": "NODE_OPTIONS=\"--no-deprecation\" tsx --tsconfig tsconfig.json scripts/launchStart.ts", @@ -24,7 +25,7 @@ "dependencies": { "@coral-xyz/anchor": "=0.29.0", "@inquirer/prompts": "^7.3.3", - "@metadaoproject/futarchy": "./sdk2", + "@metadaoproject/futarchy": "./sdk", "@metaplex-foundation/mpl-token-metadata": "^3.2.0", "@metaplex-foundation/umi": "^0.9.1", "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", diff --git a/rebuild.sh b/rebuild.sh index 62aa77721..953ae8e22 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -6,10 +6,6 @@ cd sdk yarn install yarn build-local cd .. -cd sdk2 -yarn install -yarn build-local -cd .. yarn install --force yarn lint:fix -echo "✅ SDK types synced successfully" \ No newline at end of file +echo "✅ rebuild complete" \ No newline at end of file diff --git a/scripts/v0.5/executeProposal.ts b/scripts/v0.5/executeProposal.ts index 0399e4dc6..7c97b9452 100644 --- a/scripts/v0.5/executeProposal.ts +++ b/scripts/v0.5/executeProposal.ts @@ -1,5 +1,8 @@ import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { + PERMISSIONLESS_ACCOUNT, + DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, +} from "@metadaoproject/futarchy"; import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.5"; import { Keypair, @@ -10,7 +13,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "../../sdk/src/v0.5/constants.js"; import * as token from "@solana/spl-token"; const EXISTING_TOKEN = new PublicKey( diff --git a/scripts/v0.5/initializeDao.ts b/scripts/v0.5/initializeDao.ts index 1e3f84859..196e358e5 100644 --- a/scripts/v0.5/initializeDao.ts +++ b/scripts/v0.5/initializeDao.ts @@ -3,6 +3,7 @@ import { DEVNET_USDC, MAINNET_USDC, SQUADS_PROGRAM_CONFIG_TREASURY, + DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, } from "@metadaoproject/futarchy"; import { AutocratClient, @@ -17,7 +18,6 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "../../sdk/src/v0.5/constants.js"; import * as token from "@solana/spl-token"; const EXISTING_TOKEN = new PublicKey( diff --git a/sdk/free-account.json b/sdk/free-account.json deleted file mode 100644 index 81b00d37f..000000000 --- a/sdk/free-account.json +++ /dev/null @@ -1 +0,0 @@ -[249,158,188,171,243,143,1,48,87,243,209,153,144,106,23,88,161,209,65,217,199,121,0,250,3,203,133,138,141,112,243,38,198,205,120,222,160,224,151,190,84,254,127,178,224,195,130,243,145,73,20,91,9,69,222,184,23,1,2,196,202,206,153,192] \ No newline at end of file diff --git a/sdk/package.json b/sdk/package.json index 337591d80..137a8b4de 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,27 +1,44 @@ { "name": "@metadaoproject/futarchy", - "version": "0.7.4-alpha.3", + "version": "0.8.0-alpha.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", + "exports": { + ".": "./dist/index.js", + "./amm": "./dist/amm/index.js", + "./autocrat": "./dist/autocrat/index.js", + "./bid_wall": "./dist/bid_wall/index.js", + "./conditional_vault": "./dist/conditional_vault/index.js", + "./futarchy": "./dist/futarchy/index.js", + "./launchpad": "./dist/launchpad/index.js", + "./liquidation": "./dist/liquidation/index.js", + "./mint_governor": "./dist/mint_governor/index.js", + "./performance_package_v2": "./dist/performance_package_v2/index.js", + "./price_based_performance_package": "./dist/price_based_performance_package/index.js", + "./shared_liquidity_manager": "./dist/shared_liquidity_manager/index.js", + "./amm/*": "./dist/amm/*/index.js", + "./autocrat/*": "./dist/autocrat/*/index.js", + "./bid_wall/*": "./dist/bid_wall/*/index.js", + "./conditional_vault/*": "./dist/conditional_vault/*/index.js", + "./futarchy/*": "./dist/futarchy/*/index.js", + "./launchpad/*": "./dist/launchpad/*/index.js", + "./liquidation/*": "./dist/liquidation/*/index.js", + "./mint_governor/*": "./dist/mint_governor/*/index.js", + "./performance_package_v2/*": "./dist/performance_package_v2/*/index.js", + "./price_based_performance_package/*": "./dist/price_based_performance_package/*/index.js", + "./shared_liquidity_manager/*": "./dist/shared_liquidity_manager/*/index.js" + }, "license": "BSL-1.0", "files": [ "/dist" ], - "exports": { - ".": "./dist/index.js", - "./v0.3": "./dist/v0.3/index.js", - "./v0.4": "./dist/v0.4/index.js", - "./v0.5": "./dist/v0.5/index.js", - "./v0.6": "./dist/v0.6/index.js", - "./v0.7": "./dist/v0.7/index.js" - }, "scripts": { "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", "build": "tsc", - "build-local": "rm -rf ./dist && cp ../target/types/* ./src/v0.7/types && yarn tsc", + "build-local": "rm -rf ./dist && ./sync-types.sh && yarn tsc", "prepublishOnly": "yarn lint:fix && yarn build" }, "dependencies": { @@ -47,7 +64,7 @@ "solana-bankrun": "^0.2.0", "spl-token-bankrun": "0.2.3", "ts-mocha": "^10.0.0", - "typescript": "^5.5.5" + "typescript": "5.9.3" }, "resolutions": { "error-ex": "=1.3.2", diff --git a/sdk2/permissionless-account.json b/sdk/permissionless-account.json similarity index 100% rename from sdk2/permissionless-account.json rename to sdk/permissionless-account.json diff --git a/sdk2/src/amm/index.ts b/sdk/src/amm/index.ts similarity index 100% rename from sdk2/src/amm/index.ts rename to sdk/src/amm/index.ts diff --git a/sdk2/src/amm/v0.3/AmmClient.ts b/sdk/src/amm/v0.3/AmmClient.ts similarity index 100% rename from sdk2/src/amm/v0.3/AmmClient.ts rename to sdk/src/amm/v0.3/AmmClient.ts diff --git a/sdk2/src/amm/v0.3/index.ts b/sdk/src/amm/v0.3/index.ts similarity index 100% rename from sdk2/src/amm/v0.3/index.ts rename to sdk/src/amm/v0.3/index.ts diff --git a/sdk2/src/amm/v0.3/pda.ts b/sdk/src/amm/v0.3/pda.ts similarity index 100% rename from sdk2/src/amm/v0.3/pda.ts rename to sdk/src/amm/v0.3/pda.ts diff --git a/sdk/src/v0.3/types/amm.ts b/sdk/src/amm/v0.3/types/amm.ts similarity index 100% rename from sdk/src/v0.3/types/amm.ts rename to sdk/src/amm/v0.3/types/amm.ts diff --git a/sdk2/src/amm/v0.3/types/index.ts b/sdk/src/amm/v0.3/types/index.ts similarity index 100% rename from sdk2/src/amm/v0.3/types/index.ts rename to sdk/src/amm/v0.3/types/index.ts diff --git a/sdk2/src/amm/v0.4/AmmClient.ts b/sdk/src/amm/v0.4/AmmClient.ts similarity index 100% rename from sdk2/src/amm/v0.4/AmmClient.ts rename to sdk/src/amm/v0.4/AmmClient.ts diff --git a/sdk2/src/amm/v0.4/index.ts b/sdk/src/amm/v0.4/index.ts similarity index 100% rename from sdk2/src/amm/v0.4/index.ts rename to sdk/src/amm/v0.4/index.ts diff --git a/sdk2/src/amm/v0.4/pda.ts b/sdk/src/amm/v0.4/pda.ts similarity index 100% rename from sdk2/src/amm/v0.4/pda.ts rename to sdk/src/amm/v0.4/pda.ts diff --git a/sdk/src/v0.4/types/amm.ts b/sdk/src/amm/v0.4/types/amm.ts similarity index 100% rename from sdk/src/v0.4/types/amm.ts rename to sdk/src/amm/v0.4/types/amm.ts diff --git a/sdk2/src/amm/v0.4/types/index.ts b/sdk/src/amm/v0.4/types/index.ts similarity index 100% rename from sdk2/src/amm/v0.4/types/index.ts rename to sdk/src/amm/v0.4/types/index.ts diff --git a/sdk2/src/amm/v0.5/AmmClient.ts b/sdk/src/amm/v0.5/AmmClient.ts similarity index 100% rename from sdk2/src/amm/v0.5/AmmClient.ts rename to sdk/src/amm/v0.5/AmmClient.ts diff --git a/sdk2/src/amm/v0.5/index.ts b/sdk/src/amm/v0.5/index.ts similarity index 100% rename from sdk2/src/amm/v0.5/index.ts rename to sdk/src/amm/v0.5/index.ts diff --git a/sdk2/src/amm/v0.5/pda.ts b/sdk/src/amm/v0.5/pda.ts similarity index 100% rename from sdk2/src/amm/v0.5/pda.ts rename to sdk/src/amm/v0.5/pda.ts diff --git a/sdk2/src/amm/v0.5/priceMath.ts b/sdk/src/amm/v0.5/priceMath.ts similarity index 100% rename from sdk2/src/amm/v0.5/priceMath.ts rename to sdk/src/amm/v0.5/priceMath.ts diff --git a/sdk/src/v0.5/types/amm.ts b/sdk/src/amm/v0.5/types/amm.ts similarity index 100% rename from sdk/src/v0.5/types/amm.ts rename to sdk/src/amm/v0.5/types/amm.ts diff --git a/sdk2/src/amm/v0.5/types/index.ts b/sdk/src/amm/v0.5/types/index.ts similarity index 100% rename from sdk2/src/amm/v0.5/types/index.ts rename to sdk/src/amm/v0.5/types/index.ts diff --git a/sdk2/src/autocrat/index.ts b/sdk/src/autocrat/index.ts similarity index 100% rename from sdk2/src/autocrat/index.ts rename to sdk/src/autocrat/index.ts diff --git a/sdk2/src/autocrat/v0.3/AutocratClient.ts b/sdk/src/autocrat/v0.3/AutocratClient.ts similarity index 100% rename from sdk2/src/autocrat/v0.3/AutocratClient.ts rename to sdk/src/autocrat/v0.3/AutocratClient.ts diff --git a/sdk/src/v0.3/utils/cu.ts b/sdk/src/autocrat/v0.3/cu.ts similarity index 100% rename from sdk/src/v0.3/utils/cu.ts rename to sdk/src/autocrat/v0.3/cu.ts diff --git a/sdk2/src/autocrat/v0.3/index.ts b/sdk/src/autocrat/v0.3/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.3/index.ts rename to sdk/src/autocrat/v0.3/index.ts diff --git a/sdk2/src/autocrat/v0.3/pda.ts b/sdk/src/autocrat/v0.3/pda.ts similarity index 100% rename from sdk2/src/autocrat/v0.3/pda.ts rename to sdk/src/autocrat/v0.3/pda.ts diff --git a/sdk/src/v0.3/types/autocrat.ts b/sdk/src/autocrat/v0.3/types/autocrat.ts similarity index 100% rename from sdk/src/v0.3/types/autocrat.ts rename to sdk/src/autocrat/v0.3/types/autocrat.ts diff --git a/sdk2/src/autocrat/v0.3/types/index.ts b/sdk/src/autocrat/v0.3/types/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.3/types/index.ts rename to sdk/src/autocrat/v0.3/types/index.ts diff --git a/sdk2/src/autocrat/v0.4/AutocratClient.ts b/sdk/src/autocrat/v0.4/AutocratClient.ts similarity index 100% rename from sdk2/src/autocrat/v0.4/AutocratClient.ts rename to sdk/src/autocrat/v0.4/AutocratClient.ts diff --git a/sdk2/src/autocrat/v0.4/index.ts b/sdk/src/autocrat/v0.4/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.4/index.ts rename to sdk/src/autocrat/v0.4/index.ts diff --git a/sdk2/src/autocrat/v0.4/pda.ts b/sdk/src/autocrat/v0.4/pda.ts similarity index 100% rename from sdk2/src/autocrat/v0.4/pda.ts rename to sdk/src/autocrat/v0.4/pda.ts diff --git a/sdk/src/v0.4/types/autocrat.ts b/sdk/src/autocrat/v0.4/types/autocrat.ts similarity index 100% rename from sdk/src/v0.4/types/autocrat.ts rename to sdk/src/autocrat/v0.4/types/autocrat.ts diff --git a/sdk2/src/autocrat/v0.4/types/index.ts b/sdk/src/autocrat/v0.4/types/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.4/types/index.ts rename to sdk/src/autocrat/v0.4/types/index.ts diff --git a/sdk2/src/autocrat/v0.5/AutocratClient.ts b/sdk/src/autocrat/v0.5/AutocratClient.ts similarity index 100% rename from sdk2/src/autocrat/v0.5/AutocratClient.ts rename to sdk/src/autocrat/v0.5/AutocratClient.ts diff --git a/sdk2/src/autocrat/v0.5/index.ts b/sdk/src/autocrat/v0.5/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.5/index.ts rename to sdk/src/autocrat/v0.5/index.ts diff --git a/sdk2/src/autocrat/v0.5/pda.ts b/sdk/src/autocrat/v0.5/pda.ts similarity index 100% rename from sdk2/src/autocrat/v0.5/pda.ts rename to sdk/src/autocrat/v0.5/pda.ts diff --git a/sdk/src/v0.5/types/autocrat.ts b/sdk/src/autocrat/v0.5/types/autocrat.ts similarity index 100% rename from sdk/src/v0.5/types/autocrat.ts rename to sdk/src/autocrat/v0.5/types/autocrat.ts diff --git a/sdk2/src/autocrat/v0.5/types/index.ts b/sdk/src/autocrat/v0.5/types/index.ts similarity index 100% rename from sdk2/src/autocrat/v0.5/types/index.ts rename to sdk/src/autocrat/v0.5/types/index.ts diff --git a/sdk2/src/bid_wall/index.ts b/sdk/src/bid_wall/index.ts similarity index 100% rename from sdk2/src/bid_wall/index.ts rename to sdk/src/bid_wall/index.ts diff --git a/sdk2/src/bid_wall/v0.7/BidWallClient.ts b/sdk/src/bid_wall/v0.7/BidWallClient.ts similarity index 100% rename from sdk2/src/bid_wall/v0.7/BidWallClient.ts rename to sdk/src/bid_wall/v0.7/BidWallClient.ts diff --git a/sdk2/src/bid_wall/v0.7/index.ts b/sdk/src/bid_wall/v0.7/index.ts similarity index 100% rename from sdk2/src/bid_wall/v0.7/index.ts rename to sdk/src/bid_wall/v0.7/index.ts diff --git a/sdk2/src/bid_wall/v0.7/pda.ts b/sdk/src/bid_wall/v0.7/pda.ts similarity index 100% rename from sdk2/src/bid_wall/v0.7/pda.ts rename to sdk/src/bid_wall/v0.7/pda.ts diff --git a/sdk/src/v0.7/types/bid_wall.ts b/sdk/src/bid_wall/v0.7/types/bid_wall.ts similarity index 100% rename from sdk/src/v0.7/types/bid_wall.ts rename to sdk/src/bid_wall/v0.7/types/bid_wall.ts diff --git a/sdk2/src/bid_wall/v0.7/types/index.ts b/sdk/src/bid_wall/v0.7/types/index.ts similarity index 100% rename from sdk2/src/bid_wall/v0.7/types/index.ts rename to sdk/src/bid_wall/v0.7/types/index.ts diff --git a/sdk2/src/conditional_vault/index.ts b/sdk/src/conditional_vault/index.ts similarity index 100% rename from sdk2/src/conditional_vault/index.ts rename to sdk/src/conditional_vault/index.ts diff --git a/sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts b/sdk/src/conditional_vault/v0.3/ConditionalVaultClient.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.3/ConditionalVaultClient.ts rename to sdk/src/conditional_vault/v0.3/ConditionalVaultClient.ts diff --git a/sdk2/src/conditional_vault/v0.3/index.ts b/sdk/src/conditional_vault/v0.3/index.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.3/index.ts rename to sdk/src/conditional_vault/v0.3/index.ts diff --git a/sdk2/src/conditional_vault/v0.3/pda.ts b/sdk/src/conditional_vault/v0.3/pda.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.3/pda.ts rename to sdk/src/conditional_vault/v0.3/pda.ts diff --git a/sdk/src/v0.3/types/conditional_vault.ts b/sdk/src/conditional_vault/v0.3/types/conditional_vault.ts similarity index 100% rename from sdk/src/v0.3/types/conditional_vault.ts rename to sdk/src/conditional_vault/v0.3/types/conditional_vault.ts diff --git a/sdk2/src/conditional_vault/v0.3/types/index.ts b/sdk/src/conditional_vault/v0.3/types/index.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.3/types/index.ts rename to sdk/src/conditional_vault/v0.3/types/index.ts diff --git a/sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts b/sdk/src/conditional_vault/v0.4/ConditionalVaultClient.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.4/ConditionalVaultClient.ts rename to sdk/src/conditional_vault/v0.4/ConditionalVaultClient.ts diff --git a/sdk2/src/conditional_vault/v0.4/index.ts b/sdk/src/conditional_vault/v0.4/index.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.4/index.ts rename to sdk/src/conditional_vault/v0.4/index.ts diff --git a/sdk2/src/conditional_vault/v0.4/pda.ts b/sdk/src/conditional_vault/v0.4/pda.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.4/pda.ts rename to sdk/src/conditional_vault/v0.4/pda.ts diff --git a/sdk/src/v0.7/types/conditional_vault.ts b/sdk/src/conditional_vault/v0.4/types/conditional_vault.ts similarity index 100% rename from sdk/src/v0.7/types/conditional_vault.ts rename to sdk/src/conditional_vault/v0.4/types/conditional_vault.ts diff --git a/sdk2/src/conditional_vault/v0.4/types/index.ts b/sdk/src/conditional_vault/v0.4/types/index.ts similarity index 100% rename from sdk2/src/conditional_vault/v0.4/types/index.ts rename to sdk/src/conditional_vault/v0.4/types/index.ts diff --git a/sdk2/src/constants.ts b/sdk/src/constants.ts similarity index 100% rename from sdk2/src/constants.ts rename to sdk/src/constants.ts diff --git a/sdk2/src/futarchy/index.ts b/sdk/src/futarchy/index.ts similarity index 100% rename from sdk2/src/futarchy/index.ts rename to sdk/src/futarchy/index.ts diff --git a/sdk2/src/futarchy/v0.6/FutarchyClient.ts b/sdk/src/futarchy/v0.6/FutarchyClient.ts similarity index 100% rename from sdk2/src/futarchy/v0.6/FutarchyClient.ts rename to sdk/src/futarchy/v0.6/FutarchyClient.ts diff --git a/sdk2/src/futarchy/v0.6/index.ts b/sdk/src/futarchy/v0.6/index.ts similarity index 100% rename from sdk2/src/futarchy/v0.6/index.ts rename to sdk/src/futarchy/v0.6/index.ts diff --git a/sdk2/src/futarchy/v0.6/pda.ts b/sdk/src/futarchy/v0.6/pda.ts similarity index 100% rename from sdk2/src/futarchy/v0.6/pda.ts rename to sdk/src/futarchy/v0.6/pda.ts diff --git a/sdk/src/v0.7/types/futarchy.ts b/sdk/src/futarchy/v0.6/types/futarchy.ts similarity index 100% rename from sdk/src/v0.7/types/futarchy.ts rename to sdk/src/futarchy/v0.6/types/futarchy.ts diff --git a/sdk2/src/futarchy/v0.6/types/index.ts b/sdk/src/futarchy/v0.6/types/index.ts similarity index 100% rename from sdk2/src/futarchy/v0.6/types/index.ts rename to sdk/src/futarchy/v0.6/types/index.ts diff --git a/sdk/src/v0.6/types/v0.6.0-futarchy.ts b/sdk/src/futarchy/v0.6/types/v0.6.0-futarchy.ts similarity index 100% rename from sdk/src/v0.6/types/v0.6.0-futarchy.ts rename to sdk/src/futarchy/v0.6/types/v0.6.0-futarchy.ts diff --git a/sdk/src/index.ts b/sdk/src/index.ts index bfa636c79..bd08c833a 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -1 +1,17 @@ +// Default exports for latest versions of programs +export * from "./bid_wall/index.js"; +export * from "./conditional_vault/index.js"; +export * from "./futarchy/index.js"; +export * from "./launchpad/index.js"; +export * from "./liquidation/index.js"; +export * from "./mint_governor/index.js"; +export * from "./performance_package_v2/index.js"; +export * from "./price_based_performance_package/index.js"; + +// Shared exports +export * from "./utils.js"; +export * from "./constants.js"; +export * from "./pda.js"; +export * from "./priceMath.js"; + export { sha256 } from "@noble/hashes/sha256"; diff --git a/sdk2/src/launchpad/index.ts b/sdk/src/launchpad/index.ts similarity index 100% rename from sdk2/src/launchpad/index.ts rename to sdk/src/launchpad/index.ts diff --git a/sdk2/src/launchpad/v0.4/LaunchpadClient.ts b/sdk/src/launchpad/v0.4/LaunchpadClient.ts similarity index 100% rename from sdk2/src/launchpad/v0.4/LaunchpadClient.ts rename to sdk/src/launchpad/v0.4/LaunchpadClient.ts diff --git a/sdk2/src/launchpad/v0.4/index.ts b/sdk/src/launchpad/v0.4/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.4/index.ts rename to sdk/src/launchpad/v0.4/index.ts diff --git a/sdk2/src/launchpad/v0.4/pda.ts b/sdk/src/launchpad/v0.4/pda.ts similarity index 100% rename from sdk2/src/launchpad/v0.4/pda.ts rename to sdk/src/launchpad/v0.4/pda.ts diff --git a/sdk2/src/launchpad/v0.4/types/index.ts b/sdk/src/launchpad/v0.4/types/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.4/types/index.ts rename to sdk/src/launchpad/v0.4/types/index.ts diff --git a/sdk/src/v0.4/types/launchpad.ts b/sdk/src/launchpad/v0.4/types/launchpad.ts similarity index 100% rename from sdk/src/v0.4/types/launchpad.ts rename to sdk/src/launchpad/v0.4/types/launchpad.ts diff --git a/sdk2/src/launchpad/v0.5/LaunchpadClient.ts b/sdk/src/launchpad/v0.5/LaunchpadClient.ts similarity index 100% rename from sdk2/src/launchpad/v0.5/LaunchpadClient.ts rename to sdk/src/launchpad/v0.5/LaunchpadClient.ts diff --git a/sdk2/src/launchpad/v0.5/index.ts b/sdk/src/launchpad/v0.5/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.5/index.ts rename to sdk/src/launchpad/v0.5/index.ts diff --git a/sdk2/src/launchpad/v0.5/pda.ts b/sdk/src/launchpad/v0.5/pda.ts similarity index 100% rename from sdk2/src/launchpad/v0.5/pda.ts rename to sdk/src/launchpad/v0.5/pda.ts diff --git a/sdk2/src/launchpad/v0.5/types/index.ts b/sdk/src/launchpad/v0.5/types/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.5/types/index.ts rename to sdk/src/launchpad/v0.5/types/index.ts diff --git a/sdk/src/v0.5/types/launchpad.ts b/sdk/src/launchpad/v0.5/types/launchpad.ts similarity index 100% rename from sdk/src/v0.5/types/launchpad.ts rename to sdk/src/launchpad/v0.5/types/launchpad.ts diff --git a/sdk2/src/launchpad/v0.6/LaunchpadClient.ts b/sdk/src/launchpad/v0.6/LaunchpadClient.ts similarity index 100% rename from sdk2/src/launchpad/v0.6/LaunchpadClient.ts rename to sdk/src/launchpad/v0.6/LaunchpadClient.ts diff --git a/sdk2/src/launchpad/v0.6/index.ts b/sdk/src/launchpad/v0.6/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.6/index.ts rename to sdk/src/launchpad/v0.6/index.ts diff --git a/sdk2/src/launchpad/v0.6/pda.ts b/sdk/src/launchpad/v0.6/pda.ts similarity index 100% rename from sdk2/src/launchpad/v0.6/pda.ts rename to sdk/src/launchpad/v0.6/pda.ts diff --git a/sdk2/src/launchpad/v0.6/types/index.ts b/sdk/src/launchpad/v0.6/types/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.6/types/index.ts rename to sdk/src/launchpad/v0.6/types/index.ts diff --git a/sdk/src/v0.7/types/launchpad.ts b/sdk/src/launchpad/v0.6/types/launchpad.ts similarity index 100% rename from sdk/src/v0.7/types/launchpad.ts rename to sdk/src/launchpad/v0.6/types/launchpad.ts diff --git a/sdk/src/v0.6/types/v0.6.0-launchpad.ts b/sdk/src/launchpad/v0.6/types/v0.6.0-launchpad.ts similarity index 100% rename from sdk/src/v0.6/types/v0.6.0-launchpad.ts rename to sdk/src/launchpad/v0.6/types/v0.6.0-launchpad.ts diff --git a/sdk2/src/launchpad/v0.7/LaunchpadClient.ts b/sdk/src/launchpad/v0.7/LaunchpadClient.ts similarity index 100% rename from sdk2/src/launchpad/v0.7/LaunchpadClient.ts rename to sdk/src/launchpad/v0.7/LaunchpadClient.ts diff --git a/sdk2/src/launchpad/v0.7/index.ts b/sdk/src/launchpad/v0.7/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.7/index.ts rename to sdk/src/launchpad/v0.7/index.ts diff --git a/sdk2/src/launchpad/v0.7/pda.ts b/sdk/src/launchpad/v0.7/pda.ts similarity index 100% rename from sdk2/src/launchpad/v0.7/pda.ts rename to sdk/src/launchpad/v0.7/pda.ts diff --git a/sdk2/src/launchpad/v0.7/types/index.ts b/sdk/src/launchpad/v0.7/types/index.ts similarity index 100% rename from sdk2/src/launchpad/v0.7/types/index.ts rename to sdk/src/launchpad/v0.7/types/index.ts diff --git a/sdk/src/v0.7/types/launchpad_v7.ts b/sdk/src/launchpad/v0.7/types/launchpad_v7.ts similarity index 100% rename from sdk/src/v0.7/types/launchpad_v7.ts rename to sdk/src/launchpad/v0.7/types/launchpad_v7.ts diff --git a/sdk2/src/liquidation/index.ts b/sdk/src/liquidation/index.ts similarity index 100% rename from sdk2/src/liquidation/index.ts rename to sdk/src/liquidation/index.ts diff --git a/sdk2/src/liquidation/v0.7/LiquidationClient.ts b/sdk/src/liquidation/v0.7/LiquidationClient.ts similarity index 100% rename from sdk2/src/liquidation/v0.7/LiquidationClient.ts rename to sdk/src/liquidation/v0.7/LiquidationClient.ts diff --git a/sdk2/src/liquidation/v0.7/index.ts b/sdk/src/liquidation/v0.7/index.ts similarity index 100% rename from sdk2/src/liquidation/v0.7/index.ts rename to sdk/src/liquidation/v0.7/index.ts diff --git a/sdk2/src/liquidation/v0.7/pda.ts b/sdk/src/liquidation/v0.7/pda.ts similarity index 100% rename from sdk2/src/liquidation/v0.7/pda.ts rename to sdk/src/liquidation/v0.7/pda.ts diff --git a/sdk2/src/liquidation/v0.7/types/index.ts b/sdk/src/liquidation/v0.7/types/index.ts similarity index 100% rename from sdk2/src/liquidation/v0.7/types/index.ts rename to sdk/src/liquidation/v0.7/types/index.ts diff --git a/sdk/src/v0.7/types/liquidation.ts b/sdk/src/liquidation/v0.7/types/liquidation.ts similarity index 100% rename from sdk/src/v0.7/types/liquidation.ts rename to sdk/src/liquidation/v0.7/types/liquidation.ts diff --git a/sdk2/src/mint_governor/index.ts b/sdk/src/mint_governor/index.ts similarity index 100% rename from sdk2/src/mint_governor/index.ts rename to sdk/src/mint_governor/index.ts diff --git a/sdk2/src/mint_governor/v0.7/MintGovernorClient.ts b/sdk/src/mint_governor/v0.7/MintGovernorClient.ts similarity index 100% rename from sdk2/src/mint_governor/v0.7/MintGovernorClient.ts rename to sdk/src/mint_governor/v0.7/MintGovernorClient.ts diff --git a/sdk2/src/mint_governor/v0.7/index.ts b/sdk/src/mint_governor/v0.7/index.ts similarity index 100% rename from sdk2/src/mint_governor/v0.7/index.ts rename to sdk/src/mint_governor/v0.7/index.ts diff --git a/sdk2/src/mint_governor/v0.7/pda.ts b/sdk/src/mint_governor/v0.7/pda.ts similarity index 100% rename from sdk2/src/mint_governor/v0.7/pda.ts rename to sdk/src/mint_governor/v0.7/pda.ts diff --git a/sdk2/src/mint_governor/v0.7/types/index.ts b/sdk/src/mint_governor/v0.7/types/index.ts similarity index 100% rename from sdk2/src/mint_governor/v0.7/types/index.ts rename to sdk/src/mint_governor/v0.7/types/index.ts diff --git a/sdk/src/v0.7/types/mint_governor.ts b/sdk/src/mint_governor/v0.7/types/mint_governor.ts similarity index 100% rename from sdk/src/v0.7/types/mint_governor.ts rename to sdk/src/mint_governor/v0.7/types/mint_governor.ts diff --git a/sdk2/src/pda.ts b/sdk/src/pda.ts similarity index 100% rename from sdk2/src/pda.ts rename to sdk/src/pda.ts diff --git a/sdk2/src/performance_package_v2/index.ts b/sdk/src/performance_package_v2/index.ts similarity index 100% rename from sdk2/src/performance_package_v2/index.ts rename to sdk/src/performance_package_v2/index.ts diff --git a/sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts b/sdk/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts similarity index 100% rename from sdk2/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts rename to sdk/src/performance_package_v2/v0.7/PerformancePackageV2Client.ts diff --git a/sdk2/src/performance_package_v2/v0.7/index.ts b/sdk/src/performance_package_v2/v0.7/index.ts similarity index 100% rename from sdk2/src/performance_package_v2/v0.7/index.ts rename to sdk/src/performance_package_v2/v0.7/index.ts diff --git a/sdk2/src/performance_package_v2/v0.7/pda.ts b/sdk/src/performance_package_v2/v0.7/pda.ts similarity index 100% rename from sdk2/src/performance_package_v2/v0.7/pda.ts rename to sdk/src/performance_package_v2/v0.7/pda.ts diff --git a/sdk2/src/performance_package_v2/v0.7/types/index.ts b/sdk/src/performance_package_v2/v0.7/types/index.ts similarity index 100% rename from sdk2/src/performance_package_v2/v0.7/types/index.ts rename to sdk/src/performance_package_v2/v0.7/types/index.ts diff --git a/sdk/src/v0.7/types/performance_package_v2.ts b/sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts similarity index 100% rename from sdk/src/v0.7/types/performance_package_v2.ts rename to sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts diff --git a/sdk2/src/priceMath.ts b/sdk/src/priceMath.ts similarity index 100% rename from sdk2/src/priceMath.ts rename to sdk/src/priceMath.ts diff --git a/sdk2/src/price_based_performance_package/index.ts b/sdk/src/price_based_performance_package/index.ts similarity index 100% rename from sdk2/src/price_based_performance_package/index.ts rename to sdk/src/price_based_performance_package/index.ts diff --git a/sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts b/sdk/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts similarity index 100% rename from sdk2/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts rename to sdk/src/price_based_performance_package/v0.6/PriceBasedPerformancePackageClient.ts diff --git a/sdk2/src/price_based_performance_package/v0.6/index.ts b/sdk/src/price_based_performance_package/v0.6/index.ts similarity index 100% rename from sdk2/src/price_based_performance_package/v0.6/index.ts rename to sdk/src/price_based_performance_package/v0.6/index.ts diff --git a/sdk2/src/price_based_performance_package/v0.6/pda.ts b/sdk/src/price_based_performance_package/v0.6/pda.ts similarity index 100% rename from sdk2/src/price_based_performance_package/v0.6/pda.ts rename to sdk/src/price_based_performance_package/v0.6/pda.ts diff --git a/sdk2/src/price_based_performance_package/v0.6/types/index.ts b/sdk/src/price_based_performance_package/v0.6/types/index.ts similarity index 100% rename from sdk2/src/price_based_performance_package/v0.6/types/index.ts rename to sdk/src/price_based_performance_package/v0.6/types/index.ts diff --git a/sdk/src/v0.7/types/price_based_performance_package.ts b/sdk/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts similarity index 100% rename from sdk/src/v0.7/types/price_based_performance_package.ts rename to sdk/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts diff --git a/sdk2/src/shared_liquidity_manager/index.ts b/sdk/src/shared_liquidity_manager/index.ts similarity index 100% rename from sdk2/src/shared_liquidity_manager/index.ts rename to sdk/src/shared_liquidity_manager/index.ts diff --git a/sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts b/sdk/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts similarity index 100% rename from sdk2/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts rename to sdk/src/shared_liquidity_manager/v0.5/SharedLiquidityManagerClient.ts diff --git a/sdk2/src/shared_liquidity_manager/v0.5/index.ts b/sdk/src/shared_liquidity_manager/v0.5/index.ts similarity index 100% rename from sdk2/src/shared_liquidity_manager/v0.5/index.ts rename to sdk/src/shared_liquidity_manager/v0.5/index.ts diff --git a/sdk2/src/shared_liquidity_manager/v0.5/pda.ts b/sdk/src/shared_liquidity_manager/v0.5/pda.ts similarity index 100% rename from sdk2/src/shared_liquidity_manager/v0.5/pda.ts rename to sdk/src/shared_liquidity_manager/v0.5/pda.ts diff --git a/sdk2/src/shared_liquidity_manager/v0.5/types/index.ts b/sdk/src/shared_liquidity_manager/v0.5/types/index.ts similarity index 100% rename from sdk2/src/shared_liquidity_manager/v0.5/types/index.ts rename to sdk/src/shared_liquidity_manager/v0.5/types/index.ts diff --git a/sdk/src/v0.5/types/shared_liquidity_manager.ts b/sdk/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts similarity index 100% rename from sdk/src/v0.5/types/shared_liquidity_manager.ts rename to sdk/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts diff --git a/sdk2/src/utils.ts b/sdk/src/utils.ts similarity index 100% rename from sdk2/src/utils.ts rename to sdk/src/utils.ts diff --git a/sdk/src/v0.3/AmmClient.ts b/sdk/src/v0.3/AmmClient.ts deleted file mode 100644 index ce8ef147b..000000000 --- a/sdk/src/v0.3/AmmClient.ts +++ /dev/null @@ -1,370 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { AddressLookupTableAccount, Keypair, PublicKey } from "@solana/web3.js"; - -import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; - -import BN from "bn.js"; -import { AMM_PROGRAM_ID } from "./constants.js"; -import { AmmAccount, LowercaseKeys } from "./types/index.js"; -import { getAmmLpMintAddr, getAmmAddr } from "./utils/pda.js"; -import { - MintLayout, - unpackMint, - getAssociatedTokenAddressSync, - createAssociatedTokenAccountIdempotentInstruction, -} from "@solana/spl-token"; -import { AmmMath, PriceMath } from "./utils/ammMath.js"; - -export type SwapType = LowercaseKeys["SwapType"]>; - -export type CreateAmmClientParams = { - provider: AnchorProvider; - ammProgramId?: PublicKey; -}; - -export class AmmClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.program = new Program(AmmIDL, ammProgramId, provider); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateAmmClientParams, - ): AmmClient { - let { provider, ammProgramId: programId } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AmmClient(provider, programId || AMM_PROGRAM_ID, luts); - } - - getProgramId(): PublicKey { - return this.program.programId; - } - - async createAmm( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - twapInitialObservation: number, - twapMaxObservationChangePerUpdate?: number, - ): Promise { - if (!twapMaxObservationChangePerUpdate) { - twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; - } - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - - let baseDecimals = unpackMint( - baseMint, - await this.provider.connection.getAccountInfo(baseMint), - ).decimals; - let quoteDecimals = unpackMint( - quoteMint, - await this.provider.connection.getAccountInfo(quoteMint), - ).decimals; - - let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = - PriceMath.getAmmPrices( - baseDecimals, - quoteDecimals, - twapInitialObservation, - twapMaxObservationChangePerUpdate, - ); - - await this.createAmmIx( - baseMint, - quoteMint, - twapFirstObservationScaled, - twapMaxObservationChangePerUpdateScaled, - ).rpc(); - - return amm; - } - - // both twap values need to be scaled beforehand - createAmmIx( - baseMint: PublicKey, - quoteMint: PublicKey, - twapInitialObservation: BN, - twapMaxObservationChangePerUpdate: BN, - ) { - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); - - let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); - let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); - - return this.program.methods - .createAmm({ - twapInitialObservation, - twapMaxObservationChangePerUpdate, - }) - .accounts({ - user: this.provider.publicKey, - amm, - lpMint, - baseMint, - quoteMint, - vaultAtaBase, - vaultAtaQuote, - }); - } - - async addLiquidity( - amm: PublicKey, - quoteAmount?: number, - baseAmount?: number, - ) { - let storedAmm = await this.getAmm(amm); - - let lpMintSupply = unpackMint( - storedAmm.lpMint, - await this.provider.connection.getAccountInfo(storedAmm.lpMint), - ).supply; - - let quoteAmountCasted: BN | undefined; - let baseAmountCasted: BN | undefined; - - if (quoteAmount != undefined) { - let quoteDecimals = unpackMint( - storedAmm.quoteMint, - await this.provider.connection.getAccountInfo(storedAmm.quoteMint), - ).decimals; - quoteAmountCasted = new BN(quoteAmount).mul( - new BN(10).pow(new BN(quoteDecimals)), - ); - } - - if (baseAmount != undefined) { - let baseDecimals = unpackMint( - storedAmm.baseMint, - await this.provider.connection.getAccountInfo(storedAmm.baseMint), - ).decimals; - baseAmountCasted = new BN(baseAmount).mul( - new BN(10).pow(new BN(baseDecimals)), - ); - } - - if (lpMintSupply == 0n) { - if (quoteAmount == undefined || baseAmount == undefined) { - throw new Error( - "No pool created yet, you need to specify both base and quote", - ); - } - - // console.log(quoteAmountCasted?.toString()); - // console.log(baseAmountCasted?.toString()) - - return await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - quoteAmountCasted as BN, - baseAmountCasted as BN, - new BN(0), - ).rpc(); - } - - // quoteAmount == undefined ? undefined : new BN(quoteAmount); - // let baseAmountCasted: BN | undefined = - // baseAmount == undefined ? undefined : new BN(baseAmount); - - let sim = AmmMath.simulateAddLiquidity( - storedAmm.baseAmount, - storedAmm.quoteAmount, - Number(lpMintSupply), - baseAmountCasted, - quoteAmountCasted, - ); - - await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - sim.quoteAmount, - sim.baseAmount, - sim.expectedLpTokens, - ).rpc(); - } - - addLiquidityIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - quoteAmount: BN, - maxBaseAmount: BN, - minLpTokens: BN, - user: PublicKey = this.provider.publicKey, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); - - const userLpAccount = getAssociatedTokenAddressSync(lpMint, user); - - return this.program.methods - .addLiquidity({ - quoteAmount, - maxBaseAmount, - minLpTokens, - }) - .accounts({ - user, - amm, - lpMint, - userLpAccount, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - userLpAccount, - this.provider.publicKey, - lpMint, - ), - ]); - } - - removeLiquidityIx( - ammAddr: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - lpTokensToBurn: BN, - minBaseAmount: BN, - minQuoteAmount: BN, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); - - return this.program.methods - .removeLiquidity({ - lpTokensToBurn, - minBaseAmount, - minQuoteAmount, - }) - .accounts({ - user: this.provider.publicKey, - amm: ammAddr, - lpMint, - userLpAccount: getAssociatedTokenAddressSync( - lpMint, - this.provider.publicKey, - ), - userBaseAccount: getAssociatedTokenAddressSync( - baseMint, - this.provider.publicKey, - ), - userQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - this.provider.publicKey, - ), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), - }); - } - - async swap( - amm: PublicKey, - swapType: SwapType, - inputAmount: number, - outputAmountMin: number, - ) { - const storedAmm = await this.getAmm(amm); - - let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); - let baseDecimals = await this.getDecimals(storedAmm.baseMint); - - let inputAmountScaled: BN; - let outputAmountMinScaled: BN; - if (swapType.buy) { - inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); - } else { - inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); - } - - return await this.swapIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - swapType, - inputAmountScaled, - outputAmountMinScaled, - ).rpc(); - } - - swapIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - swapType: SwapType, - inputAmount: BN, - outputAmountMin: BN, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const receivingToken = swapType.buy ? baseMint : quoteMint; - - return this.program.methods - .swap({ - swapType, - inputAmount, - outputAmountMin, - }) - .accounts({ - user, - amm, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - // create the receiving token account if it doesn't exist - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(receivingToken, user), - user, - receivingToken, - ), - ]); - } - - async crankThatTwap(amm: PublicKey) { - return this.crankThatTwapIx(amm).rpc(); - } - - crankThatTwapIx(amm: PublicKey) { - return this.program.methods.crankThatTwap().accounts({ - amm, - }); - } - - // getter functions - - // async getLTWAP(ammAddr: PublicKey): Promise { - // const amm = await this.program.account.amm.fetch(ammAddr); - // return amm.twapLastObservationUq64X32 - // .div(new BN(2).pow(new BN(32))) - // .toNumber(); - // } - - async getAmm(amm: PublicKey): Promise { - return await this.program.account.amm.fetch(amm); - } - - async getDecimals(mint: PublicKey): Promise { - return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) - .decimals; - } -} diff --git a/sdk/src/v0.3/AutocratClient.ts b/sdk/src/v0.3/AutocratClient.ts deleted file mode 100644 index 8f63b1992..000000000 --- a/sdk/src/v0.3/AutocratClient.ts +++ /dev/null @@ -1,723 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountMeta, - AddressLookupTableAccount, - ComputeBudgetProgram, - Connection, - Keypair, - PublicKey, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { PriceMath } from "./utils/ammMath.js"; -import { ProposalInstruction, InitializeDaoParams } from "./types/index.js"; - -import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; - -import BN from "bn.js"; -import { - AMM_PROGRAM_ID, - AUTOCRAT_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - MAINNET_USDC, - USDC_DECIMALS, -} from "./constants.js"; -import { - DEFAULT_CU_PRICE, - InstructionUtils, - MaxCUs, - getAmmAddr, - getAmmLpMintAddr, - getDaoTreasuryAddr, - getProposalAddr, - getVaultAddr, - getVaultFinalizeMintAddr, - getVaultRevertMintAddr, -} from "./utils/index.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { AmmClient } from "./AmmClient.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - unpackMint, -} from "@solana/spl-token"; -import { DaoAccount, Proposal } from "./types/index.js"; - -export type CreateClientParams = { - provider: AnchorProvider; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export type ProposalVaults = { - baseVault: PublicKey; - quoteVault: PublicKey; -}; - -export class AutocratClient { - public readonly provider: AnchorProvider; - public readonly autocrat: Program; - public readonly vaultClient: ConditionalVaultClient; - public readonly ammClient: AmmClient; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - autocratProgramId: PublicKey, - conditionalVaultProgramId: PublicKey, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.autocrat = new Program( - AutocratIDL, - autocratProgramId, - provider, - ); - this.vaultClient = ConditionalVaultClient.createClient({ - provider, - conditionalVaultProgramId, - }); - this.ammClient = AmmClient.createClient({ provider, ammProgramId }); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateClientParams, - ): AutocratClient { - let { - provider, - autocratProgramId, - conditionalVaultProgramId, - ammProgramId, - } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AutocratClient( - provider, - autocratProgramId || AUTOCRAT_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ammProgramId || AMM_PROGRAM_ID, - luts, - ); - } - - async getProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetch(proposal); - } - - async getDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetch(dao); - } - - getProposalPdas( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - dao: PublicKey, - ): { - baseVault: PublicKey; - quoteVault: PublicKey; - passBaseMint: PublicKey; - passQuoteMint: PublicKey; - failBaseMint: PublicKey; - failQuoteMint: PublicKey; - passAmm: PublicKey; - failAmm: PublicKey; - passLp: PublicKey; - failLp: PublicKey; - } { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const [baseVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - proposal, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - proposal, - quoteMint, - ); - - const [passBaseMint] = getVaultFinalizeMintAddr(vaultProgramId, baseVault); - const [passQuoteMint] = getVaultFinalizeMintAddr( - vaultProgramId, - quoteVault, - ); - - const [failBaseMint] = getVaultRevertMintAddr(vaultProgramId, baseVault); - const [failQuoteMint] = getVaultRevertMintAddr(vaultProgramId, quoteVault); - - const [passAmm] = getAmmAddr( - this.ammClient.program.programId, - passBaseMint, - passQuoteMint, - ); - const [failAmm] = getAmmAddr( - this.ammClient.program.programId, - failBaseMint, - failQuoteMint, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - return { - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - passAmm, - failAmm, - passLp, - failLp, - }; - } - - async initializeDao( - tokenMint: PublicKey, - tokenPriceUiAmount: number, - minBaseFutarchicLiquidity: number, - minQuoteFutarchicLiquidity: number, - usdcMint: PublicKey = MAINNET_USDC, - daoKeypair: Keypair = Keypair.generate(), - ): Promise { - let tokenDecimals = unpackMint( - tokenMint, - await this.provider.connection.getAccountInfo(tokenMint), - ).decimals; - - let scaledPrice = PriceMath.getAmmPrice( - tokenPriceUiAmount, - tokenDecimals, - USDC_DECIMALS, - ); - - // console.log( - // PriceMath.getHumanPrice(scaledPrice, tokenDecimals, USDC_DECIMALS) - // ); - - await this.initializeDaoIx( - daoKeypair, - tokenMint, - { - twapInitialObservation: scaledPrice, - twapMaxObservationChangePerUpdate: scaledPrice.divn(50), - minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( - new BN(10).pow(new BN(USDC_DECIMALS)), - ), - minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( - new BN(10).pow(new BN(tokenDecimals)), - ), - passThresholdBps: null, - slotsPerProposal: null, - }, - usdcMint, - ) - .postInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ - units: MaxCUs.initializeDao, - }), - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: DEFAULT_CU_PRICE, - }), - ]) - .rpc({ maxRetries: 5 }); - - return daoKeypair.publicKey; - } - - initializeDaoIx( - daoKeypair: Keypair, - tokenMint: PublicKey, - params: InitializeDaoParams, - usdcMint: PublicKey = MAINNET_USDC, - payer: PublicKey = this.provider.publicKey, - ) { - return this.autocrat.methods - .initializeDao(params) - .accounts({ - dao: daoKeypair.publicKey, - tokenMint, - usdcMint, - payer, - }) - .signers([daoKeypair]); - } - - async initializeProposal( - dao: PublicKey, - descriptionUrl: string, - instruction: ProposalInstruction, - baseTokensToLP: BN, - quoteTokensToLP: BN, - ): Promise { - const storedDao = await this.getDao(dao); - - const nonce = new BN(Math.random() * 2 ** 50); - - let [proposal] = getProposalAddr( - this.autocrat.programId, - this.provider.publicKey, - nonce, - ); - - const { - baseVault, - quoteVault, - passAmm, - failAmm, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas( - proposal, - storedDao.tokenMint, - storedDao.usdcMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - await this.vaultClient - .initializeVaultIx(proposal, storedDao.tokenMint) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), - this.ammClient.createAmmIx( - passBaseMint, - passQuoteMint, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - this.ammClient.createAmmIx( - failBaseMint, - failQuoteMint, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - ), - ) - .rpc(); - - await this.vaultClient - .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.mintConditionalTokensIx( - quoteVault, - storedDao.usdcMint, - quoteTokensToLP, - ), - ), - ) - .rpc(); - - await this.ammClient - .addLiquidityIx( - passAmm, - passBaseMint, - passQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ) - .postInstructions( - await InstructionUtils.getInstructions( - this.ammClient.addLiquidityIx( - failAmm, - failBaseMint, - failQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ), - ), - ) - .rpc(); - - // this is how many original tokens are created - const lpTokens = quoteTokensToLP; - - await this.initializeProposalIx( - descriptionUrl, - instruction, - dao, - storedDao.tokenMint, - storedDao.usdcMint, - lpTokens, - lpTokens, - nonce, - ).rpc(); - - return proposal; - } - - async createProposalTxAndPDAs( - dao: PublicKey, - descriptionUrl: string, - instruction: ProposalInstruction, - baseTokensToLP: BN, - quoteTokensToLP: BN, - ): Promise< - [ - Transaction[], - { - proposalAcct: PublicKey; - baseCondVaultAcct: PublicKey; - quoteCondVaultAcct: PublicKey; - passMarketAcct: PublicKey; - failMarketAcct: PublicKey; - }, - ] - > { - const storedDao = await this.getDao(dao); - - const nonce = new BN(Math.random() * 2 ** 50); - - let [proposal] = getProposalAddr( - this.autocrat.programId, - this.provider.publicKey, - nonce, - ); - - const { - baseVault, - quoteVault, - passAmm, - failAmm, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas( - proposal, - storedDao.tokenMint, - storedDao.usdcMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - const initVaultTx = await this.vaultClient - .initializeVaultIx(proposal, storedDao.tokenMint) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), - this.ammClient.createAmmIx( - passBaseMint, - passQuoteMint, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - this.ammClient.createAmmIx( - failBaseMint, - failQuoteMint, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - ), - ) - .transaction(); - - const mintConditionalTokensTx = await this.vaultClient - .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.mintConditionalTokensIx( - quoteVault, - storedDao.usdcMint, - quoteTokensToLP, - ), - ), - ) - .transaction(); - - const addLiquidityTx = await this.ammClient - .addLiquidityIx( - passAmm, - passBaseMint, - passQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ) - .postInstructions( - await InstructionUtils.getInstructions( - this.ammClient.addLiquidityIx( - failAmm, - failBaseMint, - failQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ), - ), - ) - .transaction(); - - // this is how many original tokens are created - const lpTokens = quoteTokensToLP; - - const initTx = await this.initializeProposalIx( - descriptionUrl, - instruction, - dao, - storedDao.tokenMint, - storedDao.usdcMint, - lpTokens, - lpTokens, - nonce, - ).transaction(); - - return [ - [initVaultTx, mintConditionalTokensTx, addLiquidityTx, initTx], - { - baseCondVaultAcct: baseVault, - quoteCondVaultAcct: quoteVault, - failMarketAcct: failAmm, - passMarketAcct: passAmm, - proposalAcct: proposal, - }, - ]; - } - - initializeProposalIx( - descriptionUrl: string, - instruction: ProposalInstruction, - dao: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - passLpTokensToLock: BN, - failLpTokensToLock: BN, - nonce: BN, - ) { - let [proposal] = getProposalAddr( - this.autocrat.programId, - this.provider.publicKey, - nonce, - ); - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( - proposal, - baseMint, - quoteMint, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - const passLpVaultAccount = getAssociatedTokenAddressSync( - passLp, - daoTreasury, - true, - ); - const failLpVaultAccount = getAssociatedTokenAddressSync( - failLp, - daoTreasury, - true, - ); - - return this.autocrat.methods - .initializeProposal({ - descriptionUrl, - instruction, - passLpTokensToLock, - failLpTokensToLock, - nonce, - }) - .accounts({ - proposal, - dao, - baseVault, - quoteVault, - passAmm, - failAmm, - passLpMint: passLp, - failLpMint: failLp, - passLpUserAccount: getAssociatedTokenAddressSync( - passLp, - this.provider.publicKey, - ), - failLpUserAccount: getAssociatedTokenAddressSync( - failLp, - this.provider.publicKey, - ), - passLpVaultAccount, - failLpVaultAccount, - proposer: this.provider.publicKey, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - passLpVaultAccount, - daoTreasury, - passLp, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - failLpVaultAccount, - daoTreasury, - failLp, - ), - ]); - } - - async finalizeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - let storedDao = await this.getDao(storedProposal.dao); - - return this.finalizeProposalIx( - proposal, - storedProposal.instruction, - storedProposal.dao, - storedDao.tokenMint, - storedDao.usdcMint, - storedProposal.proposer, - ).rpc(); - } - - finalizeProposalIx( - proposal: PublicKey, - instruction: any, - dao: PublicKey, - daoToken: PublicKey, - usdc: PublicKey, - proposer: PublicKey, - ) { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( - proposal, - daoToken, - usdc, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - return this.autocrat.methods.finalizeProposal().accounts({ - proposal, - passAmm, - failAmm, - dao, - baseVault, - quoteVault, - passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer), - failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer), - passLpVaultAccount: getAssociatedTokenAddressSync( - passLp, - daoTreasury, - true, - ), - failLpVaultAccount: getAssociatedTokenAddressSync( - failLp, - daoTreasury, - true, - ), - vaultProgram: this.vaultClient.vaultProgram.programId, - treasury: daoTreasury, - }); - } - - async executeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - - return this.executeProposalIx( - proposal, - storedProposal.dao, - storedProposal.instruction, - ).rpc(); - } - - executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - return this.autocrat.methods - .executeProposal() - .accounts({ - proposal, - dao, - // daoTreasury, - }) - .remainingAccounts( - instruction.accounts - .concat({ - pubkey: instruction.programId, - isWritable: false, - isSigner: false, - }) - .map((meta: AccountMeta) => - meta.pubkey.equals(daoTreasury) - ? { ...meta, isSigner: false } - : meta, - ), - ); - } - - // cranks the TWAPs of multiple proposals' markets. there's a limit on the - // number of proposals you can pass in, which I can't determine rn because - // there aren't enough proposals on devnet - async crankProposalMarkets( - proposals: PublicKey[], - priorityFeeMicroLamports: number, - ) { - const amms: PublicKey[] = []; - - for (const proposal of proposals) { - const storedProposal = await this.getProposal(proposal); - amms.push(storedProposal.passAmm); - amms.push(storedProposal.failAmm); - } - - while (true) { - let ixs: TransactionInstruction[] = []; - - for (const amm of amms) { - ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); - } - - let tx = new Transaction(); - tx.add( - ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), - ); - tx.add( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: priorityFeeMicroLamports, - }), - ); - tx.add(...ixs); - try { - await this.provider.sendAndConfirm(tx); - } catch (err) { - console.log("err", err); - } - - await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds - } - } -} diff --git a/sdk/src/v0.3/ConditionalVaultClient.ts b/sdk/src/v0.3/ConditionalVaultClient.ts deleted file mode 100644 index ca27bef91..000000000 --- a/sdk/src/v0.3/ConditionalVaultClient.ts +++ /dev/null @@ -1,348 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { AddressLookupTableAccount, Keypair, PublicKey } from "@solana/web3.js"; - -import { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./types/conditional_vault.js"; - -import BN from "bn.js"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, -} from "./constants.js"; -import { - getMetadataAddr, - getVaultAddr, - getVaultFinalizeMintAddr, - getVaultRevertMintAddr, -} from "./utils/index.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; - -export type CreateVaultClientParams = { - provider: AnchorProvider; - conditionalVaultProgramId?: PublicKey; -}; - -export class ConditionalVaultClient { - public readonly provider: AnchorProvider; - public readonly vaultProgram: Program; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - conditionalVaultProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.vaultProgram = new Program( - ConditionalVaultIDL, - conditionalVaultProgramId, - provider, - ); - this.luts = luts; - } - - public static createClient( - createVaultClientParams: CreateVaultClientParams, - ): ConditionalVaultClient { - let { provider, conditionalVaultProgramId } = createVaultClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new ConditionalVaultClient( - provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - luts, - ); - } - - async getVault(vault: PublicKey) { - return this.vaultProgram.account.conditionalVault.fetch(vault); - } - - async mintConditionalTokens( - vault: PublicKey, - uiAmount: number, - user: PublicKey = this.provider.publicKey, - ) { - const storedVault = await this.getVault(vault); - - return ( - this.mintConditionalTokensIx( - vault, - storedVault.underlyingTokenMint, - new BN(uiAmount).mul(new BN(10).pow(new BN(storedVault.decimals))), - user, - ) - // .preInstructions([ - // createAssociatedTokenAccountIdempotentInstruction(this.provider.publicKey, ) - // ]) - .rpc() - ); - } - - mintConditionalTokensIx( - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( - this.vaultProgram.programId, - vault, - ); - const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( - this.vaultProgram.programId, - vault, - ); - - let userConditionalOnFinalizeTokenAccount = getAssociatedTokenAddressSync( - conditionalOnFinalizeTokenMint, - user, - ); - - let userConditionalOnRevertTokenAccount = getAssociatedTokenAddressSync( - conditionalOnRevertTokenMint, - user, - ); - - let ix = this.vaultProgram.methods - .mintConditionalTokens(amount) - .accounts({ - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - conditionalOnFinalizeTokenMint, - userConditionalOnFinalizeTokenAccount, - conditionalOnRevertTokenMint, - userConditionalOnRevertTokenAccount, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - userConditionalOnFinalizeTokenAccount, - user, - conditionalOnFinalizeTokenMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - payer, - userConditionalOnRevertTokenAccount, - user, - conditionalOnRevertTokenMint, - ), - ]); - - return ix; - } - - initializeVaultIx( - settlementAuthority: PublicKey, - underlyingTokenMint: PublicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - settlementAuthority, - underlyingTokenMint, - ); - - const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( - this.vaultProgram.programId, - vault, - ); - const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( - this.vaultProgram.programId, - vault, - ); - - const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ); - - return this.vaultProgram.methods - .initializeConditionalVault({ settlementAuthority }) - .accounts({ - vault, - underlyingTokenMint, - vaultUnderlyingTokenAccount, - conditionalOnFinalizeTokenMint, - conditionalOnRevertTokenMint, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - vaultUnderlyingTokenAccount, - vault, - underlyingTokenMint, - ), - ]); - } - - addMetadataToConditionalTokensIx( - vault: PublicKey, - underlyingTokenMint: PublicKey, - proposalNumber: number, - onFinalizeUri: string, - onRevertUri: string, - payer: PublicKey = this.provider.publicKey, - ) { - const [underlyingTokenMetadata] = getMetadataAddr(underlyingTokenMint); - - const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( - this.vaultProgram.programId, - vault, - ); - const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( - this.vaultProgram.programId, - vault, - ); - - const [conditionalOnFinalizeTokenMetadata] = getMetadataAddr( - conditionalOnFinalizeTokenMint, - ); - - const [conditionalOnRevertTokenMetadata] = getMetadataAddr( - conditionalOnRevertTokenMint, - ); - - return this.vaultProgram.methods - .addMetadataToConditionalTokens({ - proposalNumber: new BN(proposalNumber), - onFinalizeUri, - onRevertUri, - }) - .accounts({ - payer, - vault, - underlyingTokenMint, - underlyingTokenMetadata, - conditionalOnFinalizeTokenMint, - conditionalOnRevertTokenMint, - conditionalOnFinalizeTokenMetadata, - conditionalOnRevertTokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - }); - } - - redeemConditionalTokensIx( - vault: PublicKey, - underlyingTokenMint: PublicKey, - user: PublicKey = this.provider.publicKey, - ) { - const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( - this.vaultProgram.programId, - vault, - ); - const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( - this.vaultProgram.programId, - vault, - ); - - return this.vaultProgram.methods - .redeemConditionalTokensForUnderlyingTokens() - .accounts({ - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - conditionalOnFinalizeTokenMint, - userConditionalOnFinalizeTokenAccount: getAssociatedTokenAddressSync( - conditionalOnFinalizeTokenMint, - user, - ), - conditionalOnRevertTokenMint, - userConditionalOnRevertTokenAccount: getAssociatedTokenAddressSync( - conditionalOnRevertTokenMint, - user, - ), - }); - } - - mergeConditionalTokensIx( - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - user: PublicKey = this.provider.publicKey, - ) { - const [conditionalOnFinalizeTokenMint] = getVaultFinalizeMintAddr( - this.vaultProgram.programId, - vault, - ); - const [conditionalOnRevertTokenMint] = getVaultRevertMintAddr( - this.vaultProgram.programId, - vault, - ); - - return this.vaultProgram.methods - .mergeConditionalTokensForUnderlyingTokens(amount) - .accounts({ - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - conditionalOnFinalizeTokenMint, - userConditionalOnFinalizeTokenAccount: getAssociatedTokenAddressSync( - conditionalOnFinalizeTokenMint, - user, - ), - conditionalOnRevertTokenMint, - userConditionalOnRevertTokenAccount: getAssociatedTokenAddressSync( - conditionalOnRevertTokenMint, - user, - ), - }); - } - - async initializeVault( - settlementAuthority: PublicKey, - underlyingTokenMint: PublicKey, - payer: PublicKey = this.provider.publicKey, - ): Promise { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - settlementAuthority, - underlyingTokenMint, - ); - - await this.initializeVaultIx( - settlementAuthority, - underlyingTokenMint, - payer, - ).rpc(); - - return vault; - } -} diff --git a/sdk/src/v0.3/FutarchyClient.ts b/sdk/src/v0.3/FutarchyClient.ts deleted file mode 100644 index e30f7a7db..000000000 --- a/sdk/src/v0.3/FutarchyClient.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { AnchorProvider } from "@coral-xyz/anchor"; -import { PublicKey, Transaction } from "@solana/web3.js"; -import BN from "bn.js"; -import { AmmClient, SwapType } from "./AmmClient.js"; -import { AutocratClient } from "./AutocratClient.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { - getAmmAddr, - getVaultAddr, - getVaultFinalizeMintAddr, - getVaultRevertMintAddr, -} from "./utils/pda.js"; - -export class FutarchyClient { - public readonly provider: AnchorProvider; - public readonly ammClient: AmmClient; - public readonly autocratClient: AutocratClient; - public readonly conditionalVaultClient: ConditionalVaultClient; - - constructor(provider: AnchorProvider) { - this.provider = provider; - this.ammClient = AmmClient.createClient({ provider }); - this.autocratClient = AutocratClient.createClient({ provider }); - this.conditionalVaultClient = ConditionalVaultClient.createClient({ - provider, - }); - } - - public static createClient({ - provider, - }: { - provider: AnchorProvider; - }): FutarchyClient { - return new FutarchyClient(provider); - } - - public async createMintAndSwapTx({ - proposal, - inputAmount, - quoteMint, - baseMint, - user, - payer, - swapType, - outcome, - conditionalAmount, - }: { - proposal: PublicKey; - inputAmount: BN; - quoteMint: PublicKey; - baseMint: PublicKey; - user: PublicKey; - payer: PublicKey; - swapType: SwapType; - outcome: "pass" | "fail"; - conditionalAmount?: BN; - }): Promise { - const [baseVault] = getVaultAddr( - this.conditionalVaultClient.vaultProgram.programId, - proposal, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.conditionalVaultClient.vaultProgram.programId, - proposal, - quoteMint, - ); - - const [underlyingVault, underlyingTokenMint] = swapType.buy - ? [quoteVault, quoteMint] - : [baseVault, baseMint]; - - let mintTx: Transaction | undefined; - - // Check to see if we need to mint conditional tokens - // If conditionalAmount is not passed we will mint all of the input amount - // If conditionalAmount is passed we will mint the difference between the input amount and the conditional amount - if ( - !conditionalAmount || - (conditionalAmount && conditionalAmount.lt(inputAmount)) - ) { - const mintAmount = conditionalAmount - ? inputAmount.sub(conditionalAmount) - : inputAmount; - - mintTx = await this.conditionalVaultClient - .mintConditionalTokensIx( - underlyingVault, - underlyingTokenMint, - mintAmount, - user, - payer, - ) - .transaction(); - } - - const [pUSDC] = getVaultFinalizeMintAddr( - this.conditionalVaultClient.vaultProgram.programId, - quoteVault, - ); - const [pTOKE] = getVaultFinalizeMintAddr( - this.conditionalVaultClient.vaultProgram.programId, - baseVault, - ); - - const [fUSDC] = getVaultRevertMintAddr( - this.conditionalVaultClient.vaultProgram.programId, - quoteVault, - ); - const [fTOKE] = getVaultRevertMintAddr( - this.conditionalVaultClient.vaultProgram.programId, - baseVault, - ); - - const [passMarket] = getAmmAddr( - this.ammClient.program.programId, - pTOKE, - pUSDC, - ); - const [failMarket] = getAmmAddr( - this.ammClient.program.programId, - fTOKE, - fUSDC, - ); - - const [market, ammBaseMint, ammQuoteMint] = - outcome === "pass" - ? [passMarket, pTOKE, pUSDC] - : [failMarket, fTOKE, fUSDC]; - - const swapTx = await this.ammClient - .swapIx( - market, - ammBaseMint, - ammQuoteMint, - swapType, - inputAmount, - new BN(0), - user, - payer, - ) - .transaction(); - - return mintTx ? new Transaction().add(mintTx, swapTx) : swapTx; - } -} diff --git a/sdk/src/v0.3/constants.ts b/sdk/src/v0.3/constants.ts deleted file mode 100644 index 6797d5afd..000000000 --- a/sdk/src/v0.3/constants.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PublicKey } from "@solana/web3.js"; - -export const AUTOCRAT_PROGRAM_ID = new PublicKey( - "autoQP9RmUNkzzKRXsMkWicDVZ3h29vvyMDcAYjCxxg", -); -export const AMM_PROGRAM_ID = new PublicKey( - "AMM5G2nxuKUwCLRYTW7qqEwuoqCtNSjtbipwEmm2g8bH", -); -export const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( - "VAU1T7S5UuEHmMvXtXMVmpEoQtZ2ya7eRb7gcN47wDp", -); - -export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", -); - -export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", -); -export const MAINNET_USDC = new PublicKey( - "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", -); - -export const USDC_DECIMALS = 6; - -export const AUTOCRAT_LUTS: PublicKey[] = []; diff --git a/sdk/src/v0.3/index.ts b/sdk/src/v0.3/index.ts deleted file mode 100644 index 0eb16f622..000000000 --- a/sdk/src/v0.3/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from "./types/index.js"; -export * from "./utils/index.js"; -export * from "./constants.js"; -export * from "./AmmClient.js"; -export * from "./AutocratClient.js"; -export * from "./ConditionalVaultClient.js"; -export * from "./FutarchyClient.js"; diff --git a/sdk/src/v0.3/types/autocrat_migrator.ts b/sdk/src/v0.3/types/autocrat_migrator.ts deleted file mode 100644 index 676d2df3d..000000000 --- a/sdk/src/v0.3/types/autocrat_migrator.ts +++ /dev/null @@ -1,237 +0,0 @@ -export type AutocratMigrator = { - version: "0.1.0"; - name: "autocrat_migrator"; - instructions: [ - { - name: "multiTransfer2"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "multiTransfer4"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "from2"; - isMut: true; - isSigner: false; - }, - { - name: "to2"; - isMut: true; - isSigner: false; - }, - { - name: "from3"; - isMut: true; - isSigner: false; - }, - { - name: "to3"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; -}; - -export const IDL: AutocratMigrator = { - version: "0.1.0", - name: "autocrat_migrator", - instructions: [ - { - name: "multiTransfer2", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "multiTransfer4", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "from2", - isMut: true, - isSigner: false, - }, - { - name: "to2", - isMut: true, - isSigner: false, - }, - { - name: "from3", - isMut: true, - isSigner: false, - }, - { - name: "to3", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], -}; diff --git a/sdk/src/v0.3/types/index.ts b/sdk/src/v0.3/types/index.ts deleted file mode 100644 index a372237a8..000000000 --- a/sdk/src/v0.3/types/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Autocrat } from "./autocrat.js"; -export { Autocrat, IDL as AutocratIDL } from "./autocrat.js"; - -import { Amm } from "./amm.js"; -export { Amm, IDL as AmmIDL } from "./amm.js"; - -import { ConditionalVault } from "./conditional_vault.js"; -export { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./conditional_vault.js"; - -export { LowercaseKeys } from "./utils.js"; - -import type { IdlAccounts, IdlTypes } from "@coral-xyz/anchor"; -import { PublicKey } from "@solana/web3.js"; - -export type InitializeDaoParams = IdlTypes["InitializeDaoParams"]; -export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; -export type ProposalInstruction = IdlTypes["ProposalInstruction"]; - -export type Proposal = IdlAccounts["proposal"]; -export type ProposalWrapper = { - account: Proposal; - publicKey: PublicKey; -}; - -export type DaoAccount = IdlAccounts["dao"]; -export type ProposalAccount = IdlAccounts["proposal"]; - -export type AmmAccount = IdlAccounts["amm"]; - -export type ConditionalVaultAccount = - IdlAccounts["conditionalVault"]; diff --git a/sdk/src/v0.3/types/optimistic_timelock.ts b/sdk/src/v0.3/types/optimistic_timelock.ts deleted file mode 100644 index fa1f43135..000000000 --- a/sdk/src/v0.3/types/optimistic_timelock.ts +++ /dev/null @@ -1,1023 +0,0 @@ -export type OptimisticTimelock = { - version: "0.3.0"; - name: "optimistic_timelock"; - instructions: [ - { - name: "createTimelock"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: true; - isSigner: true; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "enqueuers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "enqueuerCooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setDelayInSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "delayInSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setAuthority"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - ]; - }, - { - name: "setOptimisticProposerCooldownSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "cooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "addOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "enqueuer"; - type: "publicKey"; - }, - ]; - }, - { - name: "removeOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "optimisticProposer"; - type: "publicKey"; - }, - ]; - }, - { - name: "createTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "addTransaction"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }, - { - name: "sealTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "enqueueTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeTransactionBatch"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "timelock"; - type: { - kind: "struct"; - fields: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "signerBump"; - type: "u8"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "optimisticProposers"; - type: { - vec: { - defined: "OptimisticProposer"; - }; - }; - }, - { - name: "optimisticProposerCooldownSlots"; - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "transactionBatch"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "TransactionBatchStatus"; - }; - }, - { - name: "transactions"; - type: { - vec: { - defined: "Transaction"; - }; - }; - }, - { - name: "timelock"; - type: "publicKey"; - }, - { - name: "enqueuedSlot"; - type: "u64"; - }, - { - name: "transactionBatchAuthority"; - type: "publicKey"; - }, - { - name: "enqueuerType"; - type: { - defined: "AuthorityType"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "OptimisticProposer"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "lastSlotEnqueued"; - type: "u64"; - }, - ]; - }; - }, - { - name: "Transaction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - { - name: "didExecute"; - type: "bool"; - }, - ]; - }; - }, - { - name: "TransactionAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "AuthorityType"; - type: { - kind: "enum"; - variants: [ - { - name: "OptimisticProposer"; - }, - { - name: "TimelockAuthority"; - }, - ]; - }; - }, - { - name: "TransactionBatchStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Created"; - }, - { - name: "Sealed"; - }, - { - name: "Enqueued"; - }, - { - name: "Cancelled"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NotReady"; - msg: "This transaction is not yet ready to be executed"; - }, - { - code: 6001; - name: "CannotAddTransactions"; - msg: "Can only add instructions when transaction batch status is `Created`"; - }, - { - code: 6002; - name: "CannotSealTransactionBatch"; - msg: "Can only seal the transaction batch when status is `Created`"; - }, - { - code: 6003; - name: "CannotEnqueueTransactionBatch"; - msg: "Can only enqueue the timelock running once the status is `Sealed`"; - }, - { - code: 6004; - name: "CannotCancelTimelock"; - msg: "Can only cancel the transactions if the status `Enqueued`"; - }, - { - code: 6005; - name: "CanOnlyCancelDuringTimelockPeriod"; - msg: "Can only cancel the transactions during the timelock period"; - }, - { - code: 6006; - name: "CannotExecuteTransactions"; - msg: "Can only execute the transactions if the status is `Enqueued`"; - }, - { - code: 6007; - name: "NoAuthority"; - msg: "The signer is neither the timelock authority nor an optimistic proposer"; - }, - { - code: 6008; - name: "InsufficientPermissions"; - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority"; - }, - { - code: 6009; - name: "OptimisticProposerCooldown"; - msg: "This optimistic proposer is still in its cooldown period"; - }, - ]; -}; - -export const IDL: OptimisticTimelock = { - version: "0.3.0", - name: "optimistic_timelock", - instructions: [ - { - name: "createTimelock", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: true, - isSigner: true, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "enqueuers", - type: { - vec: "publicKey", - }, - }, - { - name: "enqueuerCooldownSlots", - type: "u64", - }, - ], - }, - { - name: "setDelayInSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "delayInSlots", - type: "u64", - }, - ], - }, - { - name: "setAuthority", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - ], - }, - { - name: "setOptimisticProposerCooldownSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "cooldownSlots", - type: "u64", - }, - ], - }, - { - name: "addOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "enqueuer", - type: "publicKey", - }, - ], - }, - { - name: "removeOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "optimisticProposer", - type: "publicKey", - }, - ], - }, - { - name: "createTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: true, - }, - ], - args: [], - }, - { - name: "addTransaction", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - { - name: "sealTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "enqueueTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeTransactionBatch", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "timelock", - type: { - kind: "struct", - fields: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "signerBump", - type: "u8", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "optimisticProposers", - type: { - vec: { - defined: "OptimisticProposer", - }, - }, - }, - { - name: "optimisticProposerCooldownSlots", - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "transactionBatch", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "TransactionBatchStatus", - }, - }, - { - name: "transactions", - type: { - vec: { - defined: "Transaction", - }, - }, - }, - { - name: "timelock", - type: "publicKey", - }, - { - name: "enqueuedSlot", - type: "u64", - }, - { - name: "transactionBatchAuthority", - type: "publicKey", - }, - { - name: "enqueuerType", - type: { - defined: "AuthorityType", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "OptimisticProposer", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "lastSlotEnqueued", - type: "u64", - }, - ], - }, - }, - { - name: "Transaction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - { - name: "didExecute", - type: "bool", - }, - ], - }, - }, - { - name: "TransactionAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "AuthorityType", - type: { - kind: "enum", - variants: [ - { - name: "OptimisticProposer", - }, - { - name: "TimelockAuthority", - }, - ], - }, - }, - { - name: "TransactionBatchStatus", - type: { - kind: "enum", - variants: [ - { - name: "Created", - }, - { - name: "Sealed", - }, - { - name: "Enqueued", - }, - { - name: "Cancelled", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NotReady", - msg: "This transaction is not yet ready to be executed", - }, - { - code: 6001, - name: "CannotAddTransactions", - msg: "Can only add instructions when transaction batch status is `Created`", - }, - { - code: 6002, - name: "CannotSealTransactionBatch", - msg: "Can only seal the transaction batch when status is `Created`", - }, - { - code: 6003, - name: "CannotEnqueueTransactionBatch", - msg: "Can only enqueue the timelock running once the status is `Sealed`", - }, - { - code: 6004, - name: "CannotCancelTimelock", - msg: "Can only cancel the transactions if the status `Enqueued`", - }, - { - code: 6005, - name: "CanOnlyCancelDuringTimelockPeriod", - msg: "Can only cancel the transactions during the timelock period", - }, - { - code: 6006, - name: "CannotExecuteTransactions", - msg: "Can only execute the transactions if the status is `Enqueued`", - }, - { - code: 6007, - name: "NoAuthority", - msg: "The signer is neither the timelock authority nor an optimistic proposer", - }, - { - code: 6008, - name: "InsufficientPermissions", - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority", - }, - { - code: 6009, - name: "OptimisticProposerCooldown", - msg: "This optimistic proposer is still in its cooldown period", - }, - ], -}; diff --git a/sdk/src/v0.3/types/utils.ts b/sdk/src/v0.3/types/utils.ts deleted file mode 100644 index c878debe7..000000000 --- a/sdk/src/v0.3/types/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; -}; diff --git a/sdk/src/v0.3/utils/ammMath.ts b/sdk/src/v0.3/utils/ammMath.ts deleted file mode 100644 index a6e542711..000000000 --- a/sdk/src/v0.3/utils/ammMath.ts +++ /dev/null @@ -1,249 +0,0 @@ -import BN from "bn.js"; -import { AmmAccount } from "../types/index.js"; -import { SwapType } from "../AmmClient.js"; - -const BN_TEN = new BN(10); -const PRICE_SCALE = BN_TEN.pow(new BN(12)); -const PRICE_SCALE_NUMBER = 1e12; - -export type AddLiquiditySimulation = { - baseAmount: BN; - quoteAmount: BN; - expectedLpTokens: BN; - minLpTokens?: BN; - maxBaseAmount?: BN; -}; - -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - -export type RemoveLiquiditySimulation = { - expectedBaseOut: BN; - expectedQuoteOut: BN; - minBaseOut?: BN; - minQuoteOut?: BN; -}; - -export class AmmMath { - public static getHumanPriceFromReserves( - baseReserves: BN, - quoteReserves: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - return this.getHumanPrice( - this.getAmmPriceFromReserves(baseReserves, quoteReserves), - baseDecimals, - quoteDecimals, - ); - } - - public static getAmmPriceFromReserves( - baseReserves: BN, - quoteReserves: BN, - ): BN { - return quoteReserves.mul(PRICE_SCALE).div(baseReserves); - } - - public static getChainAmount(humanAmount: number, decimals: number): BN { - // you have to do it this weird way because BN can't be constructed with - // numbers larger than 2**50 - const [integerPart, fractionalPart = ""] = humanAmount - .toString() - .split("."); - return new BN(integerPart + fractionalPart) - .mul(new BN(10).pow(new BN(decimals))) - .div(new BN(10).pow(new BN(fractionalPart.length))); - } - - public static getHumanAmount(chainAmount: BN, decimals: number): number { - return chainAmount.toNumber() / 10 ** decimals; - } - - public static getHumanPrice( - ammPrice: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - let decimalScalar = BN_TEN.pow(new BN(quoteDecimals - baseDecimals).abs()); - - let price1e12 = - quoteDecimals > baseDecimals - ? ammPrice.div(decimalScalar) - : ammPrice.mul(decimalScalar); - - return price1e12.toNumber() / 1e12; - } - - public static getAmmPrice( - humanPrice: number, - baseDecimals: number, - quoteDecimals: number, - ): BN { - let price1e12 = new BN(humanPrice * PRICE_SCALE_NUMBER); - - let decimalScalar = BN_TEN.pow(new BN(quoteDecimals - baseDecimals).abs()); - - let scaledPrice = - quoteDecimals > baseDecimals - ? price1e12.mul(decimalScalar) - : price1e12.div(decimalScalar); - - return scaledPrice; - } - - public static getAmmPrices( - baseDecimals: number, - quoteDecimals: number, - ...prices: number[] - ): BN[] { - // Map through each price, scaling it using the scalePrice method - return prices.map((price) => - this.getAmmPrice(price, baseDecimals, quoteDecimals), - ); - } - - public static scale(number: number, decimals: number): BN { - return new BN(number * 10 ** decimals); - // return new BN(number).mul(new BN(10).pow(new BN(decimals))); - } - - public static addSlippage(chainAmount: BN, slippageBps: BN): BN { - return chainAmount.mul(slippageBps.addn(10_000)).divn(10_000); - } - - public static subtractSlippage(chainAmount: BN, slippageBps: BN): BN { - return chainAmount.mul(new BN(10_000).sub(slippageBps)).divn(10_000); - } - - public static getTwap(amm: AmmAccount): BN { - return amm.oracle.aggregator.div( - amm.oracle.lastUpdatedSlot.sub(amm.createdAtSlot), - ); - } - - public static simulateAddLiquidity( - baseReserves: BN, - quoteReserves: BN, - lpMintSupply: number, - baseAmount?: BN, - quoteAmount?: BN, - slippageBps?: BN, - ): AddLiquiditySimulation { - if (lpMintSupply == 0) { - throw new Error( - "This AMM doesn't have existing liquidity so we can't fill in the blanks", - ); - } - - if (baseAmount == undefined && quoteAmount == undefined) { - throw new Error("Must specify either a base amount or a quote amount"); - } - - let expectedLpTokens: BN; - - if (quoteAmount == undefined) { - quoteAmount = baseAmount?.mul(quoteReserves).div(baseReserves); - } - baseAmount = quoteAmount?.mul(baseReserves).div(quoteReserves).addn(1); - - expectedLpTokens = quoteAmount - ?.mul(new BN(lpMintSupply)) - .div(quoteReserves) as BN; - - let minLpTokens, maxBaseAmount; - if (slippageBps) { - minLpTokens = AmmMath.subtractSlippage(expectedLpTokens, slippageBps); - maxBaseAmount = AmmMath.addSlippage(baseAmount as BN, slippageBps); - } - - return { - quoteAmount: quoteAmount as BN, - baseAmount: baseAmount as BN, - expectedLpTokens, - minLpTokens, - maxBaseAmount, - }; - } - - public static simulateSwap( - inputAmount: BN, - swapType: SwapType, - baseReserves: BN, - quoteReserves: BN, - slippageBps?: BN, - ): SwapSimulation { - if (baseReserves.eqn(0) || quoteReserves.eqn(0)) { - throw new Error("reserves must be non-zero"); - } - - let inputReserves, outputReserves: BN; - if (swapType.buy) { - inputReserves = quoteReserves; - outputReserves = baseReserves; - } else { - inputReserves = baseReserves; - outputReserves = quoteReserves; - } - - let inputAmountWithFee: BN = inputAmount.muln(990); - - let numerator: BN = inputAmountWithFee.mul(outputReserves); - let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); - - let expectedOut = numerator.div(denominator); - let minExpectedOut; - if (slippageBps) { - minExpectedOut = AmmMath.subtractSlippage(expectedOut, slippageBps); - } - - let newBaseReserves, newQuoteReserves: BN; - if (swapType.buy) { - newBaseReserves = baseReserves.sub(expectedOut); - newQuoteReserves = quoteReserves.add(inputAmount); - } else { - newBaseReserves = baseReserves.add(inputAmount); - newQuoteReserves = quoteReserves.sub(expectedOut); - } - - return { - expectedOut, - newBaseReserves, - newQuoteReserves, - minExpectedOut, - }; - } - - public static simulateRemoveLiquidity( - lpTokensToBurn: BN, - baseReserves: BN, - quoteReserves: BN, - lpTotalSupply: BN, - slippageBps?: BN, - ): RemoveLiquiditySimulation { - const expectedBaseOut = lpTokensToBurn.mul(baseReserves).div(lpTotalSupply); - const expectedQuoteOut = lpTokensToBurn - .mul(quoteReserves) - .div(lpTotalSupply); - - let minBaseOut, minQuoteOut; - if (slippageBps) { - minBaseOut = AmmMath.subtractSlippage(expectedBaseOut, slippageBps); - minQuoteOut = AmmMath.subtractSlippage(expectedQuoteOut, slippageBps); - } - - return { - expectedBaseOut, - expectedQuoteOut, - minBaseOut, - minQuoteOut, - }; - } -} - -// Add backwards compatibility alias -export { AmmMath as PriceMath }; diff --git a/sdk/src/v0.3/utils/filters.ts b/sdk/src/v0.3/utils/filters.ts deleted file mode 100644 index aee93f618..000000000 --- a/sdk/src/v0.3/utils/filters.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GetProgramAccountsFilter, PublicKey } from "@solana/web3.js"; - -export const filterPositionsByUser = ( - userAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: 8, // discriminator - bytes: userAddr.toBase58(), - }, -}); - -export const filterPositionsByAmm = ( - ammAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: - 8 + // discriminator - 32, // user address - bytes: ammAddr.toBase58(), - }, -}); diff --git a/sdk/src/v0.3/utils/index.ts b/sdk/src/v0.3/utils/index.ts deleted file mode 100644 index 05fc38b9a..000000000 --- a/sdk/src/v0.3/utils/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export * from "./filters.js"; -export * from "./pda.js"; -export * from "./ammMath.js"; -export * from "./metadata.js"; -export * from "./cu.js"; -export * from "./instruction.js"; - -import { AccountMeta, ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; - -export enum PriorityFeeTier { - NORMAL = 35, - HIGH = 3571, - TURBO = 357142, -} - -export const addComputeUnits = (num_units: number = 1_400_000) => - ComputeBudgetProgram.setComputeUnitLimit({ - units: num_units, - }); - -export const addPriorityFee = (pf: number) => - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: pf, - }); - -export const pubkeyToAccountInfo = ( - pubkey: PublicKey, - isWritable: boolean, - isSigner = false, -): AccountMeta => { - return { - pubkey: pubkey, - isSigner: isSigner, - isWritable: isWritable, - }; -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/sdk/src/v0.3/utils/instruction.ts b/sdk/src/v0.3/utils/instruction.ts deleted file mode 100644 index f18e48834..000000000 --- a/sdk/src/v0.3/utils/instruction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { TransactionInstruction } from "@solana/web3.js"; - -export class InstructionUtils { - public static async getInstructions( - ...methodBuilders: any[] - ): Promise { - let instructions: TransactionInstruction[] = []; - - for (const methodBuilder of methodBuilders) { - instructions.push(...(await methodBuilder.transaction()).instructions); - } - - return instructions; - } -} diff --git a/sdk/src/v0.3/utils/metadata.ts b/sdk/src/v0.3/utils/metadata.ts deleted file mode 100644 index ef17bbdb8..000000000 --- a/sdk/src/v0.3/utils/metadata.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BN from "bn.js"; -import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { Connection } from "@solana/web3.js"; -import { bundlrUploader } from "@metaplex-foundation/umi-uploader-bundlr"; -import { UmiPlugin } from "@metaplex-foundation/umi"; - -export const assetImageMap: Record = { - fMETA: "https://arweave.net/tGxvOjMZw7B0qHsdCcIMO57oH5g5OaItOZdXo3BXKz8", - fUSDC: "https://arweave.net/DpvxeAyVbaoivhIVCLjdf566k2SwVn0YVBL0sTOezWk", - pMETA: "https://arweave.net/iuqi7PRRESdDxj1oRyk2WzR90_zdFcmZsuWicv3XGfs", - pUSDC: "https://arweave.net/e4IO7F59F_RKCiuB--_ABPot7Qh1yFsGkWzVhcXuKDU", -}; - -// Upload some JSON, returning its URL -export const uploadConditionalTokenMetadataJson = async ( - connection: Connection, - identityPlugin: UmiPlugin, - proposalNumber: number, - symbol: string, - // proposal: BN, - // conditionalToken: string, - // image: string -): Promise => { - // use bundlr, targeting arweave - const umi = createUmi(connection); - umi.use(bundlrUploader()); - umi.use(identityPlugin); - - return umi.uploader.uploadJson({ - name: `Proposal ${proposalNumber}: ${symbol}`, - image: assetImageMap[symbol], - symbol, - description: "A conditional token for use in futarchy.", - }); -}; diff --git a/sdk/src/v0.3/utils/pda.ts b/sdk/src/v0.3/utils/pda.ts deleted file mode 100644 index 6bf18aff2..000000000 --- a/sdk/src/v0.3/utils/pda.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { AccountMeta, PublicKey } from "@solana/web3.js"; -import { utils } from "@coral-xyz/anchor"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - fromWeb3JsPublicKey, - toWeb3JsPublicKey, -} from "@metaplex-foundation/umi-web3js-adapters"; -import { MPL_TOKEN_METADATA_PROGRAM_ID } from "../constants.js"; - -export const getVaultAddr = ( - programId: PublicKey, - settlementAuthority: PublicKey, - underlyingTokenMint: PublicKey, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_vault"), - settlementAuthority.toBuffer(), - underlyingTokenMint.toBuffer(), - ], - programId, - ); -}; - -export const getVaultFinalizeMintAddr = ( - programId: PublicKey, - vault: PublicKey, -) => { - return getVaultMintAddr(programId, vault, "conditional_on_finalize_mint"); -}; - -export const getMetadataAddr = (mint: PublicKey) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("metadata"), - MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - MPL_TOKEN_METADATA_PROGRAM_ID, - ); -}; - -export const getVaultRevertMintAddr = ( - programId: PublicKey, - vault: PublicKey, -) => { - return getVaultMintAddr(programId, vault, "conditional_on_revert_mint"); -}; - -const getVaultMintAddr = ( - programId: PublicKey, - vault: PublicKey, - seed: string, -) => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode(seed), vault.toBuffer()], - programId, - ); -}; - -export const getDaoTreasuryAddr = ( - programId: PublicKey, - dao: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); -}; - -export const getProposalAddr = ( - programId: PublicKey, - proposer: PublicKey, - nonce: BN, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("proposal"), - proposer.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -export const getAmmAddr = ( - programId: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("amm__"), - baseMint.toBuffer(), - quoteMint.toBuffer(), - ], - programId, - ); -}; - -export const getAmmLpMintAddr = ( - programId: PublicKey, - amm: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], - programId, - ); -}; diff --git a/sdk/src/v0.4/AmmClient.ts b/sdk/src/v0.4/AmmClient.ts deleted file mode 100644 index 62b540cbf..000000000 --- a/sdk/src/v0.4/AmmClient.ts +++ /dev/null @@ -1,381 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, -} from "@solana/web3.js"; - -import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; - -import BN from "bn.js"; -import { AMM_PROGRAM_ID } from "./constants.js"; -import { Amm, LowercaseKeys } from "./types/index.js"; -import { getAmmLpMintAddr, getAmmAddr } from "./utils/pda.js"; -// import { MethodsBuilder } from "@coral-xyz/anchor/dist/cjs/program/namespace/methods"; -import { - MintLayout, - unpackMint, - getAssociatedTokenAddressSync, - createAssociatedTokenAccountIdempotentInstruction, -} from "@solana/spl-token"; -import { AmmMath, PriceMath } from "./utils/priceMath.js"; - -export type SwapType = LowercaseKeys["SwapType"]>; - -export type CreateAmmClientParams = { - provider: AnchorProvider; - ammProgramId?: PublicKey; -}; - -export class AmmClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.program = new Program(AmmIDL, ammProgramId, provider); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateAmmClientParams, - ): AmmClient { - let { provider, ammProgramId: programId } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AmmClient(provider, programId || AMM_PROGRAM_ID, luts); - } - - getProgramId(): PublicKey { - return this.program.programId; - } - - async getAmm(amm: PublicKey): Promise { - return await this.program.account.amm.fetch(amm); - } - - async fetchAmm(amm: PublicKey): Promise { - return await this.program.account.amm.fetchNullable(amm); - } - - async deserializeAmm(accountInfo: AccountInfo): Promise { - return this.program.coder.accounts.decode("amm", accountInfo.data); - } - - async createAmm( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - twapStartDelaySlots: BN, - twapInitialObservation: number, - twapMaxObservationChangePerUpdate?: number, - ): Promise { - if (!twapMaxObservationChangePerUpdate) { - twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; - } - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - - let baseDecimals = unpackMint( - baseMint, - await this.provider.connection.getAccountInfo(baseMint), - ).decimals; - let quoteDecimals = unpackMint( - quoteMint, - await this.provider.connection.getAccountInfo(quoteMint), - ).decimals; - - let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = - PriceMath.getAmmPrices( - baseDecimals, - quoteDecimals, - twapInitialObservation, - twapMaxObservationChangePerUpdate, - ); - - await this.initializeAmmIx( - baseMint, - quoteMint, - twapStartDelaySlots, - twapFirstObservationScaled, - twapMaxObservationChangePerUpdateScaled, - ).rpc(); - - return amm; - } - - // both twap values need to be scaled beforehand - initializeAmmIx( - baseMint: PublicKey, - quoteMint: PublicKey, - twapStartDelaySlots: BN, - twapInitialObservation: BN, - twapMaxObservationChangePerUpdate: BN, - ) { - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); - - let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); - let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); - - return this.program.methods - .createAmm({ - twapInitialObservation, - twapMaxObservationChangePerUpdate, - twapStartDelaySlots, - }) - .accounts({ - user: this.provider.publicKey, - amm, - lpMint, - baseMint, - quoteMint, - vaultAtaBase, - vaultAtaQuote, - }); - } - - async addLiquidity( - amm: PublicKey, - quoteAmount?: number, - baseAmount?: number, - ) { - let storedAmm = await this.getAmm(amm); - - let lpMintSupply = unpackMint( - storedAmm.lpMint, - await this.provider.connection.getAccountInfo(storedAmm.lpMint), - ).supply; - - let quoteAmountCasted: BN | undefined; - let baseAmountCasted: BN | undefined; - - if (quoteAmount != undefined) { - let quoteDecimals = unpackMint( - storedAmm.quoteMint, - await this.provider.connection.getAccountInfo(storedAmm.quoteMint), - ).decimals; - quoteAmountCasted = new BN(quoteAmount).mul( - new BN(10).pow(new BN(quoteDecimals)), - ); - } - - if (baseAmount != undefined) { - let baseDecimals = unpackMint( - storedAmm.baseMint, - await this.provider.connection.getAccountInfo(storedAmm.baseMint), - ).decimals; - baseAmountCasted = new BN(baseAmount).mul( - new BN(10).pow(new BN(baseDecimals)), - ); - } - - if (lpMintSupply == 0n) { - if (quoteAmount == undefined || baseAmount == undefined) { - throw new Error( - "No pool created yet, you need to specify both base and quote", - ); - } - - // console.log(quoteAmountCasted?.toString()); - // console.log(baseAmountCasted?.toString()) - - return await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - quoteAmountCasted as BN, - baseAmountCasted as BN, - new BN(0), - ).rpc(); - } - - // quoteAmount == undefined ? undefined : new BN(quoteAmount); - // let baseAmountCasted: BN | undefined = - // baseAmount == undefined ? undefined : new BN(baseAmount); - - let sim = AmmMath.simulateAddLiquidity( - storedAmm.baseAmount, - storedAmm.quoteAmount, - Number(lpMintSupply), - baseAmountCasted, - quoteAmountCasted, - ); - - await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - sim.quoteAmount, - sim.baseAmount, - sim.expectedLpTokens, - ).rpc(); - } - - addLiquidityIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - quoteAmount: BN, - maxBaseAmount: BN, - minLpTokens: BN, - user: PublicKey = this.provider.publicKey, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); - - const userLpAccount = getAssociatedTokenAddressSync(lpMint, user, true); - - return this.program.methods - .addLiquidity({ - quoteAmount, - maxBaseAmount, - minLpTokens, - }) - .accounts({ - user, - amm, - lpMint, - userLpAccount, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - user, - userLpAccount, - user, - lpMint, - ), - ]); - } - - removeLiquidityIx( - ammAddr: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - lpTokensToBurn: BN, - minBaseAmount: BN, - minQuoteAmount: BN, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); - - return this.program.methods - .removeLiquidity({ - lpTokensToBurn, - minBaseAmount, - minQuoteAmount, - }) - .accounts({ - user: this.provider.publicKey, - amm: ammAddr, - lpMint, - userLpAccount: getAssociatedTokenAddressSync( - lpMint, - this.provider.publicKey, - true, - ), - userBaseAccount: getAssociatedTokenAddressSync( - baseMint, - this.provider.publicKey, - true, - ), - userQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - this.provider.publicKey, - true, - ), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), - }); - } - - async swap( - amm: PublicKey, - swapType: SwapType, - inputAmount: number, - outputAmountMin: number, - ) { - const storedAmm = await this.getAmm(amm); - - let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); - let baseDecimals = await this.getDecimals(storedAmm.baseMint); - - let inputAmountScaled: BN; - let outputAmountMinScaled: BN; - if (swapType.buy) { - inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); - } else { - inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); - } - - return await this.swapIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - swapType, - inputAmountScaled, - outputAmountMinScaled, - ).rpc(); - } - - swapIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - swapType: SwapType, - inputAmount: BN, - outputAmountMin: BN, - user: PublicKey = this.provider.publicKey, - ) { - const receivingToken = swapType.buy ? baseMint : quoteMint; - - return this.program.methods - .swap({ - swapType, - inputAmount, - outputAmountMin, - }) - .accounts({ - user, - amm, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - // create the receiving token account if it doesn't exist - createAssociatedTokenAccountIdempotentInstruction( - user, - getAssociatedTokenAddressSync(receivingToken, user, true), - user, - receivingToken, - ), - ]); - } - - async crankThatTwap(amm: PublicKey) { - return this.crankThatTwapIx(amm).rpc(); - } - - crankThatTwapIx(amm: PublicKey) { - return this.program.methods.crankThatTwap().accounts({ - amm, - }); - } - - async getDecimals(mint: PublicKey): Promise { - return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) - .decimals; - } -} diff --git a/sdk/src/v0.4/AutocratClient.ts b/sdk/src/v0.4/AutocratClient.ts deleted file mode 100644 index 76b2e5298..000000000 --- a/sdk/src/v0.4/AutocratClient.ts +++ /dev/null @@ -1,797 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AccountMeta, - AddressLookupTableAccount, - ComputeBudgetProgram, - Connection, - Keypair, - PublicKey, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { PriceMath } from "./utils/priceMath.js"; -import { ProposalInstruction, InitializeDaoParams } from "./types/index.js"; - -import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; -import { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./types/conditional_vault.js"; - -import BN from "bn.js"; -import { - AMM_PROGRAM_ID, - AUTOCRAT_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - MAINNET_USDC, - USDC_DECIMALS, -} from "./constants.js"; -import { - DEFAULT_CU_PRICE, - InstructionUtils, - MaxCUs, - getAmmAddr, - getAmmLpMintAddr, - getConditionalTokenMintAddr, - getDaoTreasuryAddr, - getEventAuthorityAddr, - getProposalAddr, - getQuestionAddr, - getVaultAddr, -} from "./utils/index.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { AmmClient } from "./AmmClient.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - unpackMint, -} from "@solana/spl-token"; -import { sha256 } from "@noble/hashes/sha256"; -import { Dao, Proposal } from "./types/index.js"; - -export type CreateClientParams = { - provider: AnchorProvider; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export type ProposalVaults = { - baseVault: PublicKey; - quoteVault: PublicKey; -}; - -export class AutocratClient { - public readonly provider: AnchorProvider; - public readonly autocrat: Program; - public readonly vaultClient: ConditionalVaultClient; - public readonly ammClient: AmmClient; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - autocratProgramId: PublicKey, - conditionalVaultProgramId: PublicKey, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.autocrat = new Program( - AutocratIDL, - autocratProgramId, - provider, - ); - this.vaultClient = ConditionalVaultClient.createClient({ - provider, - conditionalVaultProgramId, - }); - this.ammClient = AmmClient.createClient({ provider, ammProgramId }); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateClientParams, - ): AutocratClient { - let { - provider, - autocratProgramId, - conditionalVaultProgramId, - ammProgramId, - } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AutocratClient( - provider, - autocratProgramId || AUTOCRAT_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ammProgramId || AMM_PROGRAM_ID, - luts, - ); - } - - getProgramId(): PublicKey { - return this.autocrat.programId; - } - - async getProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetch(proposal); - } - - async getDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetch(dao); - } - - async fetchProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetchNullable(proposal); - } - - async fetchDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetchNullable(dao); - } - - async deserializeProposal( - accountInfo: AccountInfo, - ): Promise { - return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); - } - - async deserializeDao(accountInfo: AccountInfo): Promise { - return this.autocrat.coder.accounts.decode("dao", accountInfo.data); - } - - getProposalPdas( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - dao: PublicKey, - ): { - question: PublicKey; - baseVault: PublicKey; - quoteVault: PublicKey; - passBaseMint: PublicKey; - passQuoteMint: PublicKey; - failBaseMint: PublicKey; - failQuoteMint: PublicKey; - passAmm: PublicKey; - failAmm: PublicKey; - passLp: PublicKey; - failLp: PublicKey; - } { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const [question] = getQuestionAddr( - vaultProgramId, - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const [baseVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - quoteMint, - ); - - const [failBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 0, - ); - const [failQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 0, - ); - - const [passBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 1, - ); - const [passQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 1, - ); - - const [passAmm] = getAmmAddr( - this.ammClient.program.programId, - passBaseMint, - passQuoteMint, - ); - const [failAmm] = getAmmAddr( - this.ammClient.program.programId, - failBaseMint, - failQuoteMint, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - return { - question, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - passAmm, - failAmm, - passLp, - failLp, - }; - } - - async initializeDao( - tokenMint: PublicKey, - tokenPriceUiAmount: number, - minBaseFutarchicLiquidity: number, - minQuoteFutarchicLiquidity: number, - usdcMint: PublicKey = MAINNET_USDC, - daoKeypair: Keypair = Keypair.generate(), - twapStartDelaySlots: BN, - ): Promise { - let tokenDecimals = unpackMint( - tokenMint, - await this.provider.connection.getAccountInfo(tokenMint), - ).decimals; - - let scaledPrice = PriceMath.getAmmPrice( - tokenPriceUiAmount, - tokenDecimals, - USDC_DECIMALS, - ); - - // console.log( - // PriceMath.getHumanPrice(scaledPrice, tokenDecimals, USDC_DECIMALS) - // ); - - await this.initializeDaoIx( - daoKeypair, - tokenMint, - { - twapStartDelaySlots, - twapInitialObservation: scaledPrice, - twapMaxObservationChangePerUpdate: scaledPrice.divn(50), - minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( - new BN(10).pow(new BN(USDC_DECIMALS)), - ), - minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( - new BN(10).pow(new BN(tokenDecimals)), - ), - passThresholdBps: null, - slotsPerProposal: null, - }, - usdcMint, - ) - .postInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ - units: MaxCUs.initializeDao, - }), - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: DEFAULT_CU_PRICE, - }), - ]) - .rpc({ maxRetries: 5 }); - - return daoKeypair.publicKey; - } - - initializeDaoIx( - daoKeypair: Keypair, - tokenMint: PublicKey, - params: InitializeDaoParams, - usdcMint: PublicKey = MAINNET_USDC, - ) { - return this.autocrat.methods - .initializeDao(params) - .accounts({ - dao: daoKeypair.publicKey, - tokenMint, - usdcMint, - }) - .signers([daoKeypair]); - } - - async initializeProposal( - dao: PublicKey, - descriptionUrl: string, - instruction: ProposalInstruction, - baseTokensToLP: BN, - quoteTokensToLP: BN, - ): Promise { - const storedDao = await this.getDao(dao); - - const nonce = new BN(Math.random() * 2 ** 50); - - let [proposal] = getProposalAddr( - this.autocrat.programId, - this.provider.publicKey, - nonce, - ); - - await this.vaultClient.initializeQuestion( - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - - const { - baseVault, - quoteVault, - passAmm, - failAmm, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - question, - } = this.getProposalPdas( - proposal, - storedDao.tokenMint, - storedDao.usdcMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - await this.vaultClient - .initializeVaultIx(question, storedDao.tokenMint, 2) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(question, storedDao.usdcMint, 2), - this.ammClient.initializeAmmIx( - passBaseMint, - passQuoteMint, - storedDao.twapStartDelaySlots, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - this.ammClient.initializeAmmIx( - failBaseMint, - failQuoteMint, - storedDao.twapStartDelaySlots, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - ), - ) - .rpc(); - - await this.vaultClient - .splitTokensIx( - question, - baseVault, - storedDao.tokenMint, - baseTokensToLP, - 2, - ) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.splitTokensIx( - question, - quoteVault, - storedDao.usdcMint, - quoteTokensToLP, - 2, - ), - ), - ) - .rpc(); - - await this.ammClient - .addLiquidityIx( - passAmm, - passBaseMint, - passQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ) - .postInstructions( - await InstructionUtils.getInstructions( - this.ammClient.addLiquidityIx( - failAmm, - failBaseMint, - failQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ), - ), - ) - .rpc(); - - // this is how many original tokens are created - const lpTokens = quoteTokensToLP; - - await this.initializeProposalIx( - descriptionUrl, - instruction, - dao, - storedDao.tokenMint, - storedDao.usdcMint, - lpTokens, - lpTokens, - nonce, - question, - ).rpc(); - - return proposal; - } - - // async createProposalTxAndPDAs( - // dao: PublicKey, - // descriptionUrl: string, - // instruction: ProposalInstruction, - // baseTokensToLP: BN, - // quoteTokensToLP: BN - // ): Promise< - // [ - // Transaction[], - // { - // proposalAcct: PublicKey; - // baseCondVaultAcct: PublicKey; - // quoteCondVaultAcct: PublicKey; - // passMarketAcct: PublicKey; - // failMarketAcct: PublicKey; - // } - // ] - // > { - // const storedDao = await this.getDao(dao); - - // const nonce = new BN(Math.random() * 2 ** 50); - - // let [proposal] = getProposalAddr( - // this.autocrat.programId, - // this.provider.publicKey, - // nonce - // ); - - // const { - // baseVault, - // quoteVault, - // passAmm, - // failAmm, - // passBaseMint, - // passQuoteMint, - // failBaseMint, - // failQuoteMint, - // } = this.getProposalPdas( - // proposal, - // storedDao.tokenMint, - // storedDao.usdcMint, - // dao - // ); - - // // it's important that these happen in a single atomic transaction - // const initVaultTx = await this.vaultClient - // .initializeVaultIx(proposal, storedDao.tokenMint) - // .postInstructions( - // await InstructionUtils.getInstructions( - // this.vaultClient.initializeVaultIx(proposal, storedDao.usdcMint), - // this.ammClient.createAmmIx( - // passBaseMint, - // passQuoteMint, - // storedDao.twapInitialObservation, - // storedDao.twapMaxObservationChangePerUpdate - // ), - // this.ammClient.createAmmIx( - // failBaseMint, - // failQuoteMint, - // storedDao.twapInitialObservation, - // storedDao.twapMaxObservationChangePerUpdate - // ) - // ) - // ) - // .transaction(); - - // const mintConditionalTokensTx = await this.vaultClient - // .mintConditionalTokensIx(baseVault, storedDao.tokenMint, baseTokensToLP) - // .postInstructions( - // await InstructionUtils.getInstructions( - // this.vaultClient.mintConditionalTokensIx( - // quoteVault, - // storedDao.usdcMint, - // quoteTokensToLP - // ) - // ) - // ) - // .transaction(); - - // const addLiquidityTx = await this.ammClient - // .addLiquidityIx( - // passAmm, - // passBaseMint, - // passQuoteMint, - // quoteTokensToLP, - // baseTokensToLP, - // new BN(0) - // ) - // .postInstructions( - // await InstructionUtils.getInstructions( - // this.ammClient.addLiquidityIx( - // failAmm, - // failBaseMint, - // failQuoteMint, - // quoteTokensToLP, - // baseTokensToLP, - // new BN(0) - // ) - // ) - // ) - // .transaction(); - - // // this is how many original tokens are created - // const lpTokens = quoteTokensToLP; - - // const initTx = await this.initializeProposalIx( - // descriptionUrl, - // instruction, - // dao, - // storedDao.tokenMint, - // storedDao.usdcMint, - // lpTokens, - // lpTokens, - // nonce, - // question - // ).transaction(); - - // return [ - // [initVaultTx, mintConditionalTokensTx, addLiquidityTx, initTx], - // { - // baseCondVaultAcct: baseVault, - // quoteCondVaultAcct: quoteVault, - // failMarketAcct: failAmm, - // passMarketAcct: passAmm, - // proposalAcct: proposal, - // }, - // ]; - // } - - initializeProposalIx( - descriptionUrl: string, - instruction: ProposalInstruction, - dao: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - passLpTokensToLock: BN, - failLpTokensToLock: BN, - nonce: BN, - question: PublicKey, - proposer: PublicKey = this.provider.publicKey, - ) { - let [proposal] = getProposalAddr(this.autocrat.programId, proposer, nonce); - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( - proposal, - baseMint, - quoteMint, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - const passLpVaultAccount = getAssociatedTokenAddressSync( - passLp, - daoTreasury, - true, - ); - const failLpVaultAccount = getAssociatedTokenAddressSync( - failLp, - daoTreasury, - true, - ); - - return this.autocrat.methods - .initializeProposal({ - descriptionUrl, - instruction, - passLpTokensToLock, - failLpTokensToLock, - nonce, - }) - .accounts({ - question, - proposal, - dao, - baseVault, - quoteVault, - passAmm, - failAmm, - passLpMint: passLp, - failLpMint: failLp, - passLpUserAccount: getAssociatedTokenAddressSync( - passLp, - proposer, - true, - ), - failLpUserAccount: getAssociatedTokenAddressSync( - failLp, - proposer, - true, - ), - passLpVaultAccount, - failLpVaultAccount, - proposer, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - proposer, - passLpVaultAccount, - daoTreasury, - passLp, - ), - createAssociatedTokenAccountIdempotentInstruction( - proposer, - failLpVaultAccount, - daoTreasury, - failLp, - ), - ]); - } - - async finalizeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - let storedDao = await this.getDao(storedProposal.dao); - - return this.finalizeProposalIx( - proposal, - storedProposal.instruction, - storedProposal.dao, - storedDao.tokenMint, - storedDao.usdcMint, - storedProposal.proposer, - ).rpc(); - } - - finalizeProposalIx( - proposal: PublicKey, - instruction: any, - dao: PublicKey, - daoToken: PublicKey, - usdc: PublicKey, - proposer: PublicKey, - ) { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const { question, passAmm, failAmm } = this.getProposalPdas( - proposal, - daoToken, - usdc, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); - - return this.autocrat.methods.finalizeProposal().accounts({ - proposal, - passAmm, - failAmm, - dao, - question, - // baseVault, - // quoteVault, - passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer, true), - failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer, true), - passLpVaultAccount: getAssociatedTokenAddressSync( - passLp, - daoTreasury, - true, - ), - failLpVaultAccount: getAssociatedTokenAddressSync( - failLp, - daoTreasury, - true, - ), - vaultProgram: this.vaultClient.vaultProgram.programId, - treasury: daoTreasury, - vaultEventAuthority, - }); - } - - async executeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - - return this.executeProposalIx( - proposal, - storedProposal.dao, - storedProposal.instruction, - ).rpc(); - } - - executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - return this.autocrat.methods - .executeProposal() - .accounts({ - proposal, - dao, - // daoTreasury, - }) - .remainingAccounts( - instruction.accounts - .concat({ - pubkey: instruction.programId, - isWritable: false, - isSigner: false, - }) - .map((meta: AccountMeta) => - meta.pubkey.equals(daoTreasury) - ? { ...meta, isSigner: false } - : meta, - ), - ); - } - - // cranks the TWAPs of multiple proposals' markets. there's a limit on the - // number of proposals you can pass in, which I can't determine rn because - // there aren't enough proposals on devnet - async crankProposalMarkets( - proposals: PublicKey[], - priorityFeeMicroLamports: number, - ) { - const amms: PublicKey[] = []; - - for (const proposal of proposals) { - const storedProposal = await this.getProposal(proposal); - amms.push(storedProposal.passAmm); - amms.push(storedProposal.failAmm); - } - - while (true) { - let ixs: TransactionInstruction[] = []; - - for (const amm of amms) { - ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); - } - - let tx = new Transaction(); - tx.add( - ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), - ); - tx.add( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: priorityFeeMicroLamports, - }), - ); - tx.add(...ixs); - try { - await this.provider.sendAndConfirm(tx); - } catch (err) { - console.log("err", err); - } - - await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds - } - } -} diff --git a/sdk/src/v0.4/ConditionalVaultClient.ts b/sdk/src/v0.4/ConditionalVaultClient.ts deleted file mode 100644 index 047e0a46f..000000000 --- a/sdk/src/v0.4/ConditionalVaultClient.ts +++ /dev/null @@ -1,475 +0,0 @@ -import { AnchorProvider, Program, utils } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, - SystemProgram, -} from "@solana/web3.js"; - -import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; - -import BN from "bn.js"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, -} from "./constants.js"; -import { - getQuestionAddr, - getMetadataAddr, - getVaultAddr, - getConditionalTokenMintAddr, -} from "./utils/index.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { ConditionalVault, Question } from "./types/index.js"; - -export type CreateVaultClientParams = { - provider: AnchorProvider; - conditionalVaultProgramId?: PublicKey; -}; - -export class ConditionalVaultClient { - public readonly provider: AnchorProvider; - public readonly vaultProgram: Program; - - constructor(provider: AnchorProvider, conditionalVaultProgramId: PublicKey) { - this.provider = provider; - this.vaultProgram = new Program( - ConditionalVaultIDL, - conditionalVaultProgramId, - provider, - ); - } - - public static createClient( - createVaultClientParams: CreateVaultClientParams, - ): ConditionalVaultClient { - let { provider, conditionalVaultProgramId } = createVaultClientParams; - - return new ConditionalVaultClient( - provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ); - } - - async fetchQuestion(question: PublicKey): Promise { - return this.vaultProgram.account.question.fetchNullable(question); - } - - async fetchVault(vault: PublicKey): Promise { - return this.vaultProgram.account.conditionalVault.fetchNullable(vault); - } - - async deserializeQuestion( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "question", - accountInfo.data, - ); - } - - async deserializeVault( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "conditionalVault", - accountInfo.data, - ); - } - - initializeQuestionIx( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ) { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - return this.vaultProgram.methods - .initializeQuestion({ - questionId: Array.from(questionId), - oracle, - numOutcomes, - }) - .accounts({ - question, - }); - } - - async initializeQuestion( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ): Promise { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - await this.initializeQuestionIx(questionId, oracle, numOutcomes).rpc(); - - return question; - } - - initializeVaultIx( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - payer: PublicKey = this.provider.publicKey, - ) { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ); - - return this.vaultProgram.methods - .initializeConditionalVault() - .accounts({ - vault, - question, - underlyingTokenMint, - vaultUnderlyingTokenAccount, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - vaultUnderlyingTokenAccount, - vault, - underlyingTokenMint, - ), - ]) - .remainingAccounts( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - } - - // TODO remove `numOucomes` - - async initializeVault( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - ): Promise { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - await this.initializeVaultIx( - question, - underlyingTokenMint, - numOutcomes, - ).rpc(); - - return vault; - } - - resolveQuestionIx( - question: PublicKey, - oracle: Keypair, - payoutNumerators: number[], - ) { - return this.vaultProgram.methods - .resolveQuestion({ - payoutNumerators, - }) - .accounts({ - question, - oracle: oracle.publicKey, - }) - .signers([oracle]); - } - - getConditionalTokenMints(vault: PublicKey, numOutcomes: number): PublicKey[] { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - return conditionalTokenMintAddrs; - } - - getRemainingAccounts( - conditionalTokenMints: PublicKey[], - userConditionalAccounts: PublicKey[], - ) { - return conditionalTokenMints - .concat(userConditionalAccounts) - .map((account) => ({ - pubkey: account, - isWritable: true, - isSigner: false, - })); - } - - // Helper method to get conditional token accounts and instructions - getConditionalTokenAccountsAndInstructions( - vault: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - const userConditionalAccounts = conditionalTokenMintAddrs.map((mint) => - getAssociatedTokenAddressSync(mint, user, true), - ); - - const preInstructions = conditionalTokenMintAddrs.map((mint) => - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(mint, user, true), - user, - mint, - ), - ); - - const remainingAccounts = this.getRemainingAccounts( - conditionalTokenMintAddrs, - userConditionalAccounts, - ); - - return { userConditionalAccounts, preInstructions, remainingAccounts }; - } - - splitTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const { preInstructions, remainingAccounts } = - this.getConditionalTokenAccountsAndInstructions( - vault, - numOutcomes, - user, - payer, - ); - - return this.vaultProgram.methods - .splitTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions(preInstructions) - .remainingAccounts(remainingAccounts); - } - - mergeTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .mergeTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - redeemTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .redeemTokens() - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - addMetadataToConditionalTokensIx( - vault: PublicKey, - index: number, - name: string, - symbol: string, - uri: string, - payer: PublicKey = this.provider.publicKey, - ) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - index, - ); - - const [conditionalTokenMetadata] = getMetadataAddr(conditionalTokenMint); - - return this.vaultProgram.methods - .addMetadataToConditionalTokens({ - name, - symbol, - uri, - }) - .accounts({ - payer, - vault, - conditionalTokenMint, - conditionalTokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.4/LaunchpadClient.ts b/sdk/src/v0.4/LaunchpadClient.ts deleted file mode 100644 index 70160abb3..000000000 --- a/sdk/src/v0.4/LaunchpadClient.ts +++ /dev/null @@ -1,411 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Keypair, - AccountInfo, - ComputeBudgetProgram, -} from "@solana/web3.js"; -import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; -import { - LAUNCHPAD_PROGRAM_ID, - RAYDIUM_AUTHORITY, - LOW_FEE_RAYDIUM_CONFIG, - RAYDIUM_CP_SWAP_PROGRAM_ID, - RAYDIUM_CREATE_POOL_FEE_RECEIVE, - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - DEVNET_RAYDIUM_AUTHORITY, - DEVNET_LOW_FEE_RAYDIUM_CONFIG, - DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, - MPL_TOKEN_METADATA_PROGRAM_ID, - MAINNET_USDC, - DEVNET_USDC, -} from "./constants.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; -import { BN } from "@coral-xyz/anchor"; -import { FundingRecord, Launch } from "./types/index.js"; -import { - getDaoTreasuryAddr, - getEventAuthorityAddr, - getFundingRecordAddr, - getLaunchAddr, - getLaunchDaoAddr, - getLaunchSignerAddr, - getLiquidityPoolAddr, - getMetadataAddr, - getRaydiumCpmmLpMintAddr, -} from "./utils/pda.js"; -import { AutocratClient } from "./AutocratClient.js"; -import * as anchor from "@coral-xyz/anchor"; - -export type CreateLaunchpadClientParams = { - provider: AnchorProvider; - launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export class LaunchpadClient { - public launchpad: Program; - public provider: AnchorProvider; - public autocratClient: AutocratClient; - - private constructor(params: CreateLaunchpadClientParams) { - this.provider = params.provider; - this.launchpad = new Program( - LaunchpadIDL, - params.launchpadProgramId || LAUNCHPAD_PROGRAM_ID, - this.provider, - ); - this.autocratClient = AutocratClient.createClient({ - provider: this.provider, - autocratProgramId: params.autocratProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - ammProgramId: params.ammProgramId, - }); - } - - static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { - return new LaunchpadClient(params); - } - - getProgramId(): PublicKey { - return this.launchpad.programId; - } - - async getLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetch(launch); - } - - async fetchLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetchNullable(launch); - } - - async deserializeLaunch(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("launch", accountInfo.data); - } - - async getFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetch(fundingRecord); - } - - async fetchFundingRecord( - fundingRecord: PublicKey, - ): Promise { - return await this.launchpad.account.fundingRecord.fetchNullable( - fundingRecord, - ); - } - - async deserializeFundingRecord( - accountInfo: AccountInfo, - ): Promise { - return this.launchpad.coder.accounts.decode( - "fundingRecord", - accountInfo.data, - ); - } - - initializeLaunchIx( - tokenName: string, - tokenSymbol: string, - tokenUri: string, - minimumRaiseAmount: BN, - secondsForLaunch: number, - tokenMint: PublicKey, - launchAuthority: PublicKey = this.provider.publicKey, - isDevnet: boolean = false, - payer: PublicKey = this.provider.publicKey, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - - const [launch] = getLaunchAddr(this.launchpad.programId, tokenMint); - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const usdcVault = getAssociatedTokenAddressSync(USDC, launchSigner, true); - - const tokenVault = getAssociatedTokenAddressSync( - tokenMint, - launchSigner, - true, - ); - const [tokenMetadata] = getMetadataAddr(tokenMint); - - return this.launchpad.methods - .initializeLaunch({ - minimumRaiseAmount, - secondsForLaunch, - tokenName, - tokenSymbol, - tokenUri, - }) - .accounts({ - launch, - launchSigner, - usdcVault, - tokenVault, - launchAuthority, - usdcMint: USDC, - tokenMint, - tokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - payer, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(USDC, launchSigner, true), - launchSigner, - USDC, - ), - ]); - // .signers([tokenMintKp]); - } - - startLaunchIx( - launch: PublicKey, - launchAuthority: PublicKey = this.provider.publicKey, - ) { - return this.launchpad.methods.startLaunch().accounts({ - launch, - launchAuthority, - }); - } - - fundIx( - launch: PublicKey, - amount: BN, - funder: PublicKey = this.provider.publicKey, - isDevnet: boolean = false, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const launchUsdcVault = getAssociatedTokenAddressSync( - USDC, - launchSigner, - true, - ); - const funderUsdcAccount = getAssociatedTokenAddressSync(USDC, funder, true); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods.fund(amount).accounts({ - launch, - launchUsdcVault, - fundingRecord, - funder, - funderUsdcAccount, - launchSigner, - }); - } - - completeLaunchIx( - launch: PublicKey, - tokenMint: PublicKey, - isDevnet: boolean = false, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const launchUsdcVault = getAssociatedTokenAddressSync( - USDC, - launchSigner, - true, - ); - const launchTokenVault = getAssociatedTokenAddressSync( - tokenMint, - launchSigner, - true, - ); - - // const daoKp = Keypair.generate(); - const [dao] = getLaunchDaoAddr(this.launchpad.programId, launch); - const [daoTreasury] = getDaoTreasuryAddr( - this.autocratClient.getProgramId(), - dao, - ); - const treasuryUsdcAccount = getAssociatedTokenAddressSync( - USDC, - daoTreasury, - true, - ); - - const [poolState] = getLiquidityPoolAddr(this.launchpad.programId, dao); - - const cpSwapProgramId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - - const [lpMint] = getRaydiumCpmmLpMintAddr(poolState, isDevnet); - - const lpVault = getAssociatedTokenAddressSync(lpMint, launchSigner, true); - - const [poolTokenVault] = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("pool_vault"), - poolState.toBuffer(), - tokenMint.toBuffer(), - ], - cpSwapProgramId, - ); - - const [poolUsdcVault] = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("pool_vault"), - poolState.toBuffer(), - USDC.toBuffer(), - ], - cpSwapProgramId, - ); - - const [observationState] = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("observation"), poolState.toBuffer()], - cpSwapProgramId, - ); - - const [autocratEventAuthority] = getEventAuthorityAddr( - this.autocratClient.getProgramId(), - ); - - const [tokenMetadata] = getMetadataAddr(tokenMint); - - return this.launchpad.methods - .completeLaunch() - .accounts({ - launch, - launchSigner, - launchUsdcVault, - launchTokenVault, - dao, - daoTreasury, - treasuryUsdcAccount, - treasuryLpAccount: getAssociatedTokenAddressSync( - lpMint, - daoTreasury, - true, - ), - usdcMint: USDC, - tokenMint, - tokenMetadata, - lpMint, - lpVault, - poolTokenVault, - poolUsdcVault, - poolState, - observationState, - cpSwapProgram: cpSwapProgramId, - authority: isDevnet ? DEVNET_RAYDIUM_AUTHORITY : RAYDIUM_AUTHORITY, - ammConfig: isDevnet - ? DEVNET_LOW_FEE_RAYDIUM_CONFIG - : LOW_FEE_RAYDIUM_CONFIG, - createPoolFee: isDevnet - ? DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE - : RAYDIUM_CREATE_POOL_FEE_RECEIVE, - autocratProgram: this.autocratClient.getProgramId(), - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - autocratEventAuthority, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - treasuryUsdcAccount, - daoTreasury, - USDC, - ), - ]); - } - - refundIx( - launch: PublicKey, - funder: PublicKey = this.provider.publicKey, - isDevnet: boolean = false, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - const launchUsdcVault = getAssociatedTokenAddressSync( - USDC, - launchSigner, - true, - ); - const funderUsdcAccount = getAssociatedTokenAddressSync(USDC, funder, true); - - return this.launchpad.methods.refund().accounts({ - launch, - launchSigner, - launchUsdcVault, - funder, - funderUsdcAccount, - fundingRecord, - }); - } - - claimIx( - launch: PublicKey, - tokenMint: PublicKey, - funder: PublicKey = this.provider.publicKey, - ) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods - .claim() - .accounts({ - launch, - fundingRecord, - launchSigner, - funder, - funderTokenAccount: getAssociatedTokenAddressSync( - tokenMint, - funder, - true, - ), - tokenMint, - launchTokenVault: getAssociatedTokenAddressSync( - tokenMint, - launchSigner, - true, - ), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(tokenMint, funder, true), - funder, - tokenMint, - ), - ]); - } -} diff --git a/sdk/src/v0.4/constants.ts b/sdk/src/v0.4/constants.ts deleted file mode 100644 index e5df61f7d..000000000 --- a/sdk/src/v0.4/constants.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { PublicKey } from "@solana/web3.js"; -import * as anchor from "@coral-xyz/anchor"; -import { BN } from "bn.js"; - -export const AUTOCRAT_PROGRAM_ID = new PublicKey( - "autowMzCbM29YXMgVG3T62Hkgo7RcyrvgQQkd54fDQL", -); -export const AMM_PROGRAM_ID = new PublicKey( - "AMMyu265tkBpRW21iGQxKGLaves3gKm2JcMUqfXNSpqD", -); -export const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( - "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", -); - -export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", -); - -export const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", -); - -export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", -); - -export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", -); -export const MAINNET_USDC = new PublicKey( - "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", -); - -export const DEVNET_USDC = new PublicKey( - "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", -); - -export const USDC_DECIMALS = 6; - -export const AUTOCRAT_LUTS: PublicKey[] = []; - -export const LAUNCHPAD_PROGRAM_ID = new PublicKey( - "AfJJJ5UqxhBKoE3grkKAZZsoXDE9kncbMKvqSHGsCNrE", -); - -export const RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DEVNET_RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const LOW_FEE_RAYDIUM_CONFIG = new PublicKey( - "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2", -); - -export const DEVNET_LOW_FEE_RAYDIUM_CONFIG = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("amm_config"), - new BN(0).toArrayLike(Buffer, "be", 2), - ], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8", -); - -export const DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2", -); diff --git a/sdk/src/v0.4/index.ts b/sdk/src/v0.4/index.ts deleted file mode 100644 index 06af1cf6c..000000000 --- a/sdk/src/v0.4/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from "./types/index.js"; -export * from "./utils/index.js"; -export * from "./constants.js"; -export * from "./AmmClient.js"; -export * from "./AutocratClient.js"; -export * from "./ConditionalVaultClient.js"; -export * from "./LaunchpadClient.js"; diff --git a/sdk/src/v0.4/types/autocrat_migrator.ts b/sdk/src/v0.4/types/autocrat_migrator.ts deleted file mode 100644 index 676d2df3d..000000000 --- a/sdk/src/v0.4/types/autocrat_migrator.ts +++ /dev/null @@ -1,237 +0,0 @@ -export type AutocratMigrator = { - version: "0.1.0"; - name: "autocrat_migrator"; - instructions: [ - { - name: "multiTransfer2"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "multiTransfer4"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "from2"; - isMut: true; - isSigner: false; - }, - { - name: "to2"; - isMut: true; - isSigner: false; - }, - { - name: "from3"; - isMut: true; - isSigner: false; - }, - { - name: "to3"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; -}; - -export const IDL: AutocratMigrator = { - version: "0.1.0", - name: "autocrat_migrator", - instructions: [ - { - name: "multiTransfer2", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "multiTransfer4", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "from2", - isMut: true, - isSigner: false, - }, - { - name: "to2", - isMut: true, - isSigner: false, - }, - { - name: "from3", - isMut: true, - isSigner: false, - }, - { - name: "to3", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], -}; diff --git a/sdk/src/v0.4/types/conditional_vault.ts b/sdk/src/v0.4/types/conditional_vault.ts deleted file mode 100644 index a0174c7f1..000000000 --- a/sdk/src/v0.4/types/conditional_vault.ts +++ /dev/null @@ -1,1839 +0,0 @@ -export type ConditionalVault = { - version: "0.4.0"; - name: "conditional_vault"; - instructions: [ - { - name: "initializeQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeQuestionArgs"; - }; - }, - ]; - }, - { - name: "resolveQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "oracle"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ResolveQuestionArgs"; - }; - }, - ]; - }, - { - name: "initializeConditionalVault"; - accounts: [ - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "splitTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "mergeTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "redeemTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "addMetadataToConditionalTokens"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMetadataToConditionalTokensArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "conditionalVault"; - type: { - kind: "struct"; - fields: [ - { - name: "question"; - type: "publicKey"; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - }, - { - name: "underlyingTokenAccount"; - type: "publicKey"; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "decimals"; - type: "u8"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "question"; - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - { - name: "payoutDenominator"; - type: "u32"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "AddMetadataToConditionalTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "name"; - type: "string"; - }, - { - name: "symbol"; - type: "string"; - }, - { - name: "uri"; - type: "string"; - }, - ]; - }; - }, - { - name: "InitializeQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "numOutcomes"; - type: "u8"; - }, - ]; - }; - }, - { - name: "ResolveQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - ]; - }; - }, - { - name: "VaultStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Active"; - }, - { - name: "Finalized"; - }, - { - name: "Reverted"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "AddMetadataToConditionalTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMetadata"; - type: "publicKey"; - index: false; - }, - { - name: "name"; - type: "string"; - index: false; - }, - { - name: "symbol"; - type: "string"; - index: false; - }, - { - name: "uri"; - type: "string"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeConditionalVaultEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - index: false; - }, - { - name: "oracle"; - type: "publicKey"; - index: false; - }, - { - name: "numOutcomes"; - type: "u8"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MergeTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RedeemTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "ResolveQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - index: false; - }, - ]; - }, - { - name: "SplitTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "InsufficientUnderlyingTokens"; - msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; - }, - { - code: 6002; - name: "InsufficientConditionalTokens"; - msg: "Insufficient conditional token balance to merge this `amount`"; - }, - { - code: 6003; - name: "InvalidVaultUnderlyingTokenAccount"; - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; - }, - { - code: 6004; - name: "InvalidConditionalTokenMint"; - msg: "This conditional token mint is not this vault's conditional token mint"; - }, - { - code: 6005; - name: "CantRedeemConditionalTokens"; - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens"; - }, - { - code: 6006; - name: "InsufficientNumConditions"; - msg: "Questions need 2 or more conditions"; - }, - { - code: 6007; - name: "InvalidNumPayoutNumerators"; - msg: "Invalid number of payout numerators"; - }, - { - code: 6008; - name: "InvalidConditionals"; - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens"; - }, - { - code: 6009; - name: "ConditionalMintMismatch"; - msg: "Conditional mint not in vault"; - }, - { - code: 6010; - name: "BadConditionalMint"; - msg: "Unable to deserialize a conditional token mint"; - }, - { - code: 6011; - name: "BadConditionalTokenAccount"; - msg: "Unable to deserialize a conditional token account"; - }, - { - code: 6012; - name: "ConditionalTokenMintMismatch"; - msg: "User conditional token account mint does not match conditional mint"; - }, - { - code: 6013; - name: "PayoutZero"; - msg: "Payouts must sum to 1 or more"; - }, - { - code: 6014; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - { - code: 6015; - name: "ConditionalTokenMetadataAlreadySet"; - msg: "Conditional token metadata already set"; - }, - ]; -}; - -export const IDL: ConditionalVault = { - version: "0.4.0", - name: "conditional_vault", - instructions: [ - { - name: "initializeQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeQuestionArgs", - }, - }, - ], - }, - { - name: "resolveQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "oracle", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ResolveQuestionArgs", - }, - }, - ], - }, - { - name: "initializeConditionalVault", - accounts: [ - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "splitTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "mergeTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "redeemTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "addMetadataToConditionalTokens", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMetadataToConditionalTokensArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "conditionalVault", - type: { - kind: "struct", - fields: [ - { - name: "question", - type: "publicKey", - }, - { - name: "underlyingTokenMint", - type: "publicKey", - }, - { - name: "underlyingTokenAccount", - type: "publicKey", - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "decimals", - type: "u8", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "question", - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ], - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - { - name: "payoutDenominator", - type: "u32", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "AddMetadataToConditionalTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "name", - type: "string", - }, - { - name: "symbol", - type: "string", - }, - { - name: "uri", - type: "string", - }, - ], - }, - }, - { - name: "InitializeQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "numOutcomes", - type: "u8", - }, - ], - }, - }, - { - name: "ResolveQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - ], - }, - }, - { - name: "VaultStatus", - type: { - kind: "enum", - variants: [ - { - name: "Active", - }, - { - name: "Finalized", - }, - { - name: "Reverted", - }, - ], - }, - }, - ], - events: [ - { - name: "AddMetadataToConditionalTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMint", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMetadata", - type: "publicKey", - index: false, - }, - { - name: "name", - type: "string", - index: false, - }, - { - name: "symbol", - type: "string", - index: false, - }, - { - name: "uri", - type: "string", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeConditionalVaultEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "underlyingTokenMint", - type: "publicKey", - index: false, - }, - { - name: "vaultUnderlyingTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "questionId", - type: { - array: ["u8", 32], - }, - index: false, - }, - { - name: "oracle", - type: "publicKey", - index: false, - }, - { - name: "numOutcomes", - type: "u8", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MergeTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "RedeemTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "ResolveQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - index: false, - }, - ], - }, - { - name: "SplitTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "InsufficientUnderlyingTokens", - msg: "Insufficient underlying token balance to mint this amount of conditional tokens", - }, - { - code: 6002, - name: "InsufficientConditionalTokens", - msg: "Insufficient conditional token balance to merge this `amount`", - }, - { - code: 6003, - name: "InvalidVaultUnderlyingTokenAccount", - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", - }, - { - code: 6004, - name: "InvalidConditionalTokenMint", - msg: "This conditional token mint is not this vault's conditional token mint", - }, - { - code: 6005, - name: "CantRedeemConditionalTokens", - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens", - }, - { - code: 6006, - name: "InsufficientNumConditions", - msg: "Questions need 2 or more conditions", - }, - { - code: 6007, - name: "InvalidNumPayoutNumerators", - msg: "Invalid number of payout numerators", - }, - { - code: 6008, - name: "InvalidConditionals", - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens", - }, - { - code: 6009, - name: "ConditionalMintMismatch", - msg: "Conditional mint not in vault", - }, - { - code: 6010, - name: "BadConditionalMint", - msg: "Unable to deserialize a conditional token mint", - }, - { - code: 6011, - name: "BadConditionalTokenAccount", - msg: "Unable to deserialize a conditional token account", - }, - { - code: 6012, - name: "ConditionalTokenMintMismatch", - msg: "User conditional token account mint does not match conditional mint", - }, - { - code: 6013, - name: "PayoutZero", - msg: "Payouts must sum to 1 or more", - }, - { - code: 6014, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - { - code: 6015, - name: "ConditionalTokenMetadataAlreadySet", - msg: "Conditional token metadata already set", - }, - ], -}; diff --git a/sdk/src/v0.4/types/index.ts b/sdk/src/v0.4/types/index.ts deleted file mode 100644 index dd2c33f34..000000000 --- a/sdk/src/v0.4/types/index.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Autocrat as AutocratProgram, IDL as AutocratIDL } from "./autocrat.js"; -export { AutocratProgram, AutocratIDL }; - -import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; -export { AmmProgram, AmmIDL }; - -import { - Launchpad as LaunchpadProgram, - IDL as LaunchpadIDL, -} from "./launchpad.js"; -export { LaunchpadProgram, LaunchpadIDL }; - -import { - ConditionalVault as ConditionalVaultProgram, - IDL as ConditionalVaultIDL, -} from "./conditional_vault.js"; -export { ConditionalVaultProgram, ConditionalVaultIDL }; - -export { LowercaseKeys } from "./utils.js"; - -import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; -import { PublicKey } from "@solana/web3.js"; - -export type Question = IdlAccounts["question"]; -export type ConditionalVault = - IdlAccounts["conditionalVault"]; - -export type InitializeDaoParams = - IdlTypes["InitializeDaoParams"]; -export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; -export type ProposalInstruction = - IdlTypes["ProposalInstruction"]; - -export type Dao = IdlAccounts["dao"]; -export type Proposal = IdlAccounts["proposal"]; -export type Amm = IdlAccounts["amm"]; -export type Launch = IdlAccounts["launch"]; -export type FundingRecord = IdlAccounts["fundingRecord"]; - -export type SwapEvent = IdlEvents["SwapEvent"]; -export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; -export type RemoveLiquidityEvent = - IdlEvents["RemoveLiquidityEvent"]; -export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; -export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; -export type AmmEvent = - | SwapEvent - | AddLiquidityEvent - | RemoveLiquidityEvent - | CreateAmmEvent - | CrankThatTwapEvent; - -export type AddMetadataToConditionalTokensEvent = - IdlEvents["AddMetadataToConditionalTokensEvent"]; -export type InitializeConditionalVaultEvent = - IdlEvents["InitializeConditionalVaultEvent"]; -export type InitializeQuestionEvent = - IdlEvents["InitializeQuestionEvent"]; -export type MergeTokensEvent = - IdlEvents["MergeTokensEvent"]; -export type RedeemTokensEvent = - IdlEvents["RedeemTokensEvent"]; -export type ResolveQuestionEvent = - IdlEvents["ResolveQuestionEvent"]; -export type SplitTokensEvent = - IdlEvents["SplitTokensEvent"]; -export type ConditionalVaultEvent = - | AddMetadataToConditionalTokensEvent - | InitializeConditionalVaultEvent - | InitializeQuestionEvent - | MergeTokensEvent - | RedeemTokensEvent - | ResolveQuestionEvent - | SplitTokensEvent; - -export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; -export type LaunchCompletedEvent = - IdlEvents["LaunchCompletedEvent"]; -export type LaunchFundedEvent = - IdlEvents["LaunchFundedEvent"]; -export type LaunchInitializedEvent = - IdlEvents["LaunchInitializedEvent"]; -export type LaunchRefundedEvent = - IdlEvents["LaunchRefundedEvent"]; -export type LaunchStartedEvent = - IdlEvents["LaunchStartedEvent"]; -export type LaunchpadEvent = - | LaunchClaimEvent - | LaunchCompletedEvent - | LaunchFundedEvent - | LaunchInitializedEvent - | LaunchRefundedEvent - | LaunchStartedEvent; - -export type InitializeDaoEvent = - IdlEvents["InitializeDaoEvent"]; -export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; -export type InitializeProposalEvent = - IdlEvents["InitializeProposalEvent"]; -export type FinalizeProposalEvent = - IdlEvents["FinalizeProposalEvent"]; -export type ExecuteProposalEvent = - IdlEvents["ExecuteProposalEvent"]; -export type AutocratEvent = - | InitializeDaoEvent - | UpdateDaoEvent - | InitializeProposalEvent - | FinalizeProposalEvent - | ExecuteProposalEvent; diff --git a/sdk/src/v0.4/types/optimistic_timelock.ts b/sdk/src/v0.4/types/optimistic_timelock.ts deleted file mode 100644 index fa1f43135..000000000 --- a/sdk/src/v0.4/types/optimistic_timelock.ts +++ /dev/null @@ -1,1023 +0,0 @@ -export type OptimisticTimelock = { - version: "0.3.0"; - name: "optimistic_timelock"; - instructions: [ - { - name: "createTimelock"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: true; - isSigner: true; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "enqueuers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "enqueuerCooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setDelayInSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "delayInSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setAuthority"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - ]; - }, - { - name: "setOptimisticProposerCooldownSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "cooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "addOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "enqueuer"; - type: "publicKey"; - }, - ]; - }, - { - name: "removeOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "optimisticProposer"; - type: "publicKey"; - }, - ]; - }, - { - name: "createTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "addTransaction"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }, - { - name: "sealTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "enqueueTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeTransactionBatch"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "timelock"; - type: { - kind: "struct"; - fields: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "signerBump"; - type: "u8"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "optimisticProposers"; - type: { - vec: { - defined: "OptimisticProposer"; - }; - }; - }, - { - name: "optimisticProposerCooldownSlots"; - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "transactionBatch"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "TransactionBatchStatus"; - }; - }, - { - name: "transactions"; - type: { - vec: { - defined: "Transaction"; - }; - }; - }, - { - name: "timelock"; - type: "publicKey"; - }, - { - name: "enqueuedSlot"; - type: "u64"; - }, - { - name: "transactionBatchAuthority"; - type: "publicKey"; - }, - { - name: "enqueuerType"; - type: { - defined: "AuthorityType"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "OptimisticProposer"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "lastSlotEnqueued"; - type: "u64"; - }, - ]; - }; - }, - { - name: "Transaction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - { - name: "didExecute"; - type: "bool"; - }, - ]; - }; - }, - { - name: "TransactionAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "AuthorityType"; - type: { - kind: "enum"; - variants: [ - { - name: "OptimisticProposer"; - }, - { - name: "TimelockAuthority"; - }, - ]; - }; - }, - { - name: "TransactionBatchStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Created"; - }, - { - name: "Sealed"; - }, - { - name: "Enqueued"; - }, - { - name: "Cancelled"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NotReady"; - msg: "This transaction is not yet ready to be executed"; - }, - { - code: 6001; - name: "CannotAddTransactions"; - msg: "Can only add instructions when transaction batch status is `Created`"; - }, - { - code: 6002; - name: "CannotSealTransactionBatch"; - msg: "Can only seal the transaction batch when status is `Created`"; - }, - { - code: 6003; - name: "CannotEnqueueTransactionBatch"; - msg: "Can only enqueue the timelock running once the status is `Sealed`"; - }, - { - code: 6004; - name: "CannotCancelTimelock"; - msg: "Can only cancel the transactions if the status `Enqueued`"; - }, - { - code: 6005; - name: "CanOnlyCancelDuringTimelockPeriod"; - msg: "Can only cancel the transactions during the timelock period"; - }, - { - code: 6006; - name: "CannotExecuteTransactions"; - msg: "Can only execute the transactions if the status is `Enqueued`"; - }, - { - code: 6007; - name: "NoAuthority"; - msg: "The signer is neither the timelock authority nor an optimistic proposer"; - }, - { - code: 6008; - name: "InsufficientPermissions"; - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority"; - }, - { - code: 6009; - name: "OptimisticProposerCooldown"; - msg: "This optimistic proposer is still in its cooldown period"; - }, - ]; -}; - -export const IDL: OptimisticTimelock = { - version: "0.3.0", - name: "optimistic_timelock", - instructions: [ - { - name: "createTimelock", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: true, - isSigner: true, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "enqueuers", - type: { - vec: "publicKey", - }, - }, - { - name: "enqueuerCooldownSlots", - type: "u64", - }, - ], - }, - { - name: "setDelayInSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "delayInSlots", - type: "u64", - }, - ], - }, - { - name: "setAuthority", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - ], - }, - { - name: "setOptimisticProposerCooldownSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "cooldownSlots", - type: "u64", - }, - ], - }, - { - name: "addOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "enqueuer", - type: "publicKey", - }, - ], - }, - { - name: "removeOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "optimisticProposer", - type: "publicKey", - }, - ], - }, - { - name: "createTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: true, - }, - ], - args: [], - }, - { - name: "addTransaction", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - { - name: "sealTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "enqueueTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeTransactionBatch", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "timelock", - type: { - kind: "struct", - fields: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "signerBump", - type: "u8", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "optimisticProposers", - type: { - vec: { - defined: "OptimisticProposer", - }, - }, - }, - { - name: "optimisticProposerCooldownSlots", - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "transactionBatch", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "TransactionBatchStatus", - }, - }, - { - name: "transactions", - type: { - vec: { - defined: "Transaction", - }, - }, - }, - { - name: "timelock", - type: "publicKey", - }, - { - name: "enqueuedSlot", - type: "u64", - }, - { - name: "transactionBatchAuthority", - type: "publicKey", - }, - { - name: "enqueuerType", - type: { - defined: "AuthorityType", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "OptimisticProposer", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "lastSlotEnqueued", - type: "u64", - }, - ], - }, - }, - { - name: "Transaction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - { - name: "didExecute", - type: "bool", - }, - ], - }, - }, - { - name: "TransactionAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "AuthorityType", - type: { - kind: "enum", - variants: [ - { - name: "OptimisticProposer", - }, - { - name: "TimelockAuthority", - }, - ], - }, - }, - { - name: "TransactionBatchStatus", - type: { - kind: "enum", - variants: [ - { - name: "Created", - }, - { - name: "Sealed", - }, - { - name: "Enqueued", - }, - { - name: "Cancelled", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NotReady", - msg: "This transaction is not yet ready to be executed", - }, - { - code: 6001, - name: "CannotAddTransactions", - msg: "Can only add instructions when transaction batch status is `Created`", - }, - { - code: 6002, - name: "CannotSealTransactionBatch", - msg: "Can only seal the transaction batch when status is `Created`", - }, - { - code: 6003, - name: "CannotEnqueueTransactionBatch", - msg: "Can only enqueue the timelock running once the status is `Sealed`", - }, - { - code: 6004, - name: "CannotCancelTimelock", - msg: "Can only cancel the transactions if the status `Enqueued`", - }, - { - code: 6005, - name: "CanOnlyCancelDuringTimelockPeriod", - msg: "Can only cancel the transactions during the timelock period", - }, - { - code: 6006, - name: "CannotExecuteTransactions", - msg: "Can only execute the transactions if the status is `Enqueued`", - }, - { - code: 6007, - name: "NoAuthority", - msg: "The signer is neither the timelock authority nor an optimistic proposer", - }, - { - code: 6008, - name: "InsufficientPermissions", - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority", - }, - { - code: 6009, - name: "OptimisticProposerCooldown", - msg: "This optimistic proposer is still in its cooldown period", - }, - ], -}; diff --git a/sdk/src/v0.4/types/shared_liquidity_manager.ts b/sdk/src/v0.4/types/shared_liquidity_manager.ts deleted file mode 100644 index 2de55461b..000000000 --- a/sdk/src/v0.4/types/shared_liquidity_manager.ts +++ /dev/null @@ -1,3529 +0,0 @@ -export type SharedLiquidityManager = { - version: "0.1.0"; - name: "shared_liquidity_manager"; - docs: ["TODO:", "- add unstake", "- add unit tests"]; - instructions: [ - { - name: "initializeSharedLiquidityPool"; - accounts: [ - { - name: "slPool"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "creator"; - isMut: true; - isSigner: true; - }, - { - name: "creatorSlPoolPosition"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "creatorQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "creatorBaseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "creatorLpAccount"; - isMut: true; - isSigner: false; - docs: ["so Raydium will create it"]; - }, - { - name: "raydiumInitPoolStatic"; - accounts: [ - { - name: "raydiumAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "createPoolFee"; - isMut: true; - isSigner: false; - }, - { - name: "ammConfig"; - isMut: true; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "spotPool"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolObservationState"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolBaseVault"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolQuoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeSharedLiquidityPoolParams"; - }; - }, - ]; - }, - { - name: "initializeDraftProposal"; - accounts: [ - { - name: "draftProposal"; - isMut: true; - isSigner: false; - }, - { - name: "sharedLiquidityPool"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "stakedTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDraftProposalParams"; - }; - }, - ]; - }, - { - name: "stakeToDraftProposal"; - accounts: [ - { - name: "draftProposal"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "stakerTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakedTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "stakeRecord"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "StakeToDraftProposalParams"; - }; - }, - ]; - }, - { - name: "unstakeFromDraftProposal"; - accounts: [ - { - name: "draftProposal"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "stakerTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakedTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "stakeRecord"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "UnstakeFromDraftProposalParams"; - }; - }, - ]; - }, - { - name: "depositSharedLiquidity"; - accounts: [ - { - name: "slPool"; - isMut: true; - isSigner: false; - }, - { - name: "activeSpotPool"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "spotPoolLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userSlPoolPosition"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "raydiumAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram2022"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "DepositSharedLiquidityParams"; - }; - }, - ]; - }, - { - name: "withdrawSharedLiquidity"; - accounts: [ - { - name: "slPool"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: false; - isSigner: false; - }, - { - name: "activeSpotPool"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "spotPoolLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userSlPoolPosition"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "feeReceiver"; - isMut: false; - isSigner: false; - }, - { - name: "raydiumAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram2022"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "memoProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "WithdrawSharedLiquidityParams"; - }; - }, - ]; - }, - { - name: "initializeProposalWithLiquidity"; - accounts: [ - { - name: "sharedLiquidityPool"; - isMut: true; - isSigner: false; - }, - { - name: "proposalCreator"; - isMut: false; - isSigner: true; - }, - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "raydium"; - accounts: [ - { - name: "spotPool"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "spotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "raydiumAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram2022"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "memoProgram"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "conditionalVault"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalVaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolPassBaseVault"; - isMut: true; - isSigner: true; - }, - { - name: "slPoolFailBaseVault"; - isMut: true; - isSigner: true; - }, - { - name: "slPoolPassQuoteVault"; - isMut: true; - isSigner: true; - }, - { - name: "slPoolFailQuoteVault"; - isMut: true; - isSigner: true; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: true; - isSigner: false; - }, - ]; - }, - { - name: "amm"; - accounts: [ - { - name: "passAmm"; - isMut: true; - isSigner: false; - }, - { - name: "failAmm"; - isMut: true; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolPassLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolFailLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passAmmVaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "passAmmVaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "failAmmVaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "failAmmVaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "proposalPassLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "proposalFailLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "draftProposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "autocratProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalWithLiquidityParams"; - }; - }, - ]; - }, - { - name: "removeProposalLiquidity"; - accounts: [ - { - name: "slPool"; - isMut: true; - isSigner: false; - }, - { - name: "proposal"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "raydiumInitPoolStatic"; - accounts: [ - { - name: "raydiumAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "createPoolFee"; - isMut: true; - isSigner: false; - }, - { - name: "ammConfig"; - isMut: true; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "raydium"; - accounts: [ - { - name: "activeSpotPool"; - isMut: true; - isSigner: false; - }, - { - name: "activeSpotPoolLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "activeSpotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "activeSpotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram2022"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "memoProgram"; - isMut: false; - isSigner: false; - }, - { - name: "nextSpotPool"; - isMut: true; - isSigner: false; - }, - { - name: "nextSpotPoolLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "nextSpotPoolBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "nextSpotPoolQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "nextSpotPoolObservationState"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolNextSpotLpVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPool"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "conditionalVault"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalVaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: true; - isSigner: false; - }, - ]; - }, - { - name: "ammm"; - accounts: [ - { - name: "passAmm"; - isMut: true; - isSigner: false; - }, - { - name: "failAmm"; - isMut: true; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolPassLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "slPoolFailLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passAmmVaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "passAmmVaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "failAmmVaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "failAmmVaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "ammProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "slPoolSigner"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "draftProposal"; - type: { - kind: "struct"; - fields: [ - { - name: "sharedLiquidityPool"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "status"; - type: { - defined: "DraftProposalStatus"; - }; - }, - { - name: "stakedTokenAmount"; - docs: [ - "The amount of tokens that have been staked on this draft proposal", - ]; - type: "u64"; - }, - { - name: "stakedTokenVault"; - docs: ["The vault that holds the staked tokens"]; - type: "publicKey"; - }, - { - name: "nonce"; - docs: ["The nonce used to create this draft proposal PDA"]; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - ]; - }; - }, - { - name: "liquidityPosition"; - type: { - kind: "struct"; - fields: [ - { - name: "owner"; - docs: ["The owner of this position"]; - type: "publicKey"; - }, - { - name: "pool"; - docs: ["The shared liquidity pool this position belongs to"]; - type: "publicKey"; - }, - { - name: "underlyingSpotLpShares"; - docs: [ - "The amount of underlying spot LP shares this position represents", - ]; - type: "u64"; - }, - { - name: "bump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - { - name: "sharedLiquidityPool"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "dao"; - docs: ["The DAO."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: ["The base mint."]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The quote mint."]; - type: "publicKey"; - }, - { - name: "slPoolSigner"; - docs: [ - "The signer of this pool, used because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "slPoolSignerBump"; - docs: ["The pda bump of the signer."]; - type: "u8"; - }, - { - name: "slPoolBaseVault"; - docs: [ - "Holds the base tokens for the shared liquidity pool when it's moving liquidity around.", - ]; - type: "publicKey"; - }, - { - name: "slPoolQuoteVault"; - docs: [ - "Holds the quote tokens for the shared liquidity pool when it's moving liquidity around.", - ]; - type: "publicKey"; - }, - { - name: "slPoolSpotLpVault"; - docs: ["Holds the LP tokens for the shared liquidity pool."]; - type: "publicKey"; - }, - { - name: "activeProposal"; - docs: ["The proposal that's using liquidity from this pool."]; - type: { - option: "publicKey"; - }; - }, - { - name: "proposalStakeRateThresholdBps"; - docs: [ - "The percentage of a token's supply, in basis points, that needs to be", - "staked to a draft proposal before it can be initialized.", - ]; - type: "u16"; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this shared liquidity pool. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "activeSpotPool"; - docs: [ - "The current Raydium spot pool. Changes when a proposal is removed.", - ]; - type: "publicKey"; - }, - { - name: "activeSpotPoolIndex"; - docs: [ - "The index of the current Raydium spot pool. Starts at 0 and increments by 1 for each new spot pool.", - ]; - type: "u32"; - }, - { - name: "isBaseToken0"; - docs: [ - "Whether the base token is token0 in the current Raydium spot pool (otherwise it's token1).", - ]; - type: "bool"; - }, - ]; - }; - }, - { - name: "stakeRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "staker"; - type: "publicKey"; - }, - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "DepositSharedLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokenAmount"; - docs: ["The amount of LP tokens to mint"]; - type: "u64"; - }, - { - name: "maxQuoteTokenAmount"; - docs: ["The maximum amount of quote tokens to deposit"]; - type: "u64"; - }, - { - name: "maxBaseTokenAmount"; - docs: ["The maximum amount of base tokens to deposit"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeDraftProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "draftProposalNonce"; - docs: [ - "The nonce for the draft proposal, not used for anything aside from the PDA", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeProposalWithLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeSharedLiquidityPoolParams"; - type: { - kind: "struct"; - fields: [ - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "proposalStakeRateThresholdBps"; - type: "u16"; - }, - ]; - }; - }, - { - name: "StakeToDraftProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UnstakeFromDraftProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "WithdrawSharedLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokenAmount"; - docs: ["The amount of LP tokens to withdraw"]; - type: "u64"; - }, - { - name: "minimumToken0Amount"; - docs: ["The minimum amount of token0 to receive"]; - type: "u64"; - }, - { - name: "minimumToken1Amount"; - docs: ["The minimum amount of token1 to receive"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "ProposalAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "ProposalInstruction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "ProposalAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }; - }, - { - name: "DraftProposalStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Draft"; - }, - { - name: "Initialized"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "InsufficientStake"; - msg: "Insufficient stake amount"; - }, - { - code: 6001; - name: "ProposalNotFinalized"; - msg: "Proposal is not finalized"; - }, - { - code: 6002; - name: "NoLpTokensToRemove"; - msg: "No LP tokens to remove from AMM"; - }, - { - code: 6003; - name: "NoTokensFromAmm"; - msg: "No tokens received from AMM removal"; - }, - { - code: 6004; - name: "InsufficientReservesReturned"; - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)"; - }, - { - code: 6005; - name: "PoolInUse"; - msg: "Pool is currently being used by an active proposal"; - }, - { - code: 6006; - name: "InsufficientLpShares"; - msg: "User does not have enough LP shares to withdraw"; - }, - { - code: 6007; - name: "SlippageExceeded"; - msg: "Slippage exceeded minimum token amounts"; - }, - { - code: 6008; - name: "NoLpTokensInPool"; - msg: "No LP tokens in pool's LP token account"; - }, - { - code: 6009; - name: "NotEnoughLpTokens"; - msg: "Not enough LP tokens to provide liquidity to proposal"; - }, - { - code: 6010; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6011; - name: "NoActiveProposal"; - msg: "No active proposal"; - }, - { - code: 6012; - name: "ProposalNotInDraftStatus"; - msg: "Proposal is not in draft status"; - }, - { - code: 6013; - name: "ProposalAlreadyActive"; - msg: "Proposal already active"; - }, - { - code: 6014; - name: "AmmAlreadyHasLiquidity"; - msg: "AMM already has liquidity"; - }, - { - code: 6015; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - ]; -}; - -export const IDL: SharedLiquidityManager = { - version: "0.1.0", - name: "shared_liquidity_manager", - docs: ["TODO:", "- add unstake", "- add unit tests"], - instructions: [ - { - name: "initializeSharedLiquidityPool", - accounts: [ - { - name: "slPool", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "creator", - isMut: true, - isSigner: true, - }, - { - name: "creatorSlPoolPosition", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "creatorQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "creatorBaseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "creatorLpAccount", - isMut: true, - isSigner: false, - docs: ["so Raydium will create it"], - }, - { - name: "raydiumInitPoolStatic", - accounts: [ - { - name: "raydiumAuthority", - isMut: false, - isSigner: false, - }, - { - name: "createPoolFee", - isMut: true, - isSigner: false, - }, - { - name: "ammConfig", - isMut: true, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "spotPool", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolLpMint", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolObservationState", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: false, - isSigner: false, - }, - { - name: "slPoolBaseVault", - isMut: false, - isSigner: false, - }, - { - name: "slPoolQuoteVault", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeSharedLiquidityPoolParams", - }, - }, - ], - }, - { - name: "initializeDraftProposal", - accounts: [ - { - name: "draftProposal", - isMut: true, - isSigner: false, - }, - { - name: "sharedLiquidityPool", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "stakedTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDraftProposalParams", - }, - }, - ], - }, - { - name: "stakeToDraftProposal", - accounts: [ - { - name: "draftProposal", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "stakerTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakedTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "stakeRecord", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "StakeToDraftProposalParams", - }, - }, - ], - }, - { - name: "unstakeFromDraftProposal", - accounts: [ - { - name: "draftProposal", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "stakerTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakedTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "stakeRecord", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "UnstakeFromDraftProposalParams", - }, - }, - ], - }, - { - name: "depositSharedLiquidity", - accounts: [ - { - name: "slPool", - isMut: true, - isSigner: false, - }, - { - name: "activeSpotPool", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "spotPoolLpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userSlPoolPosition", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "raydiumAuthority", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram2022", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "DepositSharedLiquidityParams", - }, - }, - ], - }, - { - name: "withdrawSharedLiquidity", - accounts: [ - { - name: "slPool", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: false, - isSigner: false, - }, - { - name: "activeSpotPool", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "spotPoolLpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userSlPoolPosition", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "feeReceiver", - isMut: false, - isSigner: false, - }, - { - name: "raydiumAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram2022", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "memoProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "WithdrawSharedLiquidityParams", - }, - }, - ], - }, - { - name: "initializeProposalWithLiquidity", - accounts: [ - { - name: "sharedLiquidityPool", - isMut: true, - isSigner: false, - }, - { - name: "proposalCreator", - isMut: false, - isSigner: true, - }, - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "slPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "raydium", - accounts: [ - { - name: "spotPool", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "spotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "raydiumAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram2022", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "memoProgram", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "conditionalVault", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "conditionalVaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "slPoolPassBaseVault", - isMut: true, - isSigner: true, - }, - { - name: "slPoolFailBaseVault", - isMut: true, - isSigner: true, - }, - { - name: "slPoolPassQuoteVault", - isMut: true, - isSigner: true, - }, - { - name: "slPoolFailQuoteVault", - isMut: true, - isSigner: true, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: true, - isSigner: false, - }, - ], - }, - { - name: "amm", - accounts: [ - { - name: "passAmm", - isMut: true, - isSigner: false, - }, - { - name: "failAmm", - isMut: true, - isSigner: false, - }, - { - name: "passLpMint", - isMut: true, - isSigner: false, - }, - { - name: "failLpMint", - isMut: true, - isSigner: false, - }, - { - name: "slPoolPassLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "slPoolFailLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "passAmmVaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "passAmmVaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "failAmmVaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "failAmmVaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "proposalPassLpVault", - isMut: true, - isSigner: false, - }, - { - name: "proposalFailLpVault", - isMut: true, - isSigner: false, - }, - { - name: "ammProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "draftProposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "autocratProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalWithLiquidityParams", - }, - }, - ], - }, - { - name: "removeProposalLiquidity", - accounts: [ - { - name: "slPool", - isMut: true, - isSigner: false, - }, - { - name: "proposal", - isMut: false, - isSigner: false, - }, - { - name: "slPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "raydiumInitPoolStatic", - accounts: [ - { - name: "raydiumAuthority", - isMut: false, - isSigner: false, - }, - { - name: "createPoolFee", - isMut: true, - isSigner: false, - }, - { - name: "ammConfig", - isMut: true, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "raydium", - accounts: [ - { - name: "activeSpotPool", - isMut: true, - isSigner: false, - }, - { - name: "activeSpotPoolLpMint", - isMut: true, - isSigner: false, - }, - { - name: "activeSpotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "activeSpotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram2022", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "memoProgram", - isMut: false, - isSigner: false, - }, - { - name: "nextSpotPool", - isMut: true, - isSigner: false, - }, - { - name: "nextSpotPoolLpMint", - isMut: true, - isSigner: false, - }, - { - name: "nextSpotPoolBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "nextSpotPoolQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "nextSpotPoolObservationState", - isMut: true, - isSigner: false, - }, - { - name: "slPoolNextSpotLpVault", - isMut: true, - isSigner: false, - }, - { - name: "slPool", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "conditionalVault", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "conditionalVaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "slPoolPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "slPoolFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: true, - isSigner: false, - }, - ], - }, - { - name: "ammm", - accounts: [ - { - name: "passAmm", - isMut: true, - isSigner: false, - }, - { - name: "failAmm", - isMut: true, - isSigner: false, - }, - { - name: "passLpMint", - isMut: true, - isSigner: false, - }, - { - name: "failLpMint", - isMut: true, - isSigner: false, - }, - { - name: "slPoolPassLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "slPoolFailLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "passAmmVaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "passAmmVaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "failAmmVaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "failAmmVaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "ammProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "slPoolSigner", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "draftProposal", - type: { - kind: "struct", - fields: [ - { - name: "sharedLiquidityPool", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "status", - type: { - defined: "DraftProposalStatus", - }, - }, - { - name: "stakedTokenAmount", - docs: [ - "The amount of tokens that have been staked on this draft proposal", - ], - type: "u64", - }, - { - name: "stakedTokenVault", - docs: ["The vault that holds the staked tokens"], - type: "publicKey", - }, - { - name: "nonce", - docs: ["The nonce used to create this draft proposal PDA"], - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - ], - }, - }, - { - name: "liquidityPosition", - type: { - kind: "struct", - fields: [ - { - name: "owner", - docs: ["The owner of this position"], - type: "publicKey", - }, - { - name: "pool", - docs: ["The shared liquidity pool this position belongs to"], - type: "publicKey", - }, - { - name: "underlyingSpotLpShares", - docs: [ - "The amount of underlying spot LP shares this position represents", - ], - type: "u64", - }, - { - name: "bump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - { - name: "sharedLiquidityPool", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "dao", - docs: ["The DAO."], - type: "publicKey", - }, - { - name: "baseMint", - docs: ["The base mint."], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The quote mint."], - type: "publicKey", - }, - { - name: "slPoolSigner", - docs: [ - "The signer of this pool, used because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "slPoolSignerBump", - docs: ["The pda bump of the signer."], - type: "u8", - }, - { - name: "slPoolBaseVault", - docs: [ - "Holds the base tokens for the shared liquidity pool when it's moving liquidity around.", - ], - type: "publicKey", - }, - { - name: "slPoolQuoteVault", - docs: [ - "Holds the quote tokens for the shared liquidity pool when it's moving liquidity around.", - ], - type: "publicKey", - }, - { - name: "slPoolSpotLpVault", - docs: ["Holds the LP tokens for the shared liquidity pool."], - type: "publicKey", - }, - { - name: "activeProposal", - docs: ["The proposal that's using liquidity from this pool."], - type: { - option: "publicKey", - }, - }, - { - name: "proposalStakeRateThresholdBps", - docs: [ - "The percentage of a token's supply, in basis points, that needs to be", - "staked to a draft proposal before it can be initialized.", - ], - type: "u16", - }, - { - name: "seqNum", - docs: [ - "The sequence number of this shared liquidity pool. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "activeSpotPool", - docs: [ - "The current Raydium spot pool. Changes when a proposal is removed.", - ], - type: "publicKey", - }, - { - name: "activeSpotPoolIndex", - docs: [ - "The index of the current Raydium spot pool. Starts at 0 and increments by 1 for each new spot pool.", - ], - type: "u32", - }, - { - name: "isBaseToken0", - docs: [ - "Whether the base token is token0 in the current Raydium spot pool (otherwise it's token1).", - ], - type: "bool", - }, - ], - }, - }, - { - name: "stakeRecord", - type: { - kind: "struct", - fields: [ - { - name: "staker", - type: "publicKey", - }, - { - name: "amount", - type: "u64", - }, - ], - }, - }, - ], - types: [ - { - name: "DepositSharedLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "lpTokenAmount", - docs: ["The amount of LP tokens to mint"], - type: "u64", - }, - { - name: "maxQuoteTokenAmount", - docs: ["The maximum amount of quote tokens to deposit"], - type: "u64", - }, - { - name: "maxBaseTokenAmount", - docs: ["The maximum amount of base tokens to deposit"], - type: "u64", - }, - ], - }, - }, - { - name: "InitializeDraftProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "draftProposalNonce", - docs: [ - "The nonce for the draft proposal, not used for anything aside from the PDA", - ], - type: "u64", - }, - ], - }, - }, - { - name: "InitializeProposalWithLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeSharedLiquidityPoolParams", - type: { - kind: "struct", - fields: [ - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "proposalStakeRateThresholdBps", - type: "u16", - }, - ], - }, - }, - { - name: "StakeToDraftProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UnstakeFromDraftProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "WithdrawSharedLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "lpTokenAmount", - docs: ["The amount of LP tokens to withdraw"], - type: "u64", - }, - { - name: "minimumToken0Amount", - docs: ["The minimum amount of token0 to receive"], - type: "u64", - }, - { - name: "minimumToken1Amount", - docs: ["The minimum amount of token1 to receive"], - type: "u64", - }, - ], - }, - }, - { - name: "ProposalAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "ProposalInstruction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "ProposalAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - }, - { - name: "DraftProposalStatus", - type: { - kind: "enum", - variants: [ - { - name: "Draft", - }, - { - name: "Initialized", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "InsufficientStake", - msg: "Insufficient stake amount", - }, - { - code: 6001, - name: "ProposalNotFinalized", - msg: "Proposal is not finalized", - }, - { - code: 6002, - name: "NoLpTokensToRemove", - msg: "No LP tokens to remove from AMM", - }, - { - code: 6003, - name: "NoTokensFromAmm", - msg: "No tokens received from AMM removal", - }, - { - code: 6004, - name: "InsufficientReservesReturned", - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)", - }, - { - code: 6005, - name: "PoolInUse", - msg: "Pool is currently being used by an active proposal", - }, - { - code: 6006, - name: "InsufficientLpShares", - msg: "User does not have enough LP shares to withdraw", - }, - { - code: 6007, - name: "SlippageExceeded", - msg: "Slippage exceeded minimum token amounts", - }, - { - code: 6008, - name: "NoLpTokensInPool", - msg: "No LP tokens in pool's LP token account", - }, - { - code: 6009, - name: "NotEnoughLpTokens", - msg: "Not enough LP tokens to provide liquidity to proposal", - }, - { - code: 6010, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6011, - name: "NoActiveProposal", - msg: "No active proposal", - }, - { - code: 6012, - name: "ProposalNotInDraftStatus", - msg: "Proposal is not in draft status", - }, - { - code: 6013, - name: "ProposalAlreadyActive", - msg: "Proposal already active", - }, - { - code: 6014, - name: "AmmAlreadyHasLiquidity", - msg: "AMM already has liquidity", - }, - { - code: 6015, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - ], -}; diff --git a/sdk/src/v0.4/types/utils.ts b/sdk/src/v0.4/types/utils.ts deleted file mode 100644 index c878debe7..000000000 --- a/sdk/src/v0.4/types/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; -}; diff --git a/sdk/src/v0.4/utils/cu.ts b/sdk/src/v0.4/utils/cu.ts deleted file mode 100644 index b55cbac95..000000000 --- a/sdk/src/v0.4/utils/cu.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const MaxCUs = { - initializeDao: 40_000, - createIdempotent: 25_000, - initializeConditionalVault: 45_000, - mintConditionalTokens: 35_000, - initializeAmm: 120_000, - addLiquidity: 120_000, - initializeProposal: 60_000, -}; - -export const DEFAULT_CU_PRICE = 1; diff --git a/sdk/src/v0.4/utils/filters.ts b/sdk/src/v0.4/utils/filters.ts deleted file mode 100644 index aee93f618..000000000 --- a/sdk/src/v0.4/utils/filters.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GetProgramAccountsFilter, PublicKey } from "@solana/web3.js"; - -export const filterPositionsByUser = ( - userAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: 8, // discriminator - bytes: userAddr.toBase58(), - }, -}); - -export const filterPositionsByAmm = ( - ammAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: - 8 + // discriminator - 32, // user address - bytes: ammAddr.toBase58(), - }, -}); diff --git a/sdk/src/v0.4/utils/index.ts b/sdk/src/v0.4/utils/index.ts deleted file mode 100644 index ee7438b0a..000000000 --- a/sdk/src/v0.4/utils/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export * from "./filters.js"; -export * from "./pda.js"; -export * from "./priceMath.js"; -export * from "./metadata.js"; -export * from "./cu.js"; -export * from "./instruction.js"; - -import { AccountMeta, ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; - -export enum PriorityFeeTier { - NORMAL = 35, - HIGH = 3571, - TURBO = 357142, -} - -export const addComputeUnits = (num_units: number = 1_400_000) => - ComputeBudgetProgram.setComputeUnitLimit({ - units: num_units, - }); - -export const addPriorityFee = (pf: number) => - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: pf, - }); - -export const pubkeyToAccountInfo = ( - pubkey: PublicKey, - isWritable: boolean, - isSigner = false, -): AccountMeta => { - return { - pubkey: pubkey, - isSigner: isSigner, - isWritable: isWritable, - }; -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/sdk/src/v0.4/utils/instruction.ts b/sdk/src/v0.4/utils/instruction.ts deleted file mode 100644 index f18e48834..000000000 --- a/sdk/src/v0.4/utils/instruction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { TransactionInstruction } from "@solana/web3.js"; - -export class InstructionUtils { - public static async getInstructions( - ...methodBuilders: any[] - ): Promise { - let instructions: TransactionInstruction[] = []; - - for (const methodBuilder of methodBuilders) { - instructions.push(...(await methodBuilder.transaction()).instructions); - } - - return instructions; - } -} diff --git a/sdk/src/v0.4/utils/metadata.ts b/sdk/src/v0.4/utils/metadata.ts deleted file mode 100644 index ef17bbdb8..000000000 --- a/sdk/src/v0.4/utils/metadata.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BN from "bn.js"; -import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { Connection } from "@solana/web3.js"; -import { bundlrUploader } from "@metaplex-foundation/umi-uploader-bundlr"; -import { UmiPlugin } from "@metaplex-foundation/umi"; - -export const assetImageMap: Record = { - fMETA: "https://arweave.net/tGxvOjMZw7B0qHsdCcIMO57oH5g5OaItOZdXo3BXKz8", - fUSDC: "https://arweave.net/DpvxeAyVbaoivhIVCLjdf566k2SwVn0YVBL0sTOezWk", - pMETA: "https://arweave.net/iuqi7PRRESdDxj1oRyk2WzR90_zdFcmZsuWicv3XGfs", - pUSDC: "https://arweave.net/e4IO7F59F_RKCiuB--_ABPot7Qh1yFsGkWzVhcXuKDU", -}; - -// Upload some JSON, returning its URL -export const uploadConditionalTokenMetadataJson = async ( - connection: Connection, - identityPlugin: UmiPlugin, - proposalNumber: number, - symbol: string, - // proposal: BN, - // conditionalToken: string, - // image: string -): Promise => { - // use bundlr, targeting arweave - const umi = createUmi(connection); - umi.use(bundlrUploader()); - umi.use(identityPlugin); - - return umi.uploader.uploadJson({ - name: `Proposal ${proposalNumber}: ${symbol}`, - image: assetImageMap[symbol], - symbol, - description: "A conditional token for use in futarchy.", - }); -}; diff --git a/sdk/src/v0.4/utils/pda.ts b/sdk/src/v0.4/utils/pda.ts deleted file mode 100644 index 4563db747..000000000 --- a/sdk/src/v0.4/utils/pda.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { AccountMeta, PublicKey } from "@solana/web3.js"; -import { utils } from "@coral-xyz/anchor"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - fromWeb3JsPublicKey, - toWeb3JsPublicKey, -} from "@metaplex-foundation/umi-web3js-adapters"; -import { - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, - RAYDIUM_CP_SWAP_PROGRAM_ID, -} from "../constants.js"; -import { LAUNCHPAD_PROGRAM_ID } from "../constants.js"; - -export const getEventAuthorityAddr = (programId: PublicKey) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("__event_authority")], - programId, - ); -}; - -export const getQuestionAddr = ( - programId: PublicKey, - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, -) => { - if (questionId.length != 32) { - throw new Error("questionId must be 32 bytes"); - } - - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("question"), - Buffer.from(questionId), - oracle.toBuffer(), - new BN(numOutcomes).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getVaultAddr = ( - programId: PublicKey, - question: PublicKey, - underlyingTokenMint: PublicKey, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_vault"), - question.toBuffer(), - underlyingTokenMint.toBuffer(), - ], - programId, - ); -}; - -export const getConditionalTokenMintAddr = ( - programId: PublicKey, - vault: PublicKey, - index: number, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_token"), - vault.toBuffer(), - new BN(index).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getDownAndUpMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { down: PublicKey; up: PublicKey } => { - return { - down: getConditionalTokenMintAddr(programId, vault, 0)[0], - up: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getFailAndPassMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { fail: PublicKey; pass: PublicKey } => { - return { - fail: getConditionalTokenMintAddr(programId, vault, 0)[0], - pass: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getMetadataAddr = (mint: PublicKey) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("metadata"), - MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - MPL_TOKEN_METADATA_PROGRAM_ID, - ); -}; - -export const getDaoTreasuryAddr = ( - programId: PublicKey, - dao: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); -}; - -export const getProposalAddr = ( - programId: PublicKey, - proposer: PublicKey, - nonce: BN, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("proposal"), - proposer.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -export const getAmmAddr = ( - programId: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("amm__"), - baseMint.toBuffer(), - quoteMint.toBuffer(), - ], - programId, - ); -}; - -export const getAmmLpMintAddr = ( - programId: PublicKey, - amm: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], - programId, - ); -}; - -export function getLaunchAddr( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - tokenMint: PublicKey, -): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch"), tokenMint.toBuffer()], - programId, - ); -} - -export const getLaunchSignerAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_signer"), launch.toBuffer()], - programId, - ); -}; - -export const getFundingRecordAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, - funder: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], - programId, - ); -}; - -export const getLaunchDaoAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_dao"), launch.toBuffer()], - programId, - ); -}; - -export const getLiquidityPoolAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - dao: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("pool_state"), dao.toBuffer()], - programId, - ); -}; - -export const getRaydiumCpmmLpMintAddr = ( - poolState: PublicKey, - isDevnet: boolean, -): [PublicKey, number] => { - const programId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - return PublicKey.findProgramAddressSync( - [Buffer.from("pool_lp_mint"), poolState.toBuffer()], - programId, - ); -}; diff --git a/sdk/src/v0.4/utils/priceMath.ts b/sdk/src/v0.4/utils/priceMath.ts deleted file mode 100644 index ee8615205..000000000 --- a/sdk/src/v0.4/utils/priceMath.ts +++ /dev/null @@ -1,198 +0,0 @@ -import BN from "bn.js"; -import { Amm } from "../types/index.js"; -import { SwapType } from "../AmmClient.js"; -import { AmmMath as V3AmmMath } from "../../v0.3/utils/ammMath.js"; - -const BN_TEN = new BN(10); -const PRICE_SCALE = BN_TEN.pow(new BN(12)); -const PRICE_SCALE_NUMBER = 1e12; - -export type AddLiquiditySimulation = { - baseAmount: BN; - quoteAmount: BN; - expectedLpTokens: BN; - minLpTokens?: BN; - maxBaseAmount?: BN; -}; - -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - -export type RemoveLiquiditySimulation = { - expectedBaseOut: BN; - expectedQuoteOut: BN; - minBaseOut?: BN; - minQuoteOut?: BN; -}; - -export class AmmMath { - // Re-export common methods from v0.3 - public static getHumanPriceFromReserves = V3AmmMath.getHumanPriceFromReserves; - public static getAmmPriceFromReserves = V3AmmMath.getAmmPriceFromReserves; - public static getChainAmount = V3AmmMath.getChainAmount; - public static getHumanAmount = V3AmmMath.getHumanAmount; - public static getAmmPrice = V3AmmMath.getAmmPrice; - public static getAmmPrices = V3AmmMath.getAmmPrices; - public static scale = V3AmmMath.scale; - public static addSlippage = V3AmmMath.addSlippage; - public static subtractSlippage = V3AmmMath.subtractSlippage; - public static simulateAddLiquidity = V3AmmMath.simulateAddLiquidity; - public static simulateRemoveLiquidity = V3AmmMath.simulateRemoveLiquidity; - - public static getHumanPrice( - ammPrice: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - const decimalScalar = BN_TEN.pow( - new BN(quoteDecimals - baseDecimals).abs(), - ); - const price1e12 = - quoteDecimals > baseDecimals - ? ammPrice.div(decimalScalar) - : ammPrice.mul(decimalScalar); - - // in case the BN is too large to cast to number, we try - try { - return price1e12.toNumber() / 1e12; - } catch (e) { - // BN tried to cast into number larger than 53 bits so we we do division via BN methods first, then cast to number(so it is smaller before the cast) - return price1e12.div(new BN(1e12)).toNumber(); - } - } - - public static getTwap(amm: Amm): BN { - return amm.oracle.aggregator.div( - amm.oracle.lastUpdatedSlot.sub(amm.createdAtSlot), - ); - } - - public static simulateSwapInner( - inputAmount: BN, - inputReserves: BN, - outputReserves: BN, - ): BN { - if (inputReserves.eqn(0) || outputReserves.eqn(0)) { - throw new Error("reserves must be non-zero"); - } - - let inputAmountWithFee: BN = inputAmount.muln(990); - - let numerator: BN = inputAmountWithFee.mul(outputReserves); - let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); - - return numerator.div(denominator); - } - - public static simulateSwap( - inputAmount: BN, - swapType: SwapType, - baseReserves: BN, - quoteReserves: BN, - slippageBps?: BN, - ): SwapSimulation { - let inputReserves: BN, outputReserves: BN; - if (swapType.buy) { - inputReserves = quoteReserves; - outputReserves = baseReserves; - } else { - inputReserves = baseReserves; - outputReserves = quoteReserves; - } - - let expectedOut = this.simulateSwapInner( - inputAmount, - inputReserves, - outputReserves, - ); - - let minExpectedOut; - if (slippageBps) { - minExpectedOut = AmmMath.subtractSlippage(expectedOut, slippageBps); - } - - let newBaseReserves: BN, newQuoteReserves: BN; - if (swapType.buy) { - newBaseReserves = baseReserves.sub(expectedOut); - newQuoteReserves = quoteReserves.add(inputAmount); - } else { - newBaseReserves = baseReserves.add(inputAmount); - newQuoteReserves = quoteReserves.sub(expectedOut); - } - - return { - expectedOut, - newBaseReserves, - newQuoteReserves, - minExpectedOut, - }; - } - - /** - * Calculates the optimal swap amount and mergeable tokens without using square roots. - * @param userBalanceIn BN – Tokens that a user wants to dispose of. - * @param ammReserveIn BN – Amount of tokens in the AMM of the token that the user wants to dispose of. - * @param ammReserveOut BN – Amount of tokens in the AMM of the token that the user wants to receive. - * @returns An object containing the optimal swap amount, expected quote received, and expected mergeable tokens. - */ - - public static calculateOptimalSwapForMerge( - userBalanceIn: BN, - ammReserveIn: BN, - ammReserveOut: BN, - slippageBps: BN, - ): { - optimalSwapAmount: BN; - userInAfterSwap: BN; - expectedOut: BN; - minimumExpectedOut: BN; - } { - // essentially, we want to calculate the swap amount so that the remaining user balance = received token amount - - // solve this system of equations for swapAmount, outputAmount (we only care about swap amount tho) - // (baseReserve + swapAmount) * (quoteReserve - outputAmount) = baseReserve * quoteReserve - // baseAmount - swapAmount = outputAmount - - //solve equation - // (baseReserve + .99*swapAmount) * (quoteReserve - (userTokens - swapAmount)) = baseReserve * quoteReserve - // multiplying out the left hand side and subtracting baseReserve * quoteReserve from both sides yields the following: - // baseReserve*quoteReserve - baseReserve*userTokens + baseReserve*swapAmount + .99*swapAmount*quoteReserve - .99*swapAmount*userTokens + .99*swapAmount^2 = baseReserve*quoteReserve - // .99*swapAmount^2 + baseReserve*swapAmount + .99*swapAmount*quoteReserve - baseReserve*userTokens - .99*swapAmount*userTokens = 0 - // in the quadratic equation, a = .99, b = (baseReserve + .99*quoteReserve - .99*userTokens), c = -baseReserve*userTokens - // x = (-b + sqrt(b^2 - 4ac)) / 2a - - let a = 0.99; - let b = - Number(ammReserveIn) + - 0.99 * Number(ammReserveOut) - - 0.99 * Number(userBalanceIn); - let c = -Number(ammReserveIn) * Number(userBalanceIn); - - let x = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a); - //this should mathematically return a positive number assuming userBalanceIn, ammReserveIn, and ammReserveOut are all positive (which they should be) - // -b + Math.sqrt(b ** 2 - 4 * a * c) > 0 because -4*a*c > 0 and sqrt(b**2 + positive number) > b - - const swapAmount = x; - - let expectedOut = this.simulateSwapInner( - new BN(swapAmount), - ammReserveIn, - ammReserveOut, - ); - let minimumExpectedOut = - Number(expectedOut) - (Number(expectedOut) * Number(slippageBps)) / 10000; - return { - optimalSwapAmount: new BN(swapAmount), - userInAfterSwap: new BN(Number(userBalanceIn) - swapAmount), - expectedOut: expectedOut, - minimumExpectedOut: new BN(minimumExpectedOut), - }; - } -} - -// Add backwards compatibility alias -export { AmmMath as PriceMath }; diff --git a/sdk/src/v0.5/AmmClient.ts b/sdk/src/v0.5/AmmClient.ts deleted file mode 100644 index 62b540cbf..000000000 --- a/sdk/src/v0.5/AmmClient.ts +++ /dev/null @@ -1,381 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, -} from "@solana/web3.js"; - -import { Amm as AmmIDLType, IDL as AmmIDL } from "./types/amm.js"; - -import BN from "bn.js"; -import { AMM_PROGRAM_ID } from "./constants.js"; -import { Amm, LowercaseKeys } from "./types/index.js"; -import { getAmmLpMintAddr, getAmmAddr } from "./utils/pda.js"; -// import { MethodsBuilder } from "@coral-xyz/anchor/dist/cjs/program/namespace/methods"; -import { - MintLayout, - unpackMint, - getAssociatedTokenAddressSync, - createAssociatedTokenAccountIdempotentInstruction, -} from "@solana/spl-token"; -import { AmmMath, PriceMath } from "./utils/priceMath.js"; - -export type SwapType = LowercaseKeys["SwapType"]>; - -export type CreateAmmClientParams = { - provider: AnchorProvider; - ammProgramId?: PublicKey; -}; - -export class AmmClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.program = new Program(AmmIDL, ammProgramId, provider); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateAmmClientParams, - ): AmmClient { - let { provider, ammProgramId: programId } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AmmClient(provider, programId || AMM_PROGRAM_ID, luts); - } - - getProgramId(): PublicKey { - return this.program.programId; - } - - async getAmm(amm: PublicKey): Promise { - return await this.program.account.amm.fetch(amm); - } - - async fetchAmm(amm: PublicKey): Promise { - return await this.program.account.amm.fetchNullable(amm); - } - - async deserializeAmm(accountInfo: AccountInfo): Promise { - return this.program.coder.accounts.decode("amm", accountInfo.data); - } - - async createAmm( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - twapStartDelaySlots: BN, - twapInitialObservation: number, - twapMaxObservationChangePerUpdate?: number, - ): Promise { - if (!twapMaxObservationChangePerUpdate) { - twapMaxObservationChangePerUpdate = twapInitialObservation * 0.02; - } - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - - let baseDecimals = unpackMint( - baseMint, - await this.provider.connection.getAccountInfo(baseMint), - ).decimals; - let quoteDecimals = unpackMint( - quoteMint, - await this.provider.connection.getAccountInfo(quoteMint), - ).decimals; - - let [twapFirstObservationScaled, twapMaxObservationChangePerUpdateScaled] = - PriceMath.getAmmPrices( - baseDecimals, - quoteDecimals, - twapInitialObservation, - twapMaxObservationChangePerUpdate, - ); - - await this.initializeAmmIx( - baseMint, - quoteMint, - twapStartDelaySlots, - twapFirstObservationScaled, - twapMaxObservationChangePerUpdateScaled, - ).rpc(); - - return amm; - } - - // both twap values need to be scaled beforehand - initializeAmmIx( - baseMint: PublicKey, - quoteMint: PublicKey, - twapStartDelaySlots: BN, - twapInitialObservation: BN, - twapMaxObservationChangePerUpdate: BN, - ) { - let [amm] = getAmmAddr(this.getProgramId(), baseMint, quoteMint); - let [lpMint] = getAmmLpMintAddr(this.getProgramId(), amm); - - let vaultAtaBase = getAssociatedTokenAddressSync(baseMint, amm, true); - let vaultAtaQuote = getAssociatedTokenAddressSync(quoteMint, amm, true); - - return this.program.methods - .createAmm({ - twapInitialObservation, - twapMaxObservationChangePerUpdate, - twapStartDelaySlots, - }) - .accounts({ - user: this.provider.publicKey, - amm, - lpMint, - baseMint, - quoteMint, - vaultAtaBase, - vaultAtaQuote, - }); - } - - async addLiquidity( - amm: PublicKey, - quoteAmount?: number, - baseAmount?: number, - ) { - let storedAmm = await this.getAmm(amm); - - let lpMintSupply = unpackMint( - storedAmm.lpMint, - await this.provider.connection.getAccountInfo(storedAmm.lpMint), - ).supply; - - let quoteAmountCasted: BN | undefined; - let baseAmountCasted: BN | undefined; - - if (quoteAmount != undefined) { - let quoteDecimals = unpackMint( - storedAmm.quoteMint, - await this.provider.connection.getAccountInfo(storedAmm.quoteMint), - ).decimals; - quoteAmountCasted = new BN(quoteAmount).mul( - new BN(10).pow(new BN(quoteDecimals)), - ); - } - - if (baseAmount != undefined) { - let baseDecimals = unpackMint( - storedAmm.baseMint, - await this.provider.connection.getAccountInfo(storedAmm.baseMint), - ).decimals; - baseAmountCasted = new BN(baseAmount).mul( - new BN(10).pow(new BN(baseDecimals)), - ); - } - - if (lpMintSupply == 0n) { - if (quoteAmount == undefined || baseAmount == undefined) { - throw new Error( - "No pool created yet, you need to specify both base and quote", - ); - } - - // console.log(quoteAmountCasted?.toString()); - // console.log(baseAmountCasted?.toString()) - - return await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - quoteAmountCasted as BN, - baseAmountCasted as BN, - new BN(0), - ).rpc(); - } - - // quoteAmount == undefined ? undefined : new BN(quoteAmount); - // let baseAmountCasted: BN | undefined = - // baseAmount == undefined ? undefined : new BN(baseAmount); - - let sim = AmmMath.simulateAddLiquidity( - storedAmm.baseAmount, - storedAmm.quoteAmount, - Number(lpMintSupply), - baseAmountCasted, - quoteAmountCasted, - ); - - await this.addLiquidityIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - sim.quoteAmount, - sim.baseAmount, - sim.expectedLpTokens, - ).rpc(); - } - - addLiquidityIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - quoteAmount: BN, - maxBaseAmount: BN, - minLpTokens: BN, - user: PublicKey = this.provider.publicKey, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, amm); - - const userLpAccount = getAssociatedTokenAddressSync(lpMint, user, true); - - return this.program.methods - .addLiquidity({ - quoteAmount, - maxBaseAmount, - minLpTokens, - }) - .accounts({ - user, - amm, - lpMint, - userLpAccount, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - user, - userLpAccount, - user, - lpMint, - ), - ]); - } - - removeLiquidityIx( - ammAddr: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - lpTokensToBurn: BN, - minBaseAmount: BN, - minQuoteAmount: BN, - ) { - const [lpMint] = getAmmLpMintAddr(this.program.programId, ammAddr); - - return this.program.methods - .removeLiquidity({ - lpTokensToBurn, - minBaseAmount, - minQuoteAmount, - }) - .accounts({ - user: this.provider.publicKey, - amm: ammAddr, - lpMint, - userLpAccount: getAssociatedTokenAddressSync( - lpMint, - this.provider.publicKey, - true, - ), - userBaseAccount: getAssociatedTokenAddressSync( - baseMint, - this.provider.publicKey, - true, - ), - userQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - this.provider.publicKey, - true, - ), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, ammAddr, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, ammAddr, true), - }); - } - - async swap( - amm: PublicKey, - swapType: SwapType, - inputAmount: number, - outputAmountMin: number, - ) { - const storedAmm = await this.getAmm(amm); - - let quoteDecimals = await this.getDecimals(storedAmm.quoteMint); - let baseDecimals = await this.getDecimals(storedAmm.baseMint); - - let inputAmountScaled: BN; - let outputAmountMinScaled: BN; - if (swapType.buy) { - inputAmountScaled = PriceMath.scale(inputAmount, quoteDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, baseDecimals); - } else { - inputAmountScaled = PriceMath.scale(inputAmount, baseDecimals); - outputAmountMinScaled = PriceMath.scale(outputAmountMin, quoteDecimals); - } - - return await this.swapIx( - amm, - storedAmm.baseMint, - storedAmm.quoteMint, - swapType, - inputAmountScaled, - outputAmountMinScaled, - ).rpc(); - } - - swapIx( - amm: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - swapType: SwapType, - inputAmount: BN, - outputAmountMin: BN, - user: PublicKey = this.provider.publicKey, - ) { - const receivingToken = swapType.buy ? baseMint : quoteMint; - - return this.program.methods - .swap({ - swapType, - inputAmount, - outputAmountMin, - }) - .accounts({ - user, - amm, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, user, true), - userQuoteAccount: getAssociatedTokenAddressSync(quoteMint, user, true), - vaultAtaBase: getAssociatedTokenAddressSync(baseMint, amm, true), - vaultAtaQuote: getAssociatedTokenAddressSync(quoteMint, amm, true), - }) - .preInstructions([ - // create the receiving token account if it doesn't exist - createAssociatedTokenAccountIdempotentInstruction( - user, - getAssociatedTokenAddressSync(receivingToken, user, true), - user, - receivingToken, - ), - ]); - } - - async crankThatTwap(amm: PublicKey) { - return this.crankThatTwapIx(amm).rpc(); - } - - crankThatTwapIx(amm: PublicKey) { - return this.program.methods.crankThatTwap().accounts({ - amm, - }); - } - - async getDecimals(mint: PublicKey): Promise { - return unpackMint(mint, await this.provider.connection.getAccountInfo(mint)) - .decimals; - } -} diff --git a/sdk/src/v0.5/AutocratClient.ts b/sdk/src/v0.5/AutocratClient.ts deleted file mode 100644 index f05795e1f..000000000 --- a/sdk/src/v0.5/AutocratClient.ts +++ /dev/null @@ -1,675 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AccountMeta, - AddressLookupTableAccount, - ComputeBudgetProgram, - Connection, - Keypair, - PublicKey, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { InitializeDaoParams, UpdateDaoParams } from "./types/index.js"; - -import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; -import { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./types/conditional_vault.js"; - -import BN from "bn.js"; -import { - AMM_PROGRAM_ID, - AUTOCRAT_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - MAINNET_USDC, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - SQUADS_PROGRAM_ID, - USDC_DECIMALS, -} from "./constants.js"; -import { - DEFAULT_CU_PRICE, - InstructionUtils, - MaxCUs, - getAmmAddr, - getAmmLpMintAddr, - getConditionalTokenMintAddr, - getDaoAddr, - getDaoTreasuryAddr, - getEventAuthorityAddr, - getProposalAddr, - getQuestionAddr, - getVaultAddr, -} from "./utils/index.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { AmmClient } from "./AmmClient.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - unpackMint, -} from "@solana/spl-token"; -import { sha256 } from "@noble/hashes/sha256"; -import { Dao, Proposal } from "./types/index.js"; - -import * as multisig from "@sqds/multisig"; - -export type CreateClientParams = { - provider: AnchorProvider; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export type ProposalVaults = { - baseVault: PublicKey; - quoteVault: PublicKey; -}; - -export class AutocratClient { - public readonly provider: AnchorProvider; - public readonly autocrat: Program; - public readonly vaultClient: ConditionalVaultClient; - public readonly ammClient: AmmClient; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - autocratProgramId: PublicKey, - conditionalVaultProgramId: PublicKey, - ammProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.autocrat = new Program( - AutocratIDL, - autocratProgramId, - provider, - ); - this.vaultClient = ConditionalVaultClient.createClient({ - provider, - conditionalVaultProgramId, - }); - this.ammClient = AmmClient.createClient({ provider, ammProgramId }); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateClientParams, - ): AutocratClient { - let { - provider, - autocratProgramId, - conditionalVaultProgramId, - ammProgramId, - } = createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new AutocratClient( - provider, - autocratProgramId || AUTOCRAT_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ammProgramId || AMM_PROGRAM_ID, - luts, - ); - } - - getProgramId(): PublicKey { - return this.autocrat.programId; - } - - async getProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetch(proposal); - } - - async getDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetch(dao); - } - - async fetchProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetchNullable(proposal); - } - - async fetchDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetchNullable(dao); - } - - async deserializeProposal( - accountInfo: AccountInfo, - ): Promise { - return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); - } - - async deserializeDao(accountInfo: AccountInfo): Promise { - return this.autocrat.coder.accounts.decode("dao", accountInfo.data); - } - - getProposalPdas( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - dao: PublicKey, - ): { - question: PublicKey; - baseVault: PublicKey; - quoteVault: PublicKey; - passBaseMint: PublicKey; - passQuoteMint: PublicKey; - failBaseMint: PublicKey; - failQuoteMint: PublicKey; - passAmm: PublicKey; - failAmm: PublicKey; - passLp: PublicKey; - failLp: PublicKey; - } { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const [question] = getQuestionAddr( - vaultProgramId, - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const [baseVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - quoteMint, - ); - - const [failBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 0, - ); - const [failQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 0, - ); - - const [passBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 1, - ); - const [passQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 1, - ); - - const [passAmm] = getAmmAddr( - this.ammClient.program.programId, - passBaseMint, - passQuoteMint, - ); - const [failAmm] = getAmmAddr( - this.ammClient.program.programId, - failBaseMint, - failQuoteMint, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - return { - question, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - passAmm, - failAmm, - passLp, - failLp, - }; - } - - // async initializeDao( - // tokenMint: PublicKey, - // tokenPriceUiAmount: number, - // minBaseFutarchicLiquidity: number, - // minQuoteFutarchicLiquidity: number, - // usdcMint: PublicKey = MAINNET_USDC, - // daoKeypair: Keypair = Keypair.generate(), - // twapStartDelaySlots: BN - // ): Promise { - // let tokenDecimals = unpackMint( - // tokenMint, - // await this.provider.connection.getAccountInfo(tokenMint) - // ).decimals; - - // let scaledPrice = PriceMath.getAmmPrice( - // tokenPriceUiAmount, - // tokenDecimals, - // USDC_DECIMALS - // ); - - // // console.log( - // // PriceMath.getHumanPrice(scaledPrice, tokenDecimals, USDC_DECIMALS) - // // ); - - // await this.initializeDaoIx({ - // daoKeypair, - // baseMint: tokenMint, - // params: { - // twapStartDelaySlots, - // twapInitialObservation: scaledPrice, - // twapMaxObservationChangePerUpdate: scaledPrice.divn(50), - // minQuoteFutarchicLiquidity: new BN(minQuoteFutarchicLiquidity).mul( - // new BN(10).pow(new BN(USDC_DECIMALS)) - // ), - // minBaseFutarchicLiquidity: new BN(minBaseFutarchicLiquidity).mul( - // new BN(10).pow(new BN(tokenDecimals)) - // ), - // passThresholdBps: null, - // slotsPerProposal: null, - // }, - // quoteMint: usdcMint, - // }) - // .postInstructions([ - // ComputeBudgetProgram.setComputeUnitLimit({ - // units: MaxCUs.initializeDao, - // }), - // ComputeBudgetProgram.setComputeUnitPrice({ - // microLamports: DEFAULT_CU_PRICE, - // }), - // ]) - // .rpc({ maxRetries: 5 }); - - // return daoKeypair.publicKey; - // } - - initializeDaoIx({ - baseMint, - params, - quoteMint = MAINNET_USDC, - squadsProgramConfigTreasury = SQUADS_PROGRAM_CONFIG_TREASURY, - }: { - baseMint: PublicKey; - params: InitializeDaoParams; - quoteMint?: PublicKey; - squadsProgramConfigTreasury?: PublicKey; - }) { - const [dao] = getDaoAddr({ - nonce: params.nonce, - daoCreator: this.provider.publicKey, - }); - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - const spendingLimit = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - })[0]; - - return this.autocrat.methods.initializeDao(params).accounts({ - dao, - baseMint, - quoteMint, - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury, - squadsProgram: SQUADS_PROGRAM_ID, - spendingLimit, - }); - } - - async initializeProposal( - dao: PublicKey, - descriptionUrl: string, - squadsProposal: PublicKey, - baseTokensToLP: BN, - quoteTokensToLP: BN, - ): Promise { - const storedDao = await this.getDao(dao); - - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); - - await this.vaultClient.initializeQuestion( - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - - const { - baseVault, - quoteVault, - passAmm, - failAmm, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - question, - } = this.getProposalPdas( - proposal, - storedDao.baseMint, - storedDao.quoteMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - await this.vaultClient - .initializeVaultIx(question, storedDao.baseMint, 2) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(question, storedDao.quoteMint, 2), - this.ammClient.initializeAmmIx( - passBaseMint, - passQuoteMint, - storedDao.twapStartDelaySlots, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - this.ammClient.initializeAmmIx( - failBaseMint, - failQuoteMint, - storedDao.twapStartDelaySlots, - storedDao.twapInitialObservation, - storedDao.twapMaxObservationChangePerUpdate, - ), - ), - ) - .rpc(); - - console.log(baseTokensToLP.toString()); - await this.vaultClient - .splitTokensIx(question, baseVault, storedDao.baseMint, baseTokensToLP, 2) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.splitTokensIx( - question, - quoteVault, - storedDao.quoteMint, - quoteTokensToLP, - 2, - ), - ), - ) - .rpc(); - - await this.ammClient - .addLiquidityIx( - passAmm, - passBaseMint, - passQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ) - .postInstructions( - await InstructionUtils.getInstructions( - this.ammClient.addLiquidityIx( - failAmm, - failBaseMint, - failQuoteMint, - quoteTokensToLP, - baseTokensToLP, - new BN(0), - ), - ), - ) - .rpc(); - - // this is how many original tokens are created - const lpTokens = quoteTokensToLP; - - await this.initializeProposalIx( - descriptionUrl, - squadsProposal, - dao, - storedDao.baseMint, - storedDao.quoteMint, - lpTokens, - lpTokens, - question, - ).rpc(); - - return proposal; - } - - initializeProposalIx( - descriptionUrl: string, - squadsProposal: PublicKey, - dao: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - passLpTokensToLock: BN, - failLpTokensToLock: BN, - question: PublicKey, - proposer: PublicKey = this.provider.publicKey, - ) { - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); - const { baseVault, quoteVault, passAmm, failAmm } = this.getProposalPdas( - proposal, - baseMint, - quoteMint, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - const passLpVaultAccount = getAssociatedTokenAddressSync( - passLp, - proposal, - true, - ); - const failLpVaultAccount = getAssociatedTokenAddressSync( - failLp, - proposal, - true, - ); - - return this.autocrat.methods - .initializeProposal({ - descriptionUrl, - passLpTokensToLock, - failLpTokensToLock, - }) - .accounts({ - question, - proposal, - squadsProposal, - dao, - baseVault, - quoteVault, - passAmm, - failAmm, - passLpMint: passLp, - failLpMint: failLp, - passLpUserAccount: getAssociatedTokenAddressSync( - passLp, - proposer, - true, - ), - failLpUserAccount: getAssociatedTokenAddressSync( - failLp, - proposer, - true, - ), - passLpVaultAccount, - failLpVaultAccount, - proposer, - }); - } - - async finalizeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - let storedDao = await this.getDao(storedProposal.dao); - - return this.finalizeProposalIx( - proposal, - storedProposal.squadsProposal, - storedProposal.dao, - storedDao.baseMint, - storedDao.quoteMint, - storedProposal.proposer, - ).rpc(); - } - - finalizeProposalIx( - proposal: PublicKey, - squadsProposal: PublicKey, - dao: PublicKey, - daoToken: PublicKey, - usdc: PublicKey, - proposer: PublicKey, - ) { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - const { question, passAmm, failAmm } = this.getProposalPdas( - proposal, - daoToken, - usdc, - dao, - ); - - const [passLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - passAmm, - ); - const [failLp] = getAmmLpMintAddr( - this.ammClient.program.programId, - failAmm, - ); - - const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); - - return this.autocrat.methods.finalizeProposal().accounts({ - proposal, - passAmm, - failAmm, - dao, - squadsProposal, - squadsMultisig: multisigPda, - squadsMultisigProgram: SQUADS_PROGRAM_ID, - question, - // baseVault, - // quoteVault, - passLpUserAccount: getAssociatedTokenAddressSync(passLp, proposer, true), - failLpUserAccount: getAssociatedTokenAddressSync(failLp, proposer, true), - passLpVaultAccount: getAssociatedTokenAddressSync(passLp, proposal, true), - failLpVaultAccount: getAssociatedTokenAddressSync(failLp, proposal, true), - vaultProgram: this.vaultClient.vaultProgram.programId, - vaultEventAuthority, - }); - } - - // async executeProposal(proposal: PublicKey) { - // let storedProposal = await this.getProposal(proposal); - - // return this.executeProposalIx( - // proposal, - // storedProposal.dao, - // storedProposal.instruction - // ).rpc(); - // } - - // executeProposalIx(proposal: PublicKey, dao: PublicKey, instruction: any) { - // const [daoTreasury] = getDaoTreasuryAddr(this.autocrat.programId, dao); - // return this.autocrat.methods - // .executeProposal() - // .accounts({ - // proposal, - // dao, - // // daoTreasury, - // }) - // .remainingAccounts( - // instruction.accounts - // .concat({ - // pubkey: instruction.programId, - // isWritable: false, - // isSigner: false, - // }) - // .map((meta: AccountMeta) => - // meta.pubkey.equals(daoTreasury) - // ? { ...meta, isSigner: false } - // : meta - // ) - // ); - // } - - updateDaoIx({ dao, params }: { dao: PublicKey; params: UpdateDaoParams }) { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - return this.autocrat.methods.updateDao(params).accounts({ - dao, - squadsMultisigVault, - }); - } - - // cranks the TWAPs of multiple proposals' markets. there's a limit on the - // number of proposals you can pass in, which I can't determine rn because - // there aren't enough proposals on devnet - async crankProposalMarkets( - proposals: PublicKey[], - priorityFeeMicroLamports: number, - ) { - const amms: PublicKey[] = []; - - for (const proposal of proposals) { - const storedProposal = await this.getProposal(proposal); - amms.push(storedProposal.passAmm); - amms.push(storedProposal.failAmm); - } - - while (true) { - let ixs: TransactionInstruction[] = []; - - for (const amm of amms) { - ixs.push(await this.ammClient.crankThatTwapIx(amm).instruction()); - } - - let tx = new Transaction(); - tx.add( - ComputeBudgetProgram.setComputeUnitLimit({ units: 4_000 * ixs.length }), - ); - tx.add( - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: priorityFeeMicroLamports, - }), - ); - tx.add(...ixs); - try { - await this.provider.sendAndConfirm(tx); - } catch (err) { - console.log("err", err); - } - - await new Promise((resolve) => setTimeout(resolve, 65 * 1000)); // 65,000 milliseconds = 1 minute and 5 seconds - } - } -} diff --git a/sdk/src/v0.5/ConditionalVaultClient.ts b/sdk/src/v0.5/ConditionalVaultClient.ts deleted file mode 100644 index 047e0a46f..000000000 --- a/sdk/src/v0.5/ConditionalVaultClient.ts +++ /dev/null @@ -1,475 +0,0 @@ -import { AnchorProvider, Program, utils } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, - SystemProgram, -} from "@solana/web3.js"; - -import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; - -import BN from "bn.js"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, -} from "./constants.js"; -import { - getQuestionAddr, - getMetadataAddr, - getVaultAddr, - getConditionalTokenMintAddr, -} from "./utils/index.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { ConditionalVault, Question } from "./types/index.js"; - -export type CreateVaultClientParams = { - provider: AnchorProvider; - conditionalVaultProgramId?: PublicKey; -}; - -export class ConditionalVaultClient { - public readonly provider: AnchorProvider; - public readonly vaultProgram: Program; - - constructor(provider: AnchorProvider, conditionalVaultProgramId: PublicKey) { - this.provider = provider; - this.vaultProgram = new Program( - ConditionalVaultIDL, - conditionalVaultProgramId, - provider, - ); - } - - public static createClient( - createVaultClientParams: CreateVaultClientParams, - ): ConditionalVaultClient { - let { provider, conditionalVaultProgramId } = createVaultClientParams; - - return new ConditionalVaultClient( - provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ); - } - - async fetchQuestion(question: PublicKey): Promise { - return this.vaultProgram.account.question.fetchNullable(question); - } - - async fetchVault(vault: PublicKey): Promise { - return this.vaultProgram.account.conditionalVault.fetchNullable(vault); - } - - async deserializeQuestion( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "question", - accountInfo.data, - ); - } - - async deserializeVault( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "conditionalVault", - accountInfo.data, - ); - } - - initializeQuestionIx( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ) { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - return this.vaultProgram.methods - .initializeQuestion({ - questionId: Array.from(questionId), - oracle, - numOutcomes, - }) - .accounts({ - question, - }); - } - - async initializeQuestion( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ): Promise { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - await this.initializeQuestionIx(questionId, oracle, numOutcomes).rpc(); - - return question; - } - - initializeVaultIx( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - payer: PublicKey = this.provider.publicKey, - ) { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ); - - return this.vaultProgram.methods - .initializeConditionalVault() - .accounts({ - vault, - question, - underlyingTokenMint, - vaultUnderlyingTokenAccount, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - vaultUnderlyingTokenAccount, - vault, - underlyingTokenMint, - ), - ]) - .remainingAccounts( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - } - - // TODO remove `numOucomes` - - async initializeVault( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - ): Promise { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - await this.initializeVaultIx( - question, - underlyingTokenMint, - numOutcomes, - ).rpc(); - - return vault; - } - - resolveQuestionIx( - question: PublicKey, - oracle: Keypair, - payoutNumerators: number[], - ) { - return this.vaultProgram.methods - .resolveQuestion({ - payoutNumerators, - }) - .accounts({ - question, - oracle: oracle.publicKey, - }) - .signers([oracle]); - } - - getConditionalTokenMints(vault: PublicKey, numOutcomes: number): PublicKey[] { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - return conditionalTokenMintAddrs; - } - - getRemainingAccounts( - conditionalTokenMints: PublicKey[], - userConditionalAccounts: PublicKey[], - ) { - return conditionalTokenMints - .concat(userConditionalAccounts) - .map((account) => ({ - pubkey: account, - isWritable: true, - isSigner: false, - })); - } - - // Helper method to get conditional token accounts and instructions - getConditionalTokenAccountsAndInstructions( - vault: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - const userConditionalAccounts = conditionalTokenMintAddrs.map((mint) => - getAssociatedTokenAddressSync(mint, user, true), - ); - - const preInstructions = conditionalTokenMintAddrs.map((mint) => - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(mint, user, true), - user, - mint, - ), - ); - - const remainingAccounts = this.getRemainingAccounts( - conditionalTokenMintAddrs, - userConditionalAccounts, - ); - - return { userConditionalAccounts, preInstructions, remainingAccounts }; - } - - splitTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const { preInstructions, remainingAccounts } = - this.getConditionalTokenAccountsAndInstructions( - vault, - numOutcomes, - user, - payer, - ); - - return this.vaultProgram.methods - .splitTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions(preInstructions) - .remainingAccounts(remainingAccounts); - } - - mergeTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .mergeTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - redeemTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .redeemTokens() - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - addMetadataToConditionalTokensIx( - vault: PublicKey, - index: number, - name: string, - symbol: string, - uri: string, - payer: PublicKey = this.provider.publicKey, - ) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - index, - ); - - const [conditionalTokenMetadata] = getMetadataAddr(conditionalTokenMint); - - return this.vaultProgram.methods - .addMetadataToConditionalTokens({ - name, - symbol, - uri, - }) - .accounts({ - payer, - vault, - conditionalTokenMint, - conditionalTokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.5/LaunchpadClient.ts b/sdk/src/v0.5/LaunchpadClient.ts deleted file mode 100644 index af27d1816..000000000 --- a/sdk/src/v0.5/LaunchpadClient.ts +++ /dev/null @@ -1,451 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Keypair, - AccountInfo, - ComputeBudgetProgram, -} from "@solana/web3.js"; -import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; -import { - LAUNCHPAD_PROGRAM_ID, - RAYDIUM_AUTHORITY, - LOW_FEE_RAYDIUM_CONFIG, - RAYDIUM_CP_SWAP_PROGRAM_ID, - RAYDIUM_CREATE_POOL_FEE_RECEIVE, - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - DEVNET_RAYDIUM_AUTHORITY, - DEVNET_LOW_FEE_RAYDIUM_CONFIG, - DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, - MPL_TOKEN_METADATA_PROGRAM_ID, - MAINNET_USDC, - DEVNET_USDC, - SQUADS_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, -} from "./constants.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { FundingRecord, Launch } from "./types/index.js"; -import { - getDaoAddr, - getDaoTreasuryAddr, - getEventAuthorityAddr, - getFundingRecordAddr, - getLaunchAddr, - getLaunchSignerAddr, - getLiquidityPoolAddr, - getMetadataAddr, - getRaydiumCpmmLpMintAddr, -} from "./utils/pda.js"; -import { AutocratClient } from "./AutocratClient.js"; -import * as anchor from "@coral-xyz/anchor"; -import * as multisig from "@sqds/multisig"; - -export type CreateLaunchpadClientParams = { - provider: AnchorProvider; - launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export class LaunchpadClient { - public launchpad: Program; - public provider: AnchorProvider; - public autocratClient: AutocratClient; - - private constructor(params: CreateLaunchpadClientParams) { - this.provider = params.provider; - this.launchpad = new Program( - LaunchpadIDL, - params.launchpadProgramId || LAUNCHPAD_PROGRAM_ID, - this.provider, - ); - this.autocratClient = AutocratClient.createClient({ - provider: this.provider, - autocratProgramId: params.autocratProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - ammProgramId: params.ammProgramId, - }); - } - - static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { - return new LaunchpadClient(params); - } - - getProgramId(): PublicKey { - return this.launchpad.programId; - } - - async getLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetch(launch); - } - - async fetchLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetchNullable(launch); - } - - async deserializeLaunch(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("launch", accountInfo.data); - } - - async getFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetch(fundingRecord); - } - - async fetchFundingRecord( - fundingRecord: PublicKey, - ): Promise { - return await this.launchpad.account.fundingRecord.fetchNullable( - fundingRecord, - ); - } - - async deserializeFundingRecord( - accountInfo: AccountInfo, - ): Promise { - return this.launchpad.coder.accounts.decode( - "fundingRecord", - accountInfo.data, - ); - } - - initializeLaunchIx( - tokenName: string, - tokenSymbol: string, - tokenUri: string, - minimumRaiseAmount: BN, - secondsForLaunch: number, - baseMint: PublicKey, - quoteMint: PublicKey, - monthlySpendingLimitAmount: BN, - monthlySpendingLimitMembers: PublicKey[], - launchAuthority: PublicKey = this.provider.publicKey, - isDevnet: boolean = false, - payer: PublicKey = this.provider.publicKey, - ) { - const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const quoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - - const baseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - const [tokenMetadata] = getMetadataAddr(baseMint); - - return this.launchpad.methods - .initializeLaunch({ - minimumRaiseAmount, - secondsForLaunch, - tokenName, - tokenSymbol, - tokenUri, - monthlySpendingLimitAmount, - monthlySpendingLimitMembers, - }) - .accounts({ - launch, - launchSigner, - quoteVault, - baseVault, - launchAuthority, - quoteMint, - baseMint, - tokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - payer, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(quoteMint, launchSigner, true), - launchSigner, - quoteMint, - ), - ]); - // .signers([tokenMintKp]); - } - - startLaunchIx( - launch: PublicKey, - launchAuthority: PublicKey = this.provider.publicKey, - ) { - return this.launchpad.methods.startLaunch().accounts({ - launch, - launchAuthority, - }); - } - - fundIx( - launch: PublicKey, - amount: BN, - funder: PublicKey = this.provider.publicKey, - quoteMint: PublicKey, - isDevnet: boolean = false, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods.fund(amount).accounts({ - launch, - launchQuoteVault, - fundingRecord, - funder, - funderQuoteAccount, - launchSigner, - }); - } - - completeLaunchIx( - launch: PublicKey, - quoteMint: PublicKey, - baseMint: PublicKey, - isDevnet: boolean = false, - ) { - const USDC = isDevnet ? DEVNET_USDC : MAINNET_USDC; - const _SQUADS_PROGRAM_CONFIG_TREASURY = isDevnet - ? DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY - : SQUADS_PROGRAM_CONFIG_TREASURY; - - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const launchBaseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - - // const daoKp = Keypair.generate(); - const [dao] = getDaoAddr({ - nonce: new BN(0), - daoCreator: launchSigner, - }); - - const [poolState] = getLiquidityPoolAddr(this.launchpad.programId, dao); - - const cpSwapProgramId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - - const [lpMint] = getRaydiumCpmmLpMintAddr(poolState, isDevnet); - - const lpVault = getAssociatedTokenAddressSync(lpMint, launchSigner, true); - - const [poolTokenVault] = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("pool_vault"), - poolState.toBuffer(), - baseMint.toBuffer(), - ], - cpSwapProgramId, - ); - - const [poolUsdcVault] = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("pool_vault"), - poolState.toBuffer(), - USDC.toBuffer(), - ], - cpSwapProgramId, - ); - - const [observationState] = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("observation"), poolState.toBuffer()], - cpSwapProgramId, - ); - - const [autocratEventAuthority] = getEventAuthorityAddr( - this.autocratClient.getProgramId(), - ); - - const [tokenMetadata] = getMetadataAddr(baseMint); - - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ - multisigPda, - index: 0, - }); - - const [spendingLimit] = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - }); - - const treasuryQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - multisigVault, - true, - ); - - return this.launchpad.methods.completeLaunch().accounts({ - launch, - launchSigner, - launchQuoteVault, - launchBaseVault, - dao, - treasuryQuoteAccount, - treasuryLpAccount: getAssociatedTokenAddressSync( - lpMint, - multisigVault, - true, - ), - quoteMint, - baseMint, - tokenMetadata, - lpMint, - lpVault, - poolTokenVault, - poolUsdcVault, - poolState, - observationState, - staticAccounts: { - cpSwapProgram: cpSwapProgramId, - authority: isDevnet ? DEVNET_RAYDIUM_AUTHORITY : RAYDIUM_AUTHORITY, - ammConfig: isDevnet - ? DEVNET_LOW_FEE_RAYDIUM_CONFIG - : LOW_FEE_RAYDIUM_CONFIG, - createPoolFee: isDevnet - ? DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE - : RAYDIUM_CREATE_POOL_FEE_RECEIVE, - autocratProgram: this.autocratClient.getProgramId(), - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - autocratEventAuthority, - squadsProgram: SQUADS_PROGRAM_ID, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury: _SQUADS_PROGRAM_CONFIG_TREASURY, - }, - squadsMultisig: multisigPda, - squadsMultisigVault: multisigVault, - spendingLimit, - }); - // .preInstructions([ - // createAssociatedTokenAccountIdempotentInstruction( - // this.provider.publicKey, - // treasuryQuoteAccount, - // daoTreasury, - // USDC - // ), - // ]); - } - - refundIx( - launch: PublicKey, - funder: PublicKey = this.provider.publicKey, - quoteMint: PublicKey, - isDevnet: boolean = false, - ) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - - return this.launchpad.methods.refund().accounts({ - launch, - launchSigner, - launchQuoteVault, - funder, - funderQuoteAccount, - fundingRecord, - }); - } - - claimIx( - launch: PublicKey, - baseMint: PublicKey, - funder: PublicKey = this.provider.publicKey, - ) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods - .claim() - .accounts({ - launch, - fundingRecord, - launchSigner, - funder, - funderTokenAccount: getAssociatedTokenAddressSync( - baseMint, - funder, - true, - ), - baseMint, - launchBaseVault: getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, funder, true), - funder, - baseMint, - ), - ]); - } -} diff --git a/sdk/src/v0.5/SharedLiquidityManagerClient.ts b/sdk/src/v0.5/SharedLiquidityManagerClient.ts deleted file mode 100644 index d1715dbf9..000000000 --- a/sdk/src/v0.5/SharedLiquidityManagerClient.ts +++ /dev/null @@ -1,863 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - ComputeBudgetProgram, - Keypair, - PublicKey, - SystemProgram, -} from "@solana/web3.js"; -import { - TOKEN_PROGRAM_ID, - TOKEN_2022_PROGRAM_ID, - createAssociatedTokenAccountIdempotentInstruction, -} from "@solana/spl-token"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; -import * as anchor from "@coral-xyz/anchor"; - -import { - SharedLiquidityManager as SharedLiquidityManagerIDLType, - IDL as SharedLiquidityManagerIDL, -} from "./types/shared_liquidity_manager.js"; -// import { -// SharedLiquidityPool, -// SharedLiquidityPoolPosition, -// } from "./types/index.js"; - -import BN from "bn.js"; -import { - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - RAYDIUM_CP_SWAP_PROGRAM_ID, - RAYDIUM_AUTHORITY, - CONDITIONAL_VAULT_PROGRAM_ID, - AMM_PROGRAM_ID, - AUTOCRAT_PROGRAM_ID, - LOW_FEE_RAYDIUM_CONFIG, - RAYDIUM_CREATE_POOL_FEE_RECEIVE, -} from "./constants.js"; -import { - getSharedLiquidityPoolAddr, - getRaydiumCpmmPoolVaultAddr, - getRaydiumCpmmLpMintAddr, - getEventAuthorityAddr, - getDaoTreasuryAddr, - getProposalAddr, - getRaydiumCpmmObservationStateAddr, - getSharedLiquidityPoolSignerAddr, - getSpotPoolAddr, - getDraftProposalAddr, - getStakeRecordAddr, - getSlPoolPositionAddr, -} from "./utils/pda.js"; -import { AutocratClient } from "./AutocratClient.js"; - -export type CreateSharedLiquidityManagerClientParams = { - provider: AnchorProvider; - sharedLiquidityManagerProgramId?: PublicKey; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - ammProgramId?: PublicKey; -}; - -export const RAYDIUM_INIT_POOL_STATIC_ACCOUNTS = { - raydiumAuthority: RAYDIUM_AUTHORITY, - ammConfig: LOW_FEE_RAYDIUM_CONFIG, - cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - createPoolFee: RAYDIUM_CREATE_POOL_FEE_RECEIVE, -}; - -export class SharedLiquidityManagerClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public autocratClient: AutocratClient; - - constructor(params: CreateSharedLiquidityManagerClientParams) { - this.provider = params.provider; - this.program = new Program( - SharedLiquidityManagerIDL, - params.sharedLiquidityManagerProgramId || - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - this.provider, - ); - this.autocratClient = AutocratClient.createClient({ - provider: this.provider, - autocratProgramId: params.autocratProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - ammProgramId: params.ammProgramId, - }); - } - - public static createClient( - params: CreateSharedLiquidityManagerClientParams, - ): SharedLiquidityManagerClient { - return new SharedLiquidityManagerClient(params); - } - - getProgramId(): PublicKey { - return this.program.programId; - } - - // async getSlPool(slPool: PublicKey): Promise { - // return await this.program.account.sharedLiquidityPool.fetch(slPool); - // } - - // async getSlPoolPosition( - // position: PublicKey - // ): Promise { - // return await this.program.account.liquidityPosition.fetch(position); - // } - - // initializeSharedLiquidityPoolIx( - // dao: PublicKey, - // baseMint: PublicKey, - // quoteMint: PublicKey, - // baseAmount: BN, - // quoteAmount: BN, - // proposalStakeRateThresholdBps: number = 100, - // creator: PublicKey = this.provider.wallet.publicKey - // ) { - // let slPool = getSharedLiquidityPoolAddr( - // this.program.programId, - // dao, - // creator, - // proposalStakeRateThresholdBps - // )[0]; - - // const [creatorSlPoolPosition] = getSlPoolPositionAddr( - // this.program.programId, - // slPool, - // creator - // ); - - // let spotPool = getSpotPoolAddr(this.program.programId, slPool, 0)[0]; - - // let [slPoolSigner] = getSharedLiquidityPoolSignerAddr( - // this.program.programId, - // slPool - // ); - - // return this.program.methods - // .initializeSharedLiquidityPool({ - // baseAmount, - // quoteAmount, - // proposalStakeRateThresholdBps, - // }) - // .accounts({ - // slPool, - // baseMint, - // quoteMint, - // dao, - // spotPool, - // spotPoolLpMint: getRaydiumCpmmLpMintAddr(spotPool, false)[0], - // creator, - // creatorSlPoolPosition, - // creatorLpAccount: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(spotPool, false)[0], - // this.provider.wallet.publicKey, - // true - // ), - // creatorBaseTokenAccount: getAssociatedTokenAddressSync( - // baseMint, - // creator, - // true - // ), - // creatorQuoteTokenAccount: getAssociatedTokenAddressSync( - // quoteMint, - // this.provider.wallet.publicKey, - // true - // ), - // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // spotPool, - // baseMint, - // false - // )[0], - // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // spotPool, - // quoteMint, - // false - // )[0], - // slPoolSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(spotPool, false)[0], - // slPoolSigner, - // true - // ), - // slPoolBaseVault: getAssociatedTokenAddressSync( - // baseMint, - // slPoolSigner, - // true - // ), - // slPoolQuoteVault: getAssociatedTokenAddressSync( - // quoteMint, - // slPoolSigner, - // true - // ), - // raydiumInitPoolStatic: RAYDIUM_INIT_POOL_STATIC_ACCOUNTS, - // spotPoolObservationState: getRaydiumCpmmObservationStateAddr( - // spotPool, - // false - // )[0], - // slPoolSigner, - // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - // }) - // .preInstructions([ - // createAssociatedTokenAccountIdempotentInstruction( - // this.provider.wallet.publicKey, - // getAssociatedTokenAddressSync(baseMint, slPoolSigner, true), - // slPoolSigner, - // baseMint - // ), - // createAssociatedTokenAccountIdempotentInstruction( - // this.provider.wallet.publicKey, - // getAssociatedTokenAddressSync(quoteMint, slPoolSigner, true), - // slPoolSigner, - // quoteMint - // ), - // ]); - // } - - // depositSharedLiquidityIx( - // slPool: PublicKey, - // activeSpotPool: PublicKey, - // baseMint: PublicKey, - // quoteMint: PublicKey, - // lpTokenAmount: BN, - // maxBaseTokenAmount: BN, - // maxQuoteTokenAmount: BN, - // user: PublicKey = this.provider.wallet.publicKey - // ) { - // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( - // this.program.programId, - // slPool - // ); - - // const [userSlPoolPosition] = getSlPoolPositionAddr( - // this.program.programId, - // slPool, - // user - // ); - - // return this.program.methods - // .depositSharedLiquidity({ - // lpTokenAmount, - // maxBaseTokenAmount, - // maxQuoteTokenAmount, - // }) - // .accounts({ - // slPool, - // activeSpotPool, - // user, - // userBaseTokenAccount: getAssociatedTokenAddressSync(baseMint, user), - // userQuoteTokenAccount: getAssociatedTokenAddressSync(quoteMint, user), - // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // baseMint, - // false - // )[0], - // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // quoteMint, - // false - // )[0], - // baseMint, - // quoteMint, - // spotPoolLpMint: getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // slPoolSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // slPoolSigner, - // true - // ), - // userLpTokenAccount: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // user, - // true - // ), - // userSlPoolPosition, - // raydiumAuthority: RAYDIUM_AUTHORITY, - // tokenProgram2022: TOKEN_2022_PROGRAM_ID, - // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - // }) - // .preInstructions([ - // ComputeBudgetProgram.setComputeUnitLimit({ - // units: 300_000, - // }), - // ]); - // } - - // withdrawSharedLiquidityIx( - // slPool: PublicKey, - // activeSpotPool: PublicKey, - // baseMint: PublicKey, - // quoteMint: PublicKey, - // lpTokenAmount: BN, - // minimumToken0Amount: BN, - // minimumToken1Amount: BN, - // user: PublicKey = this.provider.wallet.publicKey - // ) { - // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( - // this.program.programId, - // slPool - // ); - - // const [userSlPoolPosition] = PublicKey.findProgramAddressSync( - // [Buffer.from("sl_pool_position"), slPool.toBuffer(), user.toBuffer()], - // this.program.programId - // ); - - // return this.program.methods - // .withdrawSharedLiquidity({ - // lpTokenAmount, - // minimumToken0Amount, - // minimumToken1Amount, - // }) - // .accounts({ - // slPool, - // slPoolSigner, - // activeSpotPool, - // slPoolSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // slPoolSigner, - // true - // ), - // userQuoteTokenAccount: getAssociatedTokenAddressSync(quoteMint, user), - // userBaseTokenAccount: getAssociatedTokenAddressSync(baseMint, user), - // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // baseMint, - // false - // )[0], - // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // quoteMint, - // false - // )[0], - // baseMint, - // quoteMint, - // spotPoolLpMint: getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // userLpTokenAccount: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // user, - // true - // ), - // userSlPoolPosition, - // user, - // feeReceiver: this.provider.wallet.publicKey, - // raydiumAuthority: RAYDIUM_AUTHORITY, - // tokenProgram: TOKEN_PROGRAM_ID, - // tokenProgram2022: TOKEN_2022_PROGRAM_ID, - // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - // memoProgram: MEMO_PROGRAM_ID, - // eventAuthority: getEventAuthorityAddr(this.program.programId)[0], - // program: this.program.programId, - // }); - // } - - // initializeProposalWithLiquidityIx( - // dao: PublicKey, - // baseMint: PublicKey, - // quoteMint: PublicKey, - // nonce: BN, - // draftProposal: PublicKey, - // spotPoolIndex: number = 0, - // proposalStakeRateThresholdBps: number = 100 - // ) { - // const [slPool] = getSharedLiquidityPoolAddr( - // this.program.programId, - // dao, - // this.provider.wallet.publicKey, - // proposalStakeRateThresholdBps - // ); - - // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( - // this.program.programId, - // slPool - // ); - - // const [spotPool] = getSpotPoolAddr( - // this.program.programId, - // slPool, - // spotPoolIndex - // ); - - // const [proposal] = getProposalAddr( - // this.autocratClient.getProgramId(), - // slPoolSigner, - // nonce - // ); - - // const { - // passAmm, - // failAmm, - // question, - // baseVault, - // quoteVault, - // passBaseMint, - // failBaseMint, - // passQuoteMint, - // failQuoteMint, - // passLp: passLpMint, - // failLp: failLpMint, - // } = this.autocratClient.getProposalPdas(proposal, baseMint, quoteMint, dao); - - // const [daoTreasury] = getDaoTreasuryAddr( - // this.autocratClient.getProgramId(), - // dao - // ); - - // return this.program.methods - // .initializeProposalWithLiquidity({ - // nonce, - // }) - // .accounts({ - // sharedLiquidityPool: slPool, - // draftProposal, - // proposalCreator: this.provider.wallet.publicKey, - // proposal, - // baseMint, - // quoteMint, - // slPoolBaseVault: getAssociatedTokenAddressSync( - // baseMint, - // slPoolSigner, - // true - // ), - // slPoolQuoteVault: getAssociatedTokenAddressSync( - // quoteMint, - // slPoolSigner, - // true - // ), - // slPoolSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(spotPool, false)[0], - // slPoolSigner, - // true - // ), - // raydium: { - // spotPool: spotPool, - // spotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // spotPool, - // baseMint, - // false - // )[0], - // spotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // spotPool, - // quoteMint, - // false - // )[0], - // lpMint: getRaydiumCpmmLpMintAddr(spotPool, false)[0], - // raydiumAuthority: RAYDIUM_AUTHORITY, - // tokenProgram: TOKEN_PROGRAM_ID, - // tokenProgram2022: TOKEN_2022_PROGRAM_ID, - // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - // memoProgram: MEMO_PROGRAM_ID, - // }, - // conditionalVault: { - // slPoolSigner, - // question, - // baseVault, - // quoteVault, - // baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - // baseMint, - // baseVault, - // true - // ), - // quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - // quoteMint, - // quoteVault, - // true - // ), - // conditionalVaultProgram: CONDITIONAL_VAULT_PROGRAM_ID, - // passBaseMint, - // failBaseMint, - // passQuoteMint, - // failQuoteMint, - // slPoolPassBaseVault: getAssociatedTokenAddressSync( - // passBaseMint, - // slPoolSigner, - // true - // ), - // slPoolFailBaseVault: getAssociatedTokenAddressSync( - // failBaseMint, - // slPoolSigner, - // true - // ), - // slPoolPassQuoteVault: getAssociatedTokenAddressSync( - // passQuoteMint, - // slPoolSigner, - // true - // ), - // slPoolFailQuoteVault: getAssociatedTokenAddressSync( - // failQuoteMint, - // slPoolSigner, - // true - // ), - // vaultEventAuthority: getEventAuthorityAddr( - // CONDITIONAL_VAULT_PROGRAM_ID - // )[0], - // }, - // amm: { - // passAmm, - // failAmm, - // passLpMint, - // failLpMint, - // slPoolPassLpAccount: getAssociatedTokenAddressSync( - // passLpMint, - // slPoolSigner, - // true - // ), - // slPoolFailLpAccount: getAssociatedTokenAddressSync( - // failLpMint, - // slPoolSigner, - // true - // ), - // passAmmVaultAtaBase: getAssociatedTokenAddressSync( - // passBaseMint, - // passAmm, - // true - // ), - // passAmmVaultAtaQuote: getAssociatedTokenAddressSync( - // passQuoteMint, - // passAmm, - // true - // ), - // failAmmVaultAtaBase: getAssociatedTokenAddressSync( - // failBaseMint, - // failAmm, - // true - // ), - // failAmmVaultAtaQuote: getAssociatedTokenAddressSync( - // failQuoteMint, - // failAmm, - // true - // ), - // proposal, - // proposalPassLpVault: getAssociatedTokenAddressSync( - // passLpMint, - // proposal, - // true - // ), - // proposalFailLpVault: getAssociatedTokenAddressSync( - // failLpMint, - // proposal, - // true - // ), - // ammProgram: AMM_PROGRAM_ID, - // eventAuthority: getEventAuthorityAddr(AMM_PROGRAM_ID)[0], - // slPoolSigner, - // }, - // autocratEventAuthority: getEventAuthorityAddr(AUTOCRAT_PROGRAM_ID)[0], - // dao, - // autocratProgram: AUTOCRAT_PROGRAM_ID, - // systemProgram: SystemProgram.programId, - // }); - // } - - // initializeDraftProposalIx( - // sharedLiquidityPool: PublicKey, - // baseMint: PublicKey, - // instruction: any, - // draftProposalNonce: BN = new BN(Math.floor(Math.random() * 1000000)) - // ) { - // let [draftProposal] = getDraftProposalAddr( - // this.program.programId, - // draftProposalNonce - // ); - - // return this.program.methods - // .initializeDraftProposal({ - // instruction, - // draftProposalNonce, - // }) - // .accounts({ - // draftProposal, - // sharedLiquidityPool, - // baseMint, - // stakedTokenVault: getAssociatedTokenAddressSync( - // baseMint, - // draftProposal, - // true - // ), - // }); - // } - - // stakeToDraftProposalIx( - // draftProposal: PublicKey, - // baseMint: PublicKey, - // amount: BN, - // staker: PublicKey = this.provider.wallet.publicKey - // ) { - // const [stakeRecord] = getStakeRecordAddr( - // this.program.programId, - // draftProposal, - // staker - // ); - - // return this.program.methods - // .stakeToDraftProposal({ - // amount, - // }) - // .accounts({ - // draftProposal, - // staker, - // stakerTokenAccount: getAssociatedTokenAddressSync( - // baseMint, - // staker, - // true - // ), - // stakedTokenVault: getAssociatedTokenAddressSync( - // baseMint, - // draftProposal, - // true - // ), - // stakeRecord, - // }); - // } - - // unstakeFromDraftProposalIx( - // draftProposal: PublicKey, - // baseMint: PublicKey, - // amount: BN, - // staker: PublicKey = this.provider.wallet.publicKey - // ) { - // const [stakeRecord] = getStakeRecordAddr( - // this.program.programId, - // draftProposal, - // staker - // ); - - // return this.program.methods - // .unstakeFromDraftProposal({ - // amount, - // }) - // .accounts({ - // draftProposal, - // staker, - // stakerTokenAccount: getAssociatedTokenAddressSync( - // baseMint, - // staker, - // true - // ), - // stakedTokenVault: getAssociatedTokenAddressSync( - // baseMint, - // draftProposal, - // true - // ), - // stakeRecord, - // }); - // } - - // removeProposalLiquidityIx( - // dao: PublicKey, - // spotPool: PublicKey, - // baseMint: PublicKey, - // quoteMint: PublicKey, - // proposalNonce: BN, - // proposalStakeRateThresholdBps: number = 100, - // spotPoolIndex: number = 0 - // ) { - // const [slPool] = getSharedLiquidityPoolAddr( - // this.program.programId, - // dao, - // this.provider.wallet.publicKey, - // proposalStakeRateThresholdBps - // ); - - // const [slPoolSigner] = getSharedLiquidityPoolSignerAddr( - // this.program.programId, - // slPool - // ); - - // const [proposal] = getProposalAddr( - // this.autocratClient.getProgramId(), - // slPoolSigner, - // proposalNonce - // ); - - // const { - // passAmm, - // failAmm, - // question, - // baseVault, - // quoteVault, - // passBaseMint, - // failBaseMint, - // passQuoteMint, - // failQuoteMint, - // passLp: passLpMint, - // failLp: failLpMint, - // } = this.autocratClient.getProposalPdas(proposal, baseMint, quoteMint, dao); - - // const [daoTreasury] = getDaoTreasuryAddr( - // this.autocratClient.getProgramId(), - // dao - // ); - - // const poolStateKp = Keypair.generate(); - // const poolState = poolStateKp.publicKey; - - // const [observationState] = getRaydiumCpmmObservationStateAddr( - // poolState, - // false - // ); - - // const [activeSpotPool] = getSpotPoolAddr( - // this.program.programId, - // slPool, - // spotPoolIndex - // ); - // const [nextSpotPool] = getSpotPoolAddr( - // this.program.programId, - // slPool, - // spotPoolIndex + 1 - // ); - - // return this.program.methods.removeProposalLiquidity().accounts({ - // slPool, - // proposal, - // baseMint, - // quoteMint, - // slPoolBaseVault: getAssociatedTokenAddressSync( - // baseMint, - // slPoolSigner, - // true - // ), - // slPoolQuoteVault: getAssociatedTokenAddressSync( - // quoteMint, - // slPoolSigner, - // true - // ), - // slPoolSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(activeSpotPool, false)[0], - // slPoolSigner, - // true - // ), - // raydium: { - // activeSpotPool: activeSpotPool, - // activeSpotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // baseMint, - // false - // )[0], - // activeSpotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // activeSpotPool, - // quoteMint, - // false - // )[0], - // nextSpotPoolQuoteVault: getRaydiumCpmmPoolVaultAddr( - // nextSpotPool, - // quoteMint, - // false - // )[0], - // slPoolSigner, - // nextSpotPoolLpMint: getRaydiumCpmmLpMintAddr(nextSpotPool, false)[0], - // nextSpotPoolBaseVault: getRaydiumCpmmPoolVaultAddr( - // nextSpotPool, - // baseMint, - // false - // )[0], - // nextSpotPool, - // nextSpotPoolObservationState: getRaydiumCpmmObservationStateAddr( - // nextSpotPool, - // false - // )[0], - // slPoolNextSpotLpVault: getAssociatedTokenAddressSync( - // getRaydiumCpmmLpMintAddr(nextSpotPool, false)[0], - // slPoolSigner, - // true - // ), - // activeSpotPoolLpMint: getRaydiumCpmmLpMintAddr( - // activeSpotPool, - // false - // )[0], - // tokenProgram2022: TOKEN_2022_PROGRAM_ID, - // cpSwapProgram: RAYDIUM_CP_SWAP_PROGRAM_ID, - // memoProgram: MEMO_PROGRAM_ID, - // baseMint, - // quoteMint, - // slPool, - // }, - // raydiumInitPoolStatic: RAYDIUM_INIT_POOL_STATIC_ACCOUNTS, - // conditionalVault: { - // question, - // baseVault, - // quoteVault, - // baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - // baseMint, - // baseVault, - // true - // ), - // quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - // quoteMint, - // quoteVault, - // true - // ), - // conditionalVaultProgram: CONDITIONAL_VAULT_PROGRAM_ID, - // passBaseMint, - // failBaseMint, - // passQuoteMint, - // failQuoteMint, - // slPoolPassBaseVault: getAssociatedTokenAddressSync( - // passBaseMint, - // slPoolSigner, - // true - // ), - // slPoolFailBaseVault: getAssociatedTokenAddressSync( - // failBaseMint, - // slPoolSigner, - // true - // ), - // slPoolPassQuoteVault: getAssociatedTokenAddressSync( - // passQuoteMint, - // slPoolSigner, - // true - // ), - // slPoolFailQuoteVault: getAssociatedTokenAddressSync( - // failQuoteMint, - // slPoolSigner, - // true - // ), - // vaultEventAuthority: getEventAuthorityAddr( - // CONDITIONAL_VAULT_PROGRAM_ID - // )[0], - // tokenProgram: TOKEN_PROGRAM_ID, - // slPoolSigner, - // }, - // ammm: { - // passAmm, - // failAmm, - // passLpMint, - // failLpMint, - // slPoolPassLpAccount: getAssociatedTokenAddressSync( - // passLpMint, - // slPoolSigner, - // true - // ), - // slPoolFailLpAccount: getAssociatedTokenAddressSync( - // failLpMint, - // slPoolSigner, - // true - // ), - // passAmmVaultAtaBase: getAssociatedTokenAddressSync( - // passBaseMint, - // passAmm, - // true - // ), - // passAmmVaultAtaQuote: getAssociatedTokenAddressSync( - // passQuoteMint, - // passAmm, - // true - // ), - // failAmmVaultAtaBase: getAssociatedTokenAddressSync( - // failBaseMint, - // failAmm, - // true - // ), - // failAmmVaultAtaQuote: getAssociatedTokenAddressSync( - // failQuoteMint, - // failAmm, - // true - // ), - // slPoolSigner, - // ammProgram: AMM_PROGRAM_ID, - // eventAuthority: getEventAuthorityAddr(AMM_PROGRAM_ID)[0], - // }, - // }); - // } -} diff --git a/sdk/src/v0.5/constants.ts b/sdk/src/v0.5/constants.ts deleted file mode 100644 index c7ed18ec2..000000000 --- a/sdk/src/v0.5/constants.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { Keypair, PublicKey } from "@solana/web3.js"; -import * as anchor from "@coral-xyz/anchor"; -import { BN } from "bn.js"; - -export const AUTOCRAT_PROGRAM_ID = new PublicKey( - "auToUr3CQza3D4qreT6Std2MTomfzvrEeCC5qh7ivW5", -); -export const AMM_PROGRAM_ID = new PublicKey( - "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", -); -export const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( - "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", -); -export const LAUNCHPAD_PROGRAM_ID = new PublicKey( - "mooNhciQJi1LqHDmse2JPic2NqG2PXCanbE3ZYzP3qA", -); -export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( - "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", -); - -export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", -); - -export const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", -); - -export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", -); - -export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", -); -export const MAINNET_USDC = new PublicKey( - "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", -); - -export const DEVNET_USDC = new PublicKey( - "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", -); - -export const USDC_DECIMALS = 6; - -export const AUTOCRAT_LUTS: PublicKey[] = []; - -export const RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DEVNET_RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const LOW_FEE_RAYDIUM_CONFIG = new PublicKey( - "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2", -); - -export const DEVNET_LOW_FEE_RAYDIUM_CONFIG = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("amm_config"), - new BN(0).toArrayLike(Buffer, "be", 2), - ], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8", -); - -export const DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2", -); - -export const SQUADS_PROGRAM_CONFIG = new PublicKey( - "BSTq9w3kZwNwpBXJEvTZz2G9ZTNyKBvoSeXMvwb4cNZr", -); - -export const SQUADS_PROGRAM_ID = new PublicKey( - "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", -); - -export const SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "5DH2e3cJmFpyi6mk65EGFediunm4ui6BiKNUNrhWtD1b", -); - -export const DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", -); - -export const PERMISSIONLESS_ACCOUNT = Keypair.fromSecretKey( - Uint8Array.from([ - 249, 158, 188, 171, 243, 143, 1, 48, 87, 243, 209, 153, 144, 106, 23, 88, - 161, 209, 65, 217, 199, 121, 0, 250, 3, 203, 133, 138, 141, 112, 243, 38, - 198, 205, 120, 222, 160, 224, 151, 190, 84, 254, 127, 178, 224, 195, 130, - 243, 145, 73, 20, 91, 9, 69, 222, 184, 23, 1, 2, 196, 202, 206, 153, 192, - ]), -); diff --git a/sdk/src/v0.5/index.ts b/sdk/src/v0.5/index.ts deleted file mode 100644 index 32591eead..000000000 --- a/sdk/src/v0.5/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./types/index.js"; -export * from "./utils/index.js"; -export * from "./constants.js"; -export * from "./AmmClient.js"; -export * from "./AutocratClient.js"; -export * from "./ConditionalVaultClient.js"; -export * from "./LaunchpadClient.js"; -export * from "./SharedLiquidityManagerClient.js"; diff --git a/sdk/src/v0.5/types/autocrat_migrator.ts b/sdk/src/v0.5/types/autocrat_migrator.ts deleted file mode 100644 index 676d2df3d..000000000 --- a/sdk/src/v0.5/types/autocrat_migrator.ts +++ /dev/null @@ -1,237 +0,0 @@ -export type AutocratMigrator = { - version: "0.1.0"; - name: "autocrat_migrator"; - instructions: [ - { - name: "multiTransfer2"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "multiTransfer4"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "from2"; - isMut: true; - isSigner: false; - }, - { - name: "to2"; - isMut: true; - isSigner: false; - }, - { - name: "from3"; - isMut: true; - isSigner: false; - }, - { - name: "to3"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; -}; - -export const IDL: AutocratMigrator = { - version: "0.1.0", - name: "autocrat_migrator", - instructions: [ - { - name: "multiTransfer2", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "multiTransfer4", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "from2", - isMut: true, - isSigner: false, - }, - { - name: "to2", - isMut: true, - isSigner: false, - }, - { - name: "from3", - isMut: true, - isSigner: false, - }, - { - name: "to3", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], -}; diff --git a/sdk/src/v0.5/types/conditional_vault.ts b/sdk/src/v0.5/types/conditional_vault.ts deleted file mode 100644 index 27c245b79..000000000 --- a/sdk/src/v0.5/types/conditional_vault.ts +++ /dev/null @@ -1,1849 +0,0 @@ -export type ConditionalVault = { - version: "0.4.0"; - name: "conditional_vault"; - instructions: [ - { - name: "initializeQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeQuestionArgs"; - }; - }, - ]; - }, - { - name: "resolveQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "oracle"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ResolveQuestionArgs"; - }; - }, - ]; - }, - { - name: "initializeConditionalVault"; - accounts: [ - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "splitTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "mergeTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "redeemTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "addMetadataToConditionalTokens"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMetadataToConditionalTokensArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "conditionalVault"; - type: { - kind: "struct"; - fields: [ - { - name: "question"; - type: "publicKey"; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - }, - { - name: "underlyingTokenAccount"; - type: "publicKey"; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "decimals"; - type: "u8"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "question"; - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - { - name: "payoutDenominator"; - type: "u32"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "AddMetadataToConditionalTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "name"; - type: "string"; - }, - { - name: "symbol"; - type: "string"; - }, - { - name: "uri"; - type: "string"; - }, - ]; - }; - }, - { - name: "InitializeQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "numOutcomes"; - type: "u8"; - }, - ]; - }; - }, - { - name: "ResolveQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - ]; - }; - }, - { - name: "VaultStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Active"; - }, - { - name: "Finalized"; - }, - { - name: "Reverted"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "AddMetadataToConditionalTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMetadata"; - type: "publicKey"; - index: false; - }, - { - name: "name"; - type: "string"; - index: false; - }, - { - name: "symbol"; - type: "string"; - index: false; - }, - { - name: "uri"; - type: "string"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeConditionalVaultEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - index: false; - }, - { - name: "oracle"; - type: "publicKey"; - index: false; - }, - { - name: "numOutcomes"; - type: "u8"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MergeTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RedeemTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "ResolveQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - index: false; - }, - ]; - }, - { - name: "SplitTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "InsufficientUnderlyingTokens"; - msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; - }, - { - code: 6002; - name: "InsufficientConditionalTokens"; - msg: "Insufficient conditional token balance to merge this `amount`"; - }, - { - code: 6003; - name: "InvalidVaultUnderlyingTokenAccount"; - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; - }, - { - code: 6004; - name: "InvalidConditionalTokenMint"; - msg: "This conditional token mint is not this vault's conditional token mint"; - }, - { - code: 6005; - name: "CantRedeemConditionalTokens"; - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens"; - }, - { - code: 6006; - name: "InsufficientNumConditions"; - msg: "Questions need 2 or more conditions"; - }, - { - code: 6007; - name: "InvalidNumPayoutNumerators"; - msg: "Invalid number of payout numerators"; - }, - { - code: 6008; - name: "InvalidConditionals"; - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens"; - }, - { - code: 6009; - name: "ConditionalMintMismatch"; - msg: "Conditional mint not in vault"; - }, - { - code: 6010; - name: "BadConditionalMint"; - msg: "Unable to deserialize a conditional token mint"; - }, - { - code: 6011; - name: "BadConditionalTokenAccount"; - msg: "Unable to deserialize a conditional token account"; - }, - { - code: 6012; - name: "ConditionalTokenMintMismatch"; - msg: "User conditional token account mint does not match conditional mint"; - }, - { - code: 6013; - name: "PayoutZero"; - msg: "Payouts must sum to 1 or more"; - }, - { - code: 6014; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - { - code: 6015; - name: "ConditionalTokenMetadataAlreadySet"; - msg: "Conditional token metadata already set"; - }, - { - code: 6016; - name: "UnauthorizedConditionalTokenAccount"; - msg: "Conditional token account is not owned by the authority"; - }, - ]; -}; - -export const IDL: ConditionalVault = { - version: "0.4.0", - name: "conditional_vault", - instructions: [ - { - name: "initializeQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeQuestionArgs", - }, - }, - ], - }, - { - name: "resolveQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "oracle", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ResolveQuestionArgs", - }, - }, - ], - }, - { - name: "initializeConditionalVault", - accounts: [ - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "splitTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "mergeTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "redeemTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "addMetadataToConditionalTokens", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMetadataToConditionalTokensArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "conditionalVault", - type: { - kind: "struct", - fields: [ - { - name: "question", - type: "publicKey", - }, - { - name: "underlyingTokenMint", - type: "publicKey", - }, - { - name: "underlyingTokenAccount", - type: "publicKey", - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "decimals", - type: "u8", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "question", - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ], - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - { - name: "payoutDenominator", - type: "u32", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "AddMetadataToConditionalTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "name", - type: "string", - }, - { - name: "symbol", - type: "string", - }, - { - name: "uri", - type: "string", - }, - ], - }, - }, - { - name: "InitializeQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "numOutcomes", - type: "u8", - }, - ], - }, - }, - { - name: "ResolveQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - ], - }, - }, - { - name: "VaultStatus", - type: { - kind: "enum", - variants: [ - { - name: "Active", - }, - { - name: "Finalized", - }, - { - name: "Reverted", - }, - ], - }, - }, - ], - events: [ - { - name: "AddMetadataToConditionalTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMint", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMetadata", - type: "publicKey", - index: false, - }, - { - name: "name", - type: "string", - index: false, - }, - { - name: "symbol", - type: "string", - index: false, - }, - { - name: "uri", - type: "string", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeConditionalVaultEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "underlyingTokenMint", - type: "publicKey", - index: false, - }, - { - name: "vaultUnderlyingTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "questionId", - type: { - array: ["u8", 32], - }, - index: false, - }, - { - name: "oracle", - type: "publicKey", - index: false, - }, - { - name: "numOutcomes", - type: "u8", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MergeTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "RedeemTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "ResolveQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - index: false, - }, - ], - }, - { - name: "SplitTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "InsufficientUnderlyingTokens", - msg: "Insufficient underlying token balance to mint this amount of conditional tokens", - }, - { - code: 6002, - name: "InsufficientConditionalTokens", - msg: "Insufficient conditional token balance to merge this `amount`", - }, - { - code: 6003, - name: "InvalidVaultUnderlyingTokenAccount", - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", - }, - { - code: 6004, - name: "InvalidConditionalTokenMint", - msg: "This conditional token mint is not this vault's conditional token mint", - }, - { - code: 6005, - name: "CantRedeemConditionalTokens", - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens", - }, - { - code: 6006, - name: "InsufficientNumConditions", - msg: "Questions need 2 or more conditions", - }, - { - code: 6007, - name: "InvalidNumPayoutNumerators", - msg: "Invalid number of payout numerators", - }, - { - code: 6008, - name: "InvalidConditionals", - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens", - }, - { - code: 6009, - name: "ConditionalMintMismatch", - msg: "Conditional mint not in vault", - }, - { - code: 6010, - name: "BadConditionalMint", - msg: "Unable to deserialize a conditional token mint", - }, - { - code: 6011, - name: "BadConditionalTokenAccount", - msg: "Unable to deserialize a conditional token account", - }, - { - code: 6012, - name: "ConditionalTokenMintMismatch", - msg: "User conditional token account mint does not match conditional mint", - }, - { - code: 6013, - name: "PayoutZero", - msg: "Payouts must sum to 1 or more", - }, - { - code: 6014, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - { - code: 6015, - name: "ConditionalTokenMetadataAlreadySet", - msg: "Conditional token metadata already set", - }, - { - code: 6016, - name: "UnauthorizedConditionalTokenAccount", - msg: "Conditional token account is not owned by the authority", - }, - ], -}; diff --git a/sdk/src/v0.5/types/futarchy_amm.ts b/sdk/src/v0.5/types/futarchy_amm.ts deleted file mode 100644 index c1aef0d19..000000000 --- a/sdk/src/v0.5/types/futarchy_amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type FutarchyAmm = { - version: "0.4.1"; - name: "futarchy_amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: FutarchyAmm = { - version: "0.4.1", - name: "futarchy_amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk/src/v0.5/types/index.ts b/sdk/src/v0.5/types/index.ts deleted file mode 100644 index 279f482f5..000000000 --- a/sdk/src/v0.5/types/index.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Autocrat as AutocratProgram, IDL as AutocratIDL } from "./autocrat.js"; -export { AutocratProgram, AutocratIDL }; - -import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; -export { AmmProgram, AmmIDL }; - -import { - Launchpad as LaunchpadProgram, - IDL as LaunchpadIDL, -} from "./launchpad.js"; -export { LaunchpadProgram, LaunchpadIDL }; - -import { - ConditionalVault as ConditionalVaultProgram, - IDL as ConditionalVaultIDL, -} from "./conditional_vault.js"; -export { ConditionalVaultProgram, ConditionalVaultIDL }; - -import { - SharedLiquidityManager as SharedLiquidityManagerProgram, - IDL as SharedLiquidityManagerIDL, -} from "./shared_liquidity_manager.js"; -export { SharedLiquidityManagerProgram, SharedLiquidityManagerIDL }; - -export { LowercaseKeys } from "./utils.js"; - -import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; -import { PublicKey } from "@solana/web3.js"; - -export type Question = IdlAccounts["question"]; -export type ConditionalVault = - IdlAccounts["conditionalVault"]; - -export type InitializeDaoParams = - IdlTypes["InitializeDaoParams"]; -export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; - -export type Dao = IdlAccounts["dao"]; -export type Proposal = IdlAccounts["proposal"]; -export type Amm = IdlAccounts["amm"]; -export type Launch = IdlAccounts["launch"]; -export type FundingRecord = IdlAccounts["fundingRecord"]; -// export type SharedLiquidityPool = -// IdlAccounts["sharedLiquidityPool"]; -// export type SharedLiquidityPoolPosition = -// IdlAccounts["liquidityPosition"]; - -export type SwapEvent = IdlEvents["SwapEvent"]; -export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; -export type RemoveLiquidityEvent = - IdlEvents["RemoveLiquidityEvent"]; -export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; -export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; -export type AmmEvent = - | SwapEvent - | AddLiquidityEvent - | RemoveLiquidityEvent - | CreateAmmEvent - | CrankThatTwapEvent; - -export type AddMetadataToConditionalTokensEvent = - IdlEvents["AddMetadataToConditionalTokensEvent"]; -export type InitializeConditionalVaultEvent = - IdlEvents["InitializeConditionalVaultEvent"]; -export type InitializeQuestionEvent = - IdlEvents["InitializeQuestionEvent"]; -export type MergeTokensEvent = - IdlEvents["MergeTokensEvent"]; -export type RedeemTokensEvent = - IdlEvents["RedeemTokensEvent"]; -export type ResolveQuestionEvent = - IdlEvents["ResolveQuestionEvent"]; -export type SplitTokensEvent = - IdlEvents["SplitTokensEvent"]; -export type ConditionalVaultEvent = - | AddMetadataToConditionalTokensEvent - | InitializeConditionalVaultEvent - | InitializeQuestionEvent - | MergeTokensEvent - | RedeemTokensEvent - | ResolveQuestionEvent - | SplitTokensEvent; - -export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; -export type LaunchCompletedEvent = - IdlEvents["LaunchCompletedEvent"]; -export type LaunchFundedEvent = - IdlEvents["LaunchFundedEvent"]; -export type LaunchInitializedEvent = - IdlEvents["LaunchInitializedEvent"]; -export type LaunchRefundedEvent = - IdlEvents["LaunchRefundedEvent"]; -export type LaunchStartedEvent = - IdlEvents["LaunchStartedEvent"]; -export type LaunchpadEvent = - | LaunchClaimEvent - | LaunchCompletedEvent - | LaunchFundedEvent - | LaunchInitializedEvent - | LaunchRefundedEvent - | LaunchStartedEvent; - -export type InitializeDaoEvent = - IdlEvents["InitializeDaoEvent"]; -export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; -export type InitializeProposalEvent = - IdlEvents["InitializeProposalEvent"]; -export type FinalizeProposalEvent = - IdlEvents["FinalizeProposalEvent"]; -export type ExecuteProposalEvent = - IdlEvents["ExecuteProposalEvent"]; -export type AutocratEvent = - | InitializeDaoEvent - | UpdateDaoEvent - | InitializeProposalEvent - | FinalizeProposalEvent - | ExecuteProposalEvent; diff --git a/sdk/src/v0.5/types/optimistic_timelock.ts b/sdk/src/v0.5/types/optimistic_timelock.ts deleted file mode 100644 index fa1f43135..000000000 --- a/sdk/src/v0.5/types/optimistic_timelock.ts +++ /dev/null @@ -1,1023 +0,0 @@ -export type OptimisticTimelock = { - version: "0.3.0"; - name: "optimistic_timelock"; - instructions: [ - { - name: "createTimelock"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: true; - isSigner: true; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "enqueuers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "enqueuerCooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setDelayInSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "delayInSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setAuthority"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - ]; - }, - { - name: "setOptimisticProposerCooldownSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "cooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "addOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "enqueuer"; - type: "publicKey"; - }, - ]; - }, - { - name: "removeOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "optimisticProposer"; - type: "publicKey"; - }, - ]; - }, - { - name: "createTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "addTransaction"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }, - { - name: "sealTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "enqueueTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeTransactionBatch"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "timelock"; - type: { - kind: "struct"; - fields: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "signerBump"; - type: "u8"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "optimisticProposers"; - type: { - vec: { - defined: "OptimisticProposer"; - }; - }; - }, - { - name: "optimisticProposerCooldownSlots"; - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "transactionBatch"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "TransactionBatchStatus"; - }; - }, - { - name: "transactions"; - type: { - vec: { - defined: "Transaction"; - }; - }; - }, - { - name: "timelock"; - type: "publicKey"; - }, - { - name: "enqueuedSlot"; - type: "u64"; - }, - { - name: "transactionBatchAuthority"; - type: "publicKey"; - }, - { - name: "enqueuerType"; - type: { - defined: "AuthorityType"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "OptimisticProposer"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "lastSlotEnqueued"; - type: "u64"; - }, - ]; - }; - }, - { - name: "Transaction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - { - name: "didExecute"; - type: "bool"; - }, - ]; - }; - }, - { - name: "TransactionAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "AuthorityType"; - type: { - kind: "enum"; - variants: [ - { - name: "OptimisticProposer"; - }, - { - name: "TimelockAuthority"; - }, - ]; - }; - }, - { - name: "TransactionBatchStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Created"; - }, - { - name: "Sealed"; - }, - { - name: "Enqueued"; - }, - { - name: "Cancelled"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NotReady"; - msg: "This transaction is not yet ready to be executed"; - }, - { - code: 6001; - name: "CannotAddTransactions"; - msg: "Can only add instructions when transaction batch status is `Created`"; - }, - { - code: 6002; - name: "CannotSealTransactionBatch"; - msg: "Can only seal the transaction batch when status is `Created`"; - }, - { - code: 6003; - name: "CannotEnqueueTransactionBatch"; - msg: "Can only enqueue the timelock running once the status is `Sealed`"; - }, - { - code: 6004; - name: "CannotCancelTimelock"; - msg: "Can only cancel the transactions if the status `Enqueued`"; - }, - { - code: 6005; - name: "CanOnlyCancelDuringTimelockPeriod"; - msg: "Can only cancel the transactions during the timelock period"; - }, - { - code: 6006; - name: "CannotExecuteTransactions"; - msg: "Can only execute the transactions if the status is `Enqueued`"; - }, - { - code: 6007; - name: "NoAuthority"; - msg: "The signer is neither the timelock authority nor an optimistic proposer"; - }, - { - code: 6008; - name: "InsufficientPermissions"; - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority"; - }, - { - code: 6009; - name: "OptimisticProposerCooldown"; - msg: "This optimistic proposer is still in its cooldown period"; - }, - ]; -}; - -export const IDL: OptimisticTimelock = { - version: "0.3.0", - name: "optimistic_timelock", - instructions: [ - { - name: "createTimelock", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: true, - isSigner: true, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "enqueuers", - type: { - vec: "publicKey", - }, - }, - { - name: "enqueuerCooldownSlots", - type: "u64", - }, - ], - }, - { - name: "setDelayInSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "delayInSlots", - type: "u64", - }, - ], - }, - { - name: "setAuthority", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - ], - }, - { - name: "setOptimisticProposerCooldownSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "cooldownSlots", - type: "u64", - }, - ], - }, - { - name: "addOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "enqueuer", - type: "publicKey", - }, - ], - }, - { - name: "removeOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "optimisticProposer", - type: "publicKey", - }, - ], - }, - { - name: "createTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: true, - }, - ], - args: [], - }, - { - name: "addTransaction", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - { - name: "sealTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "enqueueTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeTransactionBatch", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "timelock", - type: { - kind: "struct", - fields: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "signerBump", - type: "u8", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "optimisticProposers", - type: { - vec: { - defined: "OptimisticProposer", - }, - }, - }, - { - name: "optimisticProposerCooldownSlots", - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "transactionBatch", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "TransactionBatchStatus", - }, - }, - { - name: "transactions", - type: { - vec: { - defined: "Transaction", - }, - }, - }, - { - name: "timelock", - type: "publicKey", - }, - { - name: "enqueuedSlot", - type: "u64", - }, - { - name: "transactionBatchAuthority", - type: "publicKey", - }, - { - name: "enqueuerType", - type: { - defined: "AuthorityType", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "OptimisticProposer", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "lastSlotEnqueued", - type: "u64", - }, - ], - }, - }, - { - name: "Transaction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - { - name: "didExecute", - type: "bool", - }, - ], - }, - }, - { - name: "TransactionAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "AuthorityType", - type: { - kind: "enum", - variants: [ - { - name: "OptimisticProposer", - }, - { - name: "TimelockAuthority", - }, - ], - }, - }, - { - name: "TransactionBatchStatus", - type: { - kind: "enum", - variants: [ - { - name: "Created", - }, - { - name: "Sealed", - }, - { - name: "Enqueued", - }, - { - name: "Cancelled", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NotReady", - msg: "This transaction is not yet ready to be executed", - }, - { - code: 6001, - name: "CannotAddTransactions", - msg: "Can only add instructions when transaction batch status is `Created`", - }, - { - code: 6002, - name: "CannotSealTransactionBatch", - msg: "Can only seal the transaction batch when status is `Created`", - }, - { - code: 6003, - name: "CannotEnqueueTransactionBatch", - msg: "Can only enqueue the timelock running once the status is `Sealed`", - }, - { - code: 6004, - name: "CannotCancelTimelock", - msg: "Can only cancel the transactions if the status `Enqueued`", - }, - { - code: 6005, - name: "CanOnlyCancelDuringTimelockPeriod", - msg: "Can only cancel the transactions during the timelock period", - }, - { - code: 6006, - name: "CannotExecuteTransactions", - msg: "Can only execute the transactions if the status is `Enqueued`", - }, - { - code: 6007, - name: "NoAuthority", - msg: "The signer is neither the timelock authority nor an optimistic proposer", - }, - { - code: 6008, - name: "InsufficientPermissions", - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority", - }, - { - code: 6009, - name: "OptimisticProposerCooldown", - msg: "This optimistic proposer is still in its cooldown period", - }, - ], -}; diff --git a/sdk/src/v0.5/types/utils.ts b/sdk/src/v0.5/types/utils.ts deleted file mode 100644 index c878debe7..000000000 --- a/sdk/src/v0.5/types/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; -}; diff --git a/sdk/src/v0.5/utils/cu.ts b/sdk/src/v0.5/utils/cu.ts deleted file mode 100644 index b55cbac95..000000000 --- a/sdk/src/v0.5/utils/cu.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const MaxCUs = { - initializeDao: 40_000, - createIdempotent: 25_000, - initializeConditionalVault: 45_000, - mintConditionalTokens: 35_000, - initializeAmm: 120_000, - addLiquidity: 120_000, - initializeProposal: 60_000, -}; - -export const DEFAULT_CU_PRICE = 1; diff --git a/sdk/src/v0.5/utils/filters.ts b/sdk/src/v0.5/utils/filters.ts deleted file mode 100644 index aee93f618..000000000 --- a/sdk/src/v0.5/utils/filters.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GetProgramAccountsFilter, PublicKey } from "@solana/web3.js"; - -export const filterPositionsByUser = ( - userAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: 8, // discriminator - bytes: userAddr.toBase58(), - }, -}); - -export const filterPositionsByAmm = ( - ammAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: - 8 + // discriminator - 32, // user address - bytes: ammAddr.toBase58(), - }, -}); diff --git a/sdk/src/v0.5/utils/index.ts b/sdk/src/v0.5/utils/index.ts deleted file mode 100644 index ee7438b0a..000000000 --- a/sdk/src/v0.5/utils/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export * from "./filters.js"; -export * from "./pda.js"; -export * from "./priceMath.js"; -export * from "./metadata.js"; -export * from "./cu.js"; -export * from "./instruction.js"; - -import { AccountMeta, ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; - -export enum PriorityFeeTier { - NORMAL = 35, - HIGH = 3571, - TURBO = 357142, -} - -export const addComputeUnits = (num_units: number = 1_400_000) => - ComputeBudgetProgram.setComputeUnitLimit({ - units: num_units, - }); - -export const addPriorityFee = (pf: number) => - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: pf, - }); - -export const pubkeyToAccountInfo = ( - pubkey: PublicKey, - isWritable: boolean, - isSigner = false, -): AccountMeta => { - return { - pubkey: pubkey, - isSigner: isSigner, - isWritable: isWritable, - }; -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/sdk/src/v0.5/utils/instruction.ts b/sdk/src/v0.5/utils/instruction.ts deleted file mode 100644 index f18e48834..000000000 --- a/sdk/src/v0.5/utils/instruction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { TransactionInstruction } from "@solana/web3.js"; - -export class InstructionUtils { - public static async getInstructions( - ...methodBuilders: any[] - ): Promise { - let instructions: TransactionInstruction[] = []; - - for (const methodBuilder of methodBuilders) { - instructions.push(...(await methodBuilder.transaction()).instructions); - } - - return instructions; - } -} diff --git a/sdk/src/v0.5/utils/metadata.ts b/sdk/src/v0.5/utils/metadata.ts deleted file mode 100644 index ef17bbdb8..000000000 --- a/sdk/src/v0.5/utils/metadata.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BN from "bn.js"; -import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { Connection } from "@solana/web3.js"; -import { bundlrUploader } from "@metaplex-foundation/umi-uploader-bundlr"; -import { UmiPlugin } from "@metaplex-foundation/umi"; - -export const assetImageMap: Record = { - fMETA: "https://arweave.net/tGxvOjMZw7B0qHsdCcIMO57oH5g5OaItOZdXo3BXKz8", - fUSDC: "https://arweave.net/DpvxeAyVbaoivhIVCLjdf566k2SwVn0YVBL0sTOezWk", - pMETA: "https://arweave.net/iuqi7PRRESdDxj1oRyk2WzR90_zdFcmZsuWicv3XGfs", - pUSDC: "https://arweave.net/e4IO7F59F_RKCiuB--_ABPot7Qh1yFsGkWzVhcXuKDU", -}; - -// Upload some JSON, returning its URL -export const uploadConditionalTokenMetadataJson = async ( - connection: Connection, - identityPlugin: UmiPlugin, - proposalNumber: number, - symbol: string, - // proposal: BN, - // conditionalToken: string, - // image: string -): Promise => { - // use bundlr, targeting arweave - const umi = createUmi(connection); - umi.use(bundlrUploader()); - umi.use(identityPlugin); - - return umi.uploader.uploadJson({ - name: `Proposal ${proposalNumber}: ${symbol}`, - image: assetImageMap[symbol], - symbol, - description: "A conditional token for use in futarchy.", - }); -}; diff --git a/sdk/src/v0.5/utils/pda.ts b/sdk/src/v0.5/utils/pda.ts deleted file mode 100644 index ba9fe7284..000000000 --- a/sdk/src/v0.5/utils/pda.ts +++ /dev/null @@ -1,327 +0,0 @@ -import { AccountMeta, PublicKey } from "@solana/web3.js"; -import { utils } from "@coral-xyz/anchor"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - fromWeb3JsPublicKey, - toWeb3JsPublicKey, -} from "@metaplex-foundation/umi-web3js-adapters"; -import { - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, - RAYDIUM_CP_SWAP_PROGRAM_ID, - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, -} from "../constants.js"; -import { LAUNCHPAD_PROGRAM_ID, AUTOCRAT_PROGRAM_ID } from "../constants.js"; - -export const getEventAuthorityAddr = (programId: PublicKey) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("__event_authority")], - programId, - ); -}; - -export const getQuestionAddr = ( - programId: PublicKey, - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, -) => { - if (questionId.length != 32) { - throw new Error("questionId must be 32 bytes"); - } - - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("question"), - Buffer.from(questionId), - oracle.toBuffer(), - new BN(numOutcomes).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getVaultAddr = ( - programId: PublicKey, - question: PublicKey, - underlyingTokenMint: PublicKey, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_vault"), - question.toBuffer(), - underlyingTokenMint.toBuffer(), - ], - programId, - ); -}; - -export const getConditionalTokenMintAddr = ( - programId: PublicKey, - vault: PublicKey, - index: number, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_token"), - vault.toBuffer(), - new BN(index).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getDownAndUpMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { down: PublicKey; up: PublicKey } => { - return { - down: getConditionalTokenMintAddr(programId, vault, 0)[0], - up: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getFailAndPassMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { fail: PublicKey; pass: PublicKey } => { - return { - fail: getConditionalTokenMintAddr(programId, vault, 0)[0], - pass: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getMetadataAddr = (mint: PublicKey) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("metadata"), - MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - MPL_TOKEN_METADATA_PROGRAM_ID, - ); -}; - -export const getDaoAddr = ({ - nonce, - daoCreator, - programId = AUTOCRAT_PROGRAM_ID, -}: { - nonce: BN; - daoCreator: PublicKey; - programId?: PublicKey; -}): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("dao"), - daoCreator.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -export const getDaoTreasuryAddr = ( - programId: PublicKey, - dao: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync([dao.toBuffer()], programId); -}; - -export const getProposalAddr = ( - programId: PublicKey, - squadsProposal: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("proposal"), squadsProposal.toBuffer()], - programId, - ); -}; - -export const getAmmAddr = ( - programId: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("amm__"), - baseMint.toBuffer(), - quoteMint.toBuffer(), - ], - programId, - ); -}; - -export const getAmmLpMintAddr = ( - programId: PublicKey, - amm: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("amm_lp_mint"), amm.toBuffer()], - programId, - ); -}; - -export function getLaunchAddr( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - tokenMint: PublicKey, -): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch"), tokenMint.toBuffer()], - programId, - ); -} - -export const getLaunchSignerAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_signer"), launch.toBuffer()], - programId, - ); -}; - -export const getFundingRecordAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, - funder: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], - programId, - ); -}; - -export const getLiquidityPoolAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - dao: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("pool_state"), dao.toBuffer()], - programId, - ); -}; - -export const getSharedLiquidityPoolAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - dao: PublicKey, - creator: PublicKey, - proposalStakeRateThresholdBps: number, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("sl_pool"), - dao.toBuffer(), - creator.toBuffer(), - new BN(proposalStakeRateThresholdBps).toArrayLike(Buffer, "le", 2), - ], - programId, - ); -}; - -export const getSlPoolPositionAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - slPool: PublicKey, - user: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("sl_pool_position"), slPool.toBuffer(), user.toBuffer()], - programId, - ); -}; - -export const getRaydiumCpmmLpMintAddr = ( - poolState: PublicKey, - isDevnet: boolean, -): [PublicKey, number] => { - const programId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - return PublicKey.findProgramAddressSync( - [Buffer.from("pool_lp_mint"), poolState.toBuffer()], - programId, - ); -}; - -export const getRaydiumCpmmPoolVaultAddr = ( - poolState: PublicKey, - token: PublicKey, - isDevnet: boolean, -): [PublicKey, number] => { - const programId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("pool_vault"), - poolState.toBuffer(), - token.toBuffer(), - ], - programId, - ); -}; - -export const getRaydiumCpmmObservationStateAddr = ( - poolState: PublicKey, - isDevnet: boolean, -): [PublicKey, number] => { - const programId = isDevnet - ? DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID - : RAYDIUM_CP_SWAP_PROGRAM_ID; - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("observation"), poolState.toBuffer()], - programId, - ); -}; - -export const getSharedLiquidityPoolSignerAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - slPool: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("sl_pool_signer"), slPool.toBuffer()], - programId, - ); -}; - -export const getSpotPoolAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - slPool: PublicKey, - index: number, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("spot_pool"), - slPool.toBuffer(), - new BN(index).toArrayLike(Buffer, "le", 4), - ], - programId, - ); -}; - -export const getDraftProposalAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - nonce: BN, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("draft_proposal"), nonce.toArrayLike(Buffer, "le", 8)], - programId, - ); -}; - -export const getStakeRecordAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - draftProposal: PublicKey, - staker: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("stake_record"), draftProposal.toBuffer(), staker.toBuffer()], - programId, - ); -}; diff --git a/sdk/src/v0.5/utils/priceMath.ts b/sdk/src/v0.5/utils/priceMath.ts deleted file mode 100644 index ee8615205..000000000 --- a/sdk/src/v0.5/utils/priceMath.ts +++ /dev/null @@ -1,198 +0,0 @@ -import BN from "bn.js"; -import { Amm } from "../types/index.js"; -import { SwapType } from "../AmmClient.js"; -import { AmmMath as V3AmmMath } from "../../v0.3/utils/ammMath.js"; - -const BN_TEN = new BN(10); -const PRICE_SCALE = BN_TEN.pow(new BN(12)); -const PRICE_SCALE_NUMBER = 1e12; - -export type AddLiquiditySimulation = { - baseAmount: BN; - quoteAmount: BN; - expectedLpTokens: BN; - minLpTokens?: BN; - maxBaseAmount?: BN; -}; - -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - -export type RemoveLiquiditySimulation = { - expectedBaseOut: BN; - expectedQuoteOut: BN; - minBaseOut?: BN; - minQuoteOut?: BN; -}; - -export class AmmMath { - // Re-export common methods from v0.3 - public static getHumanPriceFromReserves = V3AmmMath.getHumanPriceFromReserves; - public static getAmmPriceFromReserves = V3AmmMath.getAmmPriceFromReserves; - public static getChainAmount = V3AmmMath.getChainAmount; - public static getHumanAmount = V3AmmMath.getHumanAmount; - public static getAmmPrice = V3AmmMath.getAmmPrice; - public static getAmmPrices = V3AmmMath.getAmmPrices; - public static scale = V3AmmMath.scale; - public static addSlippage = V3AmmMath.addSlippage; - public static subtractSlippage = V3AmmMath.subtractSlippage; - public static simulateAddLiquidity = V3AmmMath.simulateAddLiquidity; - public static simulateRemoveLiquidity = V3AmmMath.simulateRemoveLiquidity; - - public static getHumanPrice( - ammPrice: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - const decimalScalar = BN_TEN.pow( - new BN(quoteDecimals - baseDecimals).abs(), - ); - const price1e12 = - quoteDecimals > baseDecimals - ? ammPrice.div(decimalScalar) - : ammPrice.mul(decimalScalar); - - // in case the BN is too large to cast to number, we try - try { - return price1e12.toNumber() / 1e12; - } catch (e) { - // BN tried to cast into number larger than 53 bits so we we do division via BN methods first, then cast to number(so it is smaller before the cast) - return price1e12.div(new BN(1e12)).toNumber(); - } - } - - public static getTwap(amm: Amm): BN { - return amm.oracle.aggregator.div( - amm.oracle.lastUpdatedSlot.sub(amm.createdAtSlot), - ); - } - - public static simulateSwapInner( - inputAmount: BN, - inputReserves: BN, - outputReserves: BN, - ): BN { - if (inputReserves.eqn(0) || outputReserves.eqn(0)) { - throw new Error("reserves must be non-zero"); - } - - let inputAmountWithFee: BN = inputAmount.muln(990); - - let numerator: BN = inputAmountWithFee.mul(outputReserves); - let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); - - return numerator.div(denominator); - } - - public static simulateSwap( - inputAmount: BN, - swapType: SwapType, - baseReserves: BN, - quoteReserves: BN, - slippageBps?: BN, - ): SwapSimulation { - let inputReserves: BN, outputReserves: BN; - if (swapType.buy) { - inputReserves = quoteReserves; - outputReserves = baseReserves; - } else { - inputReserves = baseReserves; - outputReserves = quoteReserves; - } - - let expectedOut = this.simulateSwapInner( - inputAmount, - inputReserves, - outputReserves, - ); - - let minExpectedOut; - if (slippageBps) { - minExpectedOut = AmmMath.subtractSlippage(expectedOut, slippageBps); - } - - let newBaseReserves: BN, newQuoteReserves: BN; - if (swapType.buy) { - newBaseReserves = baseReserves.sub(expectedOut); - newQuoteReserves = quoteReserves.add(inputAmount); - } else { - newBaseReserves = baseReserves.add(inputAmount); - newQuoteReserves = quoteReserves.sub(expectedOut); - } - - return { - expectedOut, - newBaseReserves, - newQuoteReserves, - minExpectedOut, - }; - } - - /** - * Calculates the optimal swap amount and mergeable tokens without using square roots. - * @param userBalanceIn BN – Tokens that a user wants to dispose of. - * @param ammReserveIn BN – Amount of tokens in the AMM of the token that the user wants to dispose of. - * @param ammReserveOut BN – Amount of tokens in the AMM of the token that the user wants to receive. - * @returns An object containing the optimal swap amount, expected quote received, and expected mergeable tokens. - */ - - public static calculateOptimalSwapForMerge( - userBalanceIn: BN, - ammReserveIn: BN, - ammReserveOut: BN, - slippageBps: BN, - ): { - optimalSwapAmount: BN; - userInAfterSwap: BN; - expectedOut: BN; - minimumExpectedOut: BN; - } { - // essentially, we want to calculate the swap amount so that the remaining user balance = received token amount - - // solve this system of equations for swapAmount, outputAmount (we only care about swap amount tho) - // (baseReserve + swapAmount) * (quoteReserve - outputAmount) = baseReserve * quoteReserve - // baseAmount - swapAmount = outputAmount - - //solve equation - // (baseReserve + .99*swapAmount) * (quoteReserve - (userTokens - swapAmount)) = baseReserve * quoteReserve - // multiplying out the left hand side and subtracting baseReserve * quoteReserve from both sides yields the following: - // baseReserve*quoteReserve - baseReserve*userTokens + baseReserve*swapAmount + .99*swapAmount*quoteReserve - .99*swapAmount*userTokens + .99*swapAmount^2 = baseReserve*quoteReserve - // .99*swapAmount^2 + baseReserve*swapAmount + .99*swapAmount*quoteReserve - baseReserve*userTokens - .99*swapAmount*userTokens = 0 - // in the quadratic equation, a = .99, b = (baseReserve + .99*quoteReserve - .99*userTokens), c = -baseReserve*userTokens - // x = (-b + sqrt(b^2 - 4ac)) / 2a - - let a = 0.99; - let b = - Number(ammReserveIn) + - 0.99 * Number(ammReserveOut) - - 0.99 * Number(userBalanceIn); - let c = -Number(ammReserveIn) * Number(userBalanceIn); - - let x = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a); - //this should mathematically return a positive number assuming userBalanceIn, ammReserveIn, and ammReserveOut are all positive (which they should be) - // -b + Math.sqrt(b ** 2 - 4 * a * c) > 0 because -4*a*c > 0 and sqrt(b**2 + positive number) > b - - const swapAmount = x; - - let expectedOut = this.simulateSwapInner( - new BN(swapAmount), - ammReserveIn, - ammReserveOut, - ); - let minimumExpectedOut = - Number(expectedOut) - (Number(expectedOut) * Number(slippageBps)) / 10000; - return { - optimalSwapAmount: new BN(swapAmount), - userInAfterSwap: new BN(Number(userBalanceIn) - swapAmount), - expectedOut: expectedOut, - minimumExpectedOut: new BN(minimumExpectedOut), - }; - } -} - -// Add backwards compatibility alias -export { AmmMath as PriceMath }; diff --git a/sdk/src/v0.6/ConditionalVaultClient.ts b/sdk/src/v0.6/ConditionalVaultClient.ts deleted file mode 100644 index 047e0a46f..000000000 --- a/sdk/src/v0.6/ConditionalVaultClient.ts +++ /dev/null @@ -1,475 +0,0 @@ -import { AnchorProvider, Program, utils } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, - SystemProgram, -} from "@solana/web3.js"; - -import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; - -import BN from "bn.js"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, -} from "./constants.js"; -import { - getQuestionAddr, - getMetadataAddr, - getVaultAddr, - getConditionalTokenMintAddr, -} from "./utils/index.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { ConditionalVault, Question } from "./types/index.js"; - -export type CreateVaultClientParams = { - provider: AnchorProvider; - conditionalVaultProgramId?: PublicKey; -}; - -export class ConditionalVaultClient { - public readonly provider: AnchorProvider; - public readonly vaultProgram: Program; - - constructor(provider: AnchorProvider, conditionalVaultProgramId: PublicKey) { - this.provider = provider; - this.vaultProgram = new Program( - ConditionalVaultIDL, - conditionalVaultProgramId, - provider, - ); - } - - public static createClient( - createVaultClientParams: CreateVaultClientParams, - ): ConditionalVaultClient { - let { provider, conditionalVaultProgramId } = createVaultClientParams; - - return new ConditionalVaultClient( - provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ); - } - - async fetchQuestion(question: PublicKey): Promise { - return this.vaultProgram.account.question.fetchNullable(question); - } - - async fetchVault(vault: PublicKey): Promise { - return this.vaultProgram.account.conditionalVault.fetchNullable(vault); - } - - async deserializeQuestion( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "question", - accountInfo.data, - ); - } - - async deserializeVault( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "conditionalVault", - accountInfo.data, - ); - } - - initializeQuestionIx( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ) { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - return this.vaultProgram.methods - .initializeQuestion({ - questionId: Array.from(questionId), - oracle, - numOutcomes, - }) - .accounts({ - question, - }); - } - - async initializeQuestion( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ): Promise { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - await this.initializeQuestionIx(questionId, oracle, numOutcomes).rpc(); - - return question; - } - - initializeVaultIx( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - payer: PublicKey = this.provider.publicKey, - ) { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ); - - return this.vaultProgram.methods - .initializeConditionalVault() - .accounts({ - vault, - question, - underlyingTokenMint, - vaultUnderlyingTokenAccount, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - vaultUnderlyingTokenAccount, - vault, - underlyingTokenMint, - ), - ]) - .remainingAccounts( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - } - - // TODO remove `numOucomes` - - async initializeVault( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - ): Promise { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - await this.initializeVaultIx( - question, - underlyingTokenMint, - numOutcomes, - ).rpc(); - - return vault; - } - - resolveQuestionIx( - question: PublicKey, - oracle: Keypair, - payoutNumerators: number[], - ) { - return this.vaultProgram.methods - .resolveQuestion({ - payoutNumerators, - }) - .accounts({ - question, - oracle: oracle.publicKey, - }) - .signers([oracle]); - } - - getConditionalTokenMints(vault: PublicKey, numOutcomes: number): PublicKey[] { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - return conditionalTokenMintAddrs; - } - - getRemainingAccounts( - conditionalTokenMints: PublicKey[], - userConditionalAccounts: PublicKey[], - ) { - return conditionalTokenMints - .concat(userConditionalAccounts) - .map((account) => ({ - pubkey: account, - isWritable: true, - isSigner: false, - })); - } - - // Helper method to get conditional token accounts and instructions - getConditionalTokenAccountsAndInstructions( - vault: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - const userConditionalAccounts = conditionalTokenMintAddrs.map((mint) => - getAssociatedTokenAddressSync(mint, user, true), - ); - - const preInstructions = conditionalTokenMintAddrs.map((mint) => - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(mint, user, true), - user, - mint, - ), - ); - - const remainingAccounts = this.getRemainingAccounts( - conditionalTokenMintAddrs, - userConditionalAccounts, - ); - - return { userConditionalAccounts, preInstructions, remainingAccounts }; - } - - splitTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const { preInstructions, remainingAccounts } = - this.getConditionalTokenAccountsAndInstructions( - vault, - numOutcomes, - user, - payer, - ); - - return this.vaultProgram.methods - .splitTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions(preInstructions) - .remainingAccounts(remainingAccounts); - } - - mergeTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .mergeTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - redeemTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .redeemTokens() - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - addMetadataToConditionalTokensIx( - vault: PublicKey, - index: number, - name: string, - symbol: string, - uri: string, - payer: PublicKey = this.provider.publicKey, - ) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - index, - ); - - const [conditionalTokenMetadata] = getMetadataAddr(conditionalTokenMint); - - return this.vaultProgram.methods - .addMetadataToConditionalTokens({ - name, - symbol, - uri, - }) - .accounts({ - payer, - vault, - conditionalTokenMint, - conditionalTokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.6/FutarchyClient.ts b/sdk/src/v0.6/FutarchyClient.ts deleted file mode 100644 index dce78b1dc..000000000 --- a/sdk/src/v0.6/FutarchyClient.ts +++ /dev/null @@ -1,1130 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AccountMeta, - AddressLookupTableAccount, - ComputeBudgetProgram, - Connection, - Keypair, - PublicKey, - SystemProgram, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { InitializeDaoParams, UpdateDaoParams } from "./types/index.js"; - -// import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; -import { Futarchy, IDL as FutarchyIDL } from "./types/futarchy.js"; -import { - Futarchy as v0_6_0_futarchy, - IDL as v0_6_0_futarchyIDL, -} from "./types/v0.6.0-futarchy.js"; -import { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./types/conditional_vault.js"; - -import BN from "bn.js"; -import { - AMM_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - MAINNET_USDC, - PERMISSIONLESS_ACCOUNT, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - SQUADS_PROGRAM_ID, - USDC_DECIMALS, - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - DAMM_V2_PROGRAM_ID, - DAMM_V2_POOL_AUTHORITY, - MAINNET_METEORA_CONFIG, - LAUNCHPAD_PROGRAM_ID, - METADAO_MULTISIG_VAULT, -} from "./constants.js"; -import { - DEFAULT_CU_PRICE, - InstructionUtils, - MaxCUs, - getConditionalTokenMintAddr, - getDaoAddr, - getEventAuthorityAddr, - getProposalAddr, - getProposalAddrV2, - getQuestionAddr, - getVaultAddr, -} from "./utils/index.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - unpackMint, - TOKEN_PROGRAM_ID, - ASSOCIATED_TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { sha256 } from "@noble/hashes/sha256"; -import { Dao, Proposal } from "./types/index.js"; - -import * as multisig from "@sqds/multisig"; -import { TransactionMessage } from "@solana/web3.js"; -import { getStakeAddr } from "./utils/index.js"; - -export type CreateClientParams = { - provider: AnchorProvider; - futarchyProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; -}; - -export type ProposalVaults = { - baseVault: PublicKey; - quoteVault: PublicKey; -}; - -export class FutarchyClient { - public readonly provider: AnchorProvider; - public readonly futarchy: Program; - // useful for parsing old events - public readonly v0_6_0_futarchy: Program; - public readonly vaultClient: ConditionalVaultClient; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - futarchyProgramId: PublicKey, - conditionalVaultProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.futarchy = new Program( - FutarchyIDL, - futarchyProgramId, - provider, - ); - this.v0_6_0_futarchy = new Program( - v0_6_0_futarchyIDL, - futarchyProgramId, - provider, - ); - this.vaultClient = ConditionalVaultClient.createClient({ - provider, - conditionalVaultProgramId, - }); - this.luts = luts; - } - - public static createClient(params: CreateClientParams): FutarchyClient { - let { - provider, - futarchyProgramId: autocratProgramId, - conditionalVaultProgramId, - } = params; - - const luts: AddressLookupTableAccount[] = []; - - return new FutarchyClient( - provider, - autocratProgramId || FUTARCHY_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - luts, - ); - } - - getProgramId(): PublicKey { - return this.futarchy.programId; - } - - async getProposal(proposal: PublicKey): Promise { - return this.futarchy.account.proposal.fetch(proposal); - } - - async getDao(dao: PublicKey): Promise { - return this.futarchy.account.dao.fetch(dao); - } - - async fetchProposal(proposal: PublicKey): Promise { - return this.futarchy.account.proposal.fetchNullable(proposal); - } - - async fetchDao(dao: PublicKey): Promise { - return this.futarchy.account.dao.fetchNullable(dao); - } - - async deserializeProposal( - accountInfo: AccountInfo, - ): Promise { - return this.futarchy.coder.accounts.decode("proposal", accountInfo.data); - } - - async deserializeDao(accountInfo: AccountInfo): Promise { - return this.futarchy.coder.accounts.decode("dao", accountInfo.data); - } - - getProposalPdas( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - dao: PublicKey, - ): { - question: PublicKey; - baseVault: PublicKey; - quoteVault: PublicKey; - passBaseMint: PublicKey; - passQuoteMint: PublicKey; - failBaseMint: PublicKey; - failQuoteMint: PublicKey; - } { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const [question] = getQuestionAddr( - vaultProgramId, - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - const [baseVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - quoteMint, - ); - - const [failBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 0, - ); - const [failQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 0, - ); - - const [passBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 1, - ); - const [passQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 1, - ); - - return { - question, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - }; - } - - initializeDaoIx({ - baseMint, - params, - provideLiquidity = false, - quoteMint = MAINNET_USDC, - squadsProgramConfigTreasury = SQUADS_PROGRAM_CONFIG_TREASURY, - }: { - baseMint: PublicKey; - params: InitializeDaoParams; - provideLiquidity?: boolean; - quoteMint?: PublicKey; - squadsProgramConfigTreasury?: PublicKey; - }) { - const [dao] = getDaoAddr({ - nonce: params.nonce, - daoCreator: this.provider.publicKey, - }); - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - let daoCreatorBaseAccount = null; - let daoCreatorQuoteAccount = null; - if (provideLiquidity) { - daoCreatorBaseAccount = getAssociatedTokenAddressSync( - baseMint, - this.provider.publicKey, - true, - ); - daoCreatorQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - this.provider.publicKey, - true, - ); - } - - const spendingLimit = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - })[0]; - - return this.futarchy.methods.initializeDao(params).accounts({ - dao, - baseMint, - quoteMint, - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury, - squadsProgram: SQUADS_PROGRAM_ID, - spendingLimit, - futarchyAmmBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - futarchyAmmQuoteVault: getAssociatedTokenAddressSync( - quoteMint, - dao, - true, - ), - }); - } - - launchProposalIx({ - proposal, - dao, - baseMint, - quoteMint, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - }) { - const { - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - return this.futarchy.methods - .launchProposal() - .accounts({ - proposal, - dao, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - payer: this.provider.publicKey, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]); - } - - spotSwapIx({ - dao, - baseMint, - quoteMint = MAINNET_USDC, - swapType, - inputAmount, - minOutputAmount = new BN(0), - trader = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - swapType: "buy" | "sell"; - inputAmount: BN; - minOutputAmount?: BN; - trader?: PublicKey; - }) { - return this.futarchy.methods - .spotSwap({ - swapType: swapType === "buy" ? { buy: {} } : { sell: {} }, - inputAmount, - minOutputAmount, - }) - .accounts({ - dao, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, trader, true), - userQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - trader, - true, - ), - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - user: trader, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, trader, true), - trader, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(quoteMint, trader, true), - trader, - quoteMint, - ), - ]); - } - - provideLiquidityIx({ - dao, - baseMint, - quoteMint, - quoteAmount, - maxBaseAmount, - minLiquidity = new BN(0), - positionAuthority = this.provider.publicKey, - liquidityProvider = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - quoteAmount: BN; - maxBaseAmount: BN; - minLiquidity?: BN; - positionAuthority?: PublicKey; - liquidityProvider?: PublicKey; - }) { - const ammPosition = PublicKey.findProgramAddressSync( - [ - Buffer.from("amm_position"), - dao.toBuffer(), - positionAuthority.toBuffer(), - ], - this.getProgramId(), - )[0]; - - return this.futarchy.methods - .provideLiquidity({ - quoteAmount, - maxBaseAmount, - minLiquidity, - positionAuthority, - }) - .accounts({ - dao, - liquidityProvider, - liquidityProviderBaseAccount: getAssociatedTokenAddressSync( - baseMint, - liquidityProvider, - true, - ), - liquidityProviderQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - liquidityProvider, - true, - ), - payer: this.provider.publicKey, - systemProgram: SystemProgram.programId, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - ammPosition, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, liquidityProvider, true), - liquidityProvider, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(quoteMint, liquidityProvider, true), - liquidityProvider, - quoteMint, - ), - ]); - } - - conditionalSwapIx({ - dao, - trader = this.provider.publicKey, - payer = this.provider.publicKey, - baseMint, - quoteMint = MAINNET_USDC, - proposal, - market, - swapType, - inputAmount, - minOutputAmount, - }: { - dao: PublicKey; - trader?: PublicKey; - payer?: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - proposal: PublicKey; - market: "pass" | "fail"; - swapType: "buy" | "sell"; - inputAmount: BN; - minOutputAmount: BN; - }) { - const { - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - baseVault, - quoteVault, - question, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - let inputMint: PublicKey, outputMint: PublicKey; - - if (market == "pass" && swapType == "buy") { - inputMint = passQuoteMint; - outputMint = passBaseMint; - } else if (market == "pass" && swapType == "sell") { - inputMint = passBaseMint; - outputMint = passQuoteMint; - } else if (market == "fail" && swapType == "buy") { - inputMint = failQuoteMint; - outputMint = failBaseMint; - } else if (market == "fail" && swapType == "sell") { - inputMint = failBaseMint; - outputMint = failQuoteMint; - } else { - throw new Error( - "Either `market` or `swapType` is incorrectly configured", - ); - } - - return this.futarchy.methods - .conditionalSwap({ - market: market == "pass" ? { pass: {} } : { fail: {} }, - swapType: swapType == "buy" ? { buy: {} } : { sell: {} }, - inputAmount, - minOutputAmount, - }) - .accounts({ - dao, - proposal, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - baseVault, - quoteVault, - userInputAccount: getAssociatedTokenAddressSync( - inputMint, - trader, - true, - ), - userOutputAccount: getAssociatedTokenAddressSync( - outputMint, - trader, - true, - ), - baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - baseMint, - baseVault, - true, - ), - quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - quoteMint, - quoteVault, - true, - ), - passBaseMint, - failBaseMint, - passQuoteMint, - failQuoteMint, - conditionalVaultProgram: this.vaultClient.vaultProgram.programId, - vaultEventAuthority: getEventAuthorityAddr( - this.vaultClient.vaultProgram.programId, - )[0], - question, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(outputMint, trader, true), - trader, - outputMint, - ), - ]); - } - - squadsProposalCreateTx({ - dao, - instructions, - transactionIndex, - payer = this.provider.publicKey, - }: { - dao: PublicKey; - instructions: TransactionInstruction[]; - transactionIndex: bigint; - payer?: PublicKey; - }): { tx: Transaction; squadsProposal: PublicKey } { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - const transactionMessage = new TransactionMessage({ - payerKey: payer, - recentBlockhash: "", // this doesn't get used - instructions, - }); - - const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - vaultIndex: 0, - ephemeralSigners: 0, - transactionMessage, - }); - - const proposalCreate = multisig.instructions.proposalCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - }); - - const [squadsProposal] = multisig.getProposalPda({ - multisigPda, - transactionIndex: transactionIndex, - }); - - const tx = new Transaction().add(vaultTxCreate, proposalCreate); - - return { tx, squadsProposal }; - } - - async initializeProposal( - dao: PublicKey, - squadsProposal: PublicKey, - ): Promise { - const storedDao = await this.getDao(dao); - - let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal); - - await this.vaultClient.initializeQuestion( - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - - const { question } = this.getProposalPdas( - proposal, - storedDao.baseMint, - storedDao.quoteMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - await this.vaultClient - .initializeVaultIx(question, storedDao.baseMint, 2) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(question, storedDao.quoteMint, 2), - ), - ) - .rpc(); - - await this.initializeProposalIx( - squadsProposal, - dao, - storedDao.baseMint, - storedDao.quoteMint, - question, - ) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]) - .rpc(); - - return proposal; - } - - initializeProposalIx( - squadsProposal: PublicKey, - dao: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - question: PublicKey, - proposer: PublicKey = this.provider.publicKey, - ) { - let [proposal] = getProposalAddr(this.futarchy.programId, squadsProposal); - const { - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - let [futarchyAmm] = PublicKey.findProgramAddressSync( - [Buffer.from("futarchy_amm")], - this.getProgramId(), - ); - - return this.futarchy.methods - .initializeProposal() - .accounts({ - question, - proposal, - squadsProposal, - dao, - baseVault, - quoteVault, - proposer, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(passBaseMint, futarchyAmm, true), - futarchyAmm, - passBaseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(passQuoteMint, futarchyAmm, true), - futarchyAmm, - passQuoteMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(failBaseMint, futarchyAmm, true), - futarchyAmm, - failBaseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(failQuoteMint, futarchyAmm, true), - futarchyAmm, - failQuoteMint, - ), - ]); - } - - async finalizeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - let storedDao = await this.getDao(storedProposal.dao); - - return this.finalizeProposalIx( - proposal, - storedProposal.squadsProposal, - storedProposal.dao, - storedDao.baseMint, - storedDao.quoteMint, - ).rpc(); - } - - finalizeProposalIxV2({ - squadsProposal, - dao, - baseMint, - quoteMint = MAINNET_USDC, - }: { - squadsProposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - }) { - const [proposal] = getProposalAddrV2({ squadsProposal }); - - return this.finalizeProposalIx( - proposal, - squadsProposal, - dao, - baseMint, - quoteMint, - ); - } - - /** - * @deprecated use `finalizeProposalIxV2` instead - */ - finalizeProposalIx( - proposal: PublicKey, - squadsProposal: PublicKey, - dao: PublicKey, - daoToken: PublicKey, - usdc: PublicKey, - ) { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - const { - question, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - baseVault, - } = this.getProposalPdas(proposal, daoToken, usdc, dao); - - const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); - - return this.futarchy.methods - .finalizeProposal() - .accounts({ - proposal, - dao, - squadsProposal, - squadsMultisig: multisigPda, - squadsMultisigProgram: SQUADS_PROGRAM_ID, - quoteVault, - question, - quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - usdc, - quoteVault, - true, - ), - passQuoteMint, - failQuoteMint, - passBaseMint, - failBaseMint, - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - ammQuoteVault: getAssociatedTokenAddressSync(usdc, dao, true), - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammBaseVault: getAssociatedTokenAddressSync(daoToken, dao, true), - baseVault, - baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - daoToken, - baseVault, - true, - ), - vaultProgram: this.vaultClient.vaultProgram.programId, - vaultEventAuthority, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]); - } - - updateDaoIx({ dao, params }: { dao: PublicKey; params: UpdateDaoParams }) { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - return this.futarchy.methods.updateDao(params).accounts({ - dao, - squadsMultisigVault, - }); - } - - stakeToProposalIx({ - proposal, - dao, - baseMint, - amount, - staker = this.provider.publicKey, - payer = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - amount: BN; - staker?: PublicKey; - payer?: PublicKey; - }) { - const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0]; - - return this.futarchy.methods - .stakeToProposal({ amount }) - .accounts({ - proposal, - dao, - stakerBaseAccount: getAssociatedTokenAddressSync( - baseMint, - staker, - true, - ), - proposalBaseAccount: getAssociatedTokenAddressSync( - baseMint, - proposal, - true, - ), - stakeAccount, - staker, - payer, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(baseMint, staker, true), - staker, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(baseMint, proposal, true), - proposal, - baseMint, - ), - ]); - } - - unstakeFromProposalIx({ - proposal, - dao, - baseMint, - amount, - staker = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - amount: BN; - staker?: PublicKey; - }) { - const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0]; - - return this.futarchy.methods.unstakeFromProposal({ amount }).accounts({ - proposal, - dao, - stakerBaseAccount: getAssociatedTokenAddressSync(baseMint, staker, true), - proposalBaseAccount: getAssociatedTokenAddressSync( - baseMint, - proposal, - true, - ), - stakeAccount, - staker, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - collectFeesIx({ - dao, - baseMint, - quoteMint, - baseTokenAccount = getAssociatedTokenAddressSync( - baseMint, - METADAO_MULTISIG_VAULT, - true, - ), - quoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - METADAO_MULTISIG_VAULT, - true, - ), - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - baseTokenAccount?: PublicKey; - quoteTokenAccount?: PublicKey; - }) { - return this.futarchy.methods.collectFees().accounts({ - dao, - admin: this.provider.publicKey, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - baseTokenAccount, - quoteTokenAccount, - }); - } - - sponsorProposalIx({ - proposal, - dao, - teamAddress = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - teamAddress?: PublicKey; - }) { - return this.futarchy.methods.sponsorProposal().accounts({ - proposal, - dao, - teamAddress, - }); - } - - collectMeteoraDammFeesIx({ - dao, - baseMint, - quoteMint = MAINNET_USDC, - transactionIndex, - meteoraConfig = MAINNET_METEORA_CONFIG, - admin = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - transactionIndex: bigint; - meteoraConfig?: PublicKey; - admin?: PublicKey; - }) { - // Squads accounts - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - const squadsMultisigVaultTransaction = multisig.getTransactionPda({ - multisigPda, - index: transactionIndex, - })[0]; - const squadsMultisigProposal = multisig.getProposalPda({ - multisigPda, - transactionIndex, - })[0]; - - // Token accounts for receiving fees - const baseTokenAccount = getAssociatedTokenAddressSync( - baseMint, - METADAO_MULTISIG_VAULT, - true, - ); - const quoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - METADAO_MULTISIG_VAULT, - true, - ); - - // Helper function to sort mints for Meteora pool PDA - const sortMints = ( - mint1: PublicKey, - mint2: PublicKey, - ): [Buffer, Buffer] => { - const buf1 = mint1.toBuffer(); - const buf2 = mint2.toBuffer(); - if (Buffer.compare(buf1, buf2) > 0) { - return [buf1, buf2]; - } - return [buf2, buf1]; - }; - - const [sortedMint1, sortedMint2] = sortMints(baseMint, quoteMint); - - // Meteora DAMM accounts - const [pool] = PublicKey.findProgramAddressSync( - [Buffer.from("pool"), meteoraConfig.toBuffer(), sortedMint1, sortedMint2], - DAMM_V2_PROGRAM_ID, - ); - - const [positionNftMint] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_mint"), baseMint.toBuffer()], - LAUNCHPAD_PROGRAM_ID, - ); - - const [positionNftAccount] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [position] = PublicKey.findProgramAddressSync( - [Buffer.from("position"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - - return this.futarchy.methods.collectMeteoraDammFees().accounts({ - dao, - admin, - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsMultisigVaultTransaction, - squadsMultisigProposal, - squadsMultisigPermissionlessAccount: PERMISSIONLESS_ACCOUNT.publicKey, - meteoraClaimPositionFeesAccounts: { - dammV2Program: DAMM_V2_PROGRAM_ID, - dammV2EventAuthority, - poolAuthority: DAMM_V2_POOL_AUTHORITY, - pool, - position, - tokenAAccount: baseTokenAccount, - tokenBAccount: quoteTokenAccount, - tokenAVault, - tokenBVault, - tokenAMint: baseMint, - tokenBMint: quoteMint, - positionNftAccount, - owner: squadsMultisigVault, - tokenAProgram: TOKEN_PROGRAM_ID, - tokenBProgram: TOKEN_PROGRAM_ID, - }, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - squadsProgram: SQUADS_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.6/LaunchpadClient.ts b/sdk/src/v0.6/LaunchpadClient.ts deleted file mode 100644 index 77097f3ce..000000000 --- a/sdk/src/v0.6/LaunchpadClient.ts +++ /dev/null @@ -1,589 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Keypair, - AccountInfo, - ComputeBudgetProgram, -} from "@solana/web3.js"; -import { Launchpad, IDL as LaunchpadIDL } from "./types/launchpad.js"; -import { - Launchpad as v0_6_0_launchpad, - IDL as v0_6_0_launchpadIDL, -} from "./types/v0.6.0-launchpad.js"; -import { - LAUNCHPAD_PROGRAM_ID, - RAYDIUM_AUTHORITY, - LOW_FEE_RAYDIUM_CONFIG, - RAYDIUM_CP_SWAP_PROGRAM_ID, - RAYDIUM_CREATE_POOL_FEE_RECEIVE, - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - DEVNET_RAYDIUM_AUTHORITY, - DEVNET_LOW_FEE_RAYDIUM_CONFIG, - DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, - MPL_TOKEN_METADATA_PROGRAM_ID, - MAINNET_USDC, - DEVNET_USDC, - SQUADS_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - DAMM_V2_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, - MAINNET_METEORA_CONFIG, -} from "./constants.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - TOKEN_2022_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { FundingRecord, Launch } from "./types/index.js"; -import { - getDaoAddr, - getEventAuthorityAddr, - getFundingRecordAddr, - getLaunchAddr, - getLaunchSignerAddr, - getMetadataAddr, - getPerformancePackageAddr, -} from "./utils/pda.js"; -import { FutarchyClient } from "./FutarchyClient.js"; -import * as anchor from "@coral-xyz/anchor"; -import * as multisig from "@sqds/multisig"; -import { PriceBasedPerformancePackageClient } from "./PriceBasedPerformancePackageClient.js"; - -export type CreateLaunchpadClientParams = { - provider: AnchorProvider; - launchpadProgramId?: PublicKey; - futarchyProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - priceBasedUnlockProgramId?: PublicKey; -}; - -export class LaunchpadClient { - public launchpad: Program; - public provider: AnchorProvider; - // useful for parsing old events - public v0_6_0_launchpad: Program; - public futarchyClient: FutarchyClient; - public priceBasedUnlock: PriceBasedPerformancePackageClient; - - private constructor(params: CreateLaunchpadClientParams) { - this.provider = params.provider; - this.launchpad = new Program( - LaunchpadIDL, - params.launchpadProgramId || LAUNCHPAD_PROGRAM_ID, - this.provider, - ); - this.v0_6_0_launchpad = new Program( - v0_6_0_launchpadIDL, - params.launchpadProgramId || LAUNCHPAD_PROGRAM_ID, - this.provider, - ); - this.futarchyClient = FutarchyClient.createClient({ - provider: this.provider, - futarchyProgramId: params.futarchyProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - }); - this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ - provider: this.provider, - priceBasedTokenLockProgramId: params.priceBasedUnlockProgramId, - }); - } - - static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { - return new LaunchpadClient(params); - } - - getProgramId(): PublicKey { - return this.launchpad.programId; - } - - async getLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetch(launch); - } - - async fetchLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetchNullable(launch); - } - - async deserializeLaunch(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("launch", accountInfo.data); - } - - async getFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetch(fundingRecord); - } - - async fetchFundingRecord( - fundingRecord: PublicKey, - ): Promise { - return await this.launchpad.account.fundingRecord.fetchNullable( - fundingRecord, - ); - } - - async deserializeFundingRecord( - accountInfo: AccountInfo, - ): Promise { - return this.launchpad.coder.accounts.decode( - "fundingRecord", - accountInfo.data, - ); - } - - initializeLaunchIx({ - tokenName, - tokenSymbol, - tokenUri, - minimumRaiseAmount, - secondsForLaunch = 60 * 60 * 24 * 5, // 5 days - baseMint, - quoteMint = MAINNET_USDC, - monthlySpendingLimitAmount, - monthlySpendingLimitMembers, - performancePackageGrantee, - performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, - teamAddress, - launchAuthority = this.provider.publicKey, - payer = this.provider.publicKey, - }: { - tokenName: string; - tokenSymbol: string; - tokenUri: string; - minimumRaiseAmount: BN; - secondsForLaunch?: number; - baseMint: PublicKey; - quoteMint?: PublicKey; - monthlySpendingLimitAmount: BN; - monthlySpendingLimitMembers: PublicKey[]; - performancePackageGrantee: PublicKey; - performancePackageTokenAmount: BN; - monthsUntilInsidersCanUnlock: number; - teamAddress: PublicKey; - launchAuthority?: PublicKey; - payer?: PublicKey; - }) { - const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const quoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - - const baseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - const [tokenMetadata] = getMetadataAddr(baseMint); - - return this.launchpad.methods - .initializeLaunch({ - minimumRaiseAmount, - secondsForLaunch, - tokenName, - tokenSymbol, - tokenUri, - monthlySpendingLimitAmount, - monthlySpendingLimitMembers, - performancePackageGrantee, - performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, - teamAddress, - }) - .accounts({ - launch, - launchSigner, - quoteVault, - baseVault, - launchAuthority, - quoteMint, - baseMint, - tokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - payer, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(quoteMint, launchSigner, true), - launchSigner, - quoteMint, - ), - ]); - // .signers([tokenMintKp]); - } - - startLaunchIx({ - launch, - launchAuthority = this.provider.publicKey, - }: { - launch: PublicKey; - launchAuthority?: PublicKey; - }) { - return this.launchpad.methods.startLaunch().accounts({ - launch, - launchAuthority, - }); - } - - fundIx({ - launch, - amount, - funder = this.provider.publicKey, - quoteMint = MAINNET_USDC, - }: { - launch: PublicKey; - amount: BN; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods.fund(amount).accounts({ - launch, - launchQuoteVault, - fundingRecord, - funder, - funderQuoteAccount, - }); - } - - closeLaunchIx({ launch }: { launch: PublicKey }) { - return this.launchpad.methods.closeLaunch().accounts({ - launch, - }); - } - - completeLaunchIx({ - launch, - quoteMint = MAINNET_USDC, - baseMint, - finalRaiseAmount, - launchAuthority, - isDevnet = false, - meteoraConfig = MAINNET_METEORA_CONFIG, - }: { - launch: PublicKey; - quoteMint?: PublicKey; - baseMint: PublicKey; - finalRaiseAmount: BN | null; - launchAuthority: PublicKey | null; - isDevnet?: boolean; - meteoraConfig?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const launchBaseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - - // const daoKp = Keypair.generate(); - const [dao] = getDaoAddr({ - nonce: new BN(0), - daoCreator: launchSigner, - }); - - const [autocratEventAuthority] = getEventAuthorityAddr( - this.futarchyClient.getProgramId(), - ); - - const [tokenMetadata] = getMetadataAddr(baseMint); - - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ - multisigPda, - index: 0, - }); - - const [spendingLimit] = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - }); - - const treasuryQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - multisigVault, - true, - ); - - const [ammPosition] = PublicKey.findProgramAddressSync( - [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], - this.futarchyClient.getProgramId(), - ); - - const [performancePackage] = getPerformancePackageAddr({ - createKey: launchSigner, - }); - const performancePackageTokenAccount = getAssociatedTokenAddressSync( - baseMint, - performancePackage, - true, - ); - - const [poolAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("pool_authority")], - DAMM_V2_PROGRAM_ID, - ); - - const [positionNftMint] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_mint"), baseMint.toBuffer()], - LAUNCHPAD_PROGRAM_ID, - ); - - const [positionNftAccount] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - function getFirstKey(key1: PublicKey, key2: PublicKey) { - const buf1 = key1.toBuffer(); - const buf2 = key2.toBuffer(); - // Buf1 > buf2 - if (Buffer.compare(buf1, buf2) === 1) { - return buf1; - } - return buf2; - } - - function getSecondKey(key1: PublicKey, key2: PublicKey) { - const buf1 = key1.toBuffer(); - const buf2 = key2.toBuffer(); - // Buf1 > buf2 - if (Buffer.compare(buf1, buf2) === 1) { - return buf2; - } - return buf1; - } - - const [pool] = PublicKey.findProgramAddressSync( - [ - Buffer.from("pool"), - meteoraConfig.toBuffer(), - getFirstKey(baseMint, quoteMint), - getSecondKey(baseMint, quoteMint), - ], - DAMM_V2_PROGRAM_ID, - ); - - const [position] = PublicKey.findProgramAddressSync( - [Buffer.from("position"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, - ); - - const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - - return this.launchpad.methods - .completeLaunch({ finalRaiseAmount }) - .accounts({ - launch, - launchSigner, - launchQuoteVault, - launchBaseVault, - launchAuthority, - dao, - treasuryQuoteAccount, - quoteMint, - baseMint, - tokenMetadata, - daoOwnedLpPosition: ammPosition, - futarchyAmmQuoteVault: getAssociatedTokenAddressSync( - quoteMint, - dao, - true, - ), - futarchyAmmBaseVault: getAssociatedTokenAddressSync( - baseMint, - dao, - true, - ), - staticAccounts: { - futarchyProgram: this.futarchyClient.getProgramId(), - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - autocratEventAuthority, - squadsProgram: SQUADS_PROGRAM_ID, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury: isDevnet - ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET - : SQUADS_PROGRAM_CONFIG_TREASURY, - priceBasedPerformancePackageProgram: this.priceBasedUnlock.programId, - priceBasedPerformancePackageEventAuthority: - this.priceBasedUnlock.getEventAuthorityAddress(), - }, - squadsMultisig: multisigPda, - squadsMultisigVault: multisigVault, - spendingLimit, - performancePackage, - performancePackageTokenAccount, - meteoraAccounts: { - dammV2Program: DAMM_V2_PROGRAM_ID, - positionNftMint, - baseMint, - quoteMint, - config: meteoraConfig, - token2022Program: TOKEN_2022_PROGRAM_ID, - positionNftAccount, - pool, - // baseMint, - // quoteMint, - poolCreatorAuthority, - position, - tokenAVault, - tokenBVault, - poolAuthority, - dammV2EventAuthority, - }, - // poolCreatorAuthority, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 850_000 }), - ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), - ]); - } - - refundIx({ - launch, - funder = this.provider.publicKey, - quoteMint = MAINNET_USDC, - }: { - launch: PublicKey; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - - return this.launchpad.methods.refund().accounts({ - launch, - launchSigner, - launchQuoteVault, - funder, - funderQuoteAccount, - fundingRecord, - }); - } - - claimIx( - launch: PublicKey, - baseMint: PublicKey, - funder: PublicKey = this.provider.publicKey, - ) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods - .claim() - .accounts({ - launch, - fundingRecord, - launchSigner, - funder, - funderTokenAccount: getAssociatedTokenAddressSync( - baseMint, - funder, - true, - ), - baseMint, - launchBaseVault: getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, funder, true), - funder, - baseMint, - ), - ]); - } - - getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { - return getLaunchAddr(this.launchpad.programId, baseMint)[0]; - } - - getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { - return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; - } - - getFundingRecordAddress({ - launch, - funder, - }: { - launch: PublicKey; - funder: PublicKey; - }): PublicKey { - return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; - } -} diff --git a/sdk/src/v0.6/PriceBasedPerformancePackageClient.ts b/sdk/src/v0.6/PriceBasedPerformancePackageClient.ts deleted file mode 100644 index 116319323..000000000 --- a/sdk/src/v0.6/PriceBasedPerformancePackageClient.ts +++ /dev/null @@ -1,228 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Transaction, - TransactionInstruction, - SystemProgram, -} from "@solana/web3.js"; -import { - TOKEN_PROGRAM_ID, - ASSOCIATED_TOKEN_PROGRAM_ID, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; -import { - PriceBasedPerformancePackage, - IDL as PriceBasedPerformancePackageIDL, -} from "./types/price_based_performance_package.js"; -import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID } from "./constants.js"; -import BN from "bn.js"; -// import { OracleConfig } from "./types/index.js"; -import { - getChangeRequestAddr, - getEventAuthorityAddr, - getPerformancePackageAddr, -} from "./utils/pda.js"; -import { InitializePerformancePackageParams } from "./types/index.js"; - -export type CreatePriceBasedPerformancePackageClientParams = { - provider: AnchorProvider; - priceBasedTokenLockProgramId?: PublicKey; -}; - -export class PriceBasedPerformancePackageClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly programId: PublicKey; - - constructor( - provider: AnchorProvider, - priceBasedTokenLockProgramId: PublicKey, - ) { - this.provider = provider; - this.programId = priceBasedTokenLockProgramId; - this.program = new Program( - PriceBasedPerformancePackageIDL, - priceBasedTokenLockProgramId, - provider, - ); - } - - public static createClient( - createClientParams: CreatePriceBasedPerformancePackageClientParams, - ): PriceBasedPerformancePackageClient { - let { provider, priceBasedTokenLockProgramId } = createClientParams; - - if (!priceBasedTokenLockProgramId) { - priceBasedTokenLockProgramId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID; - } - - return new PriceBasedPerformancePackageClient( - provider, - priceBasedTokenLockProgramId, - ); - } - - public initializePerformancePackageIx(params: { - params: InitializePerformancePackageParams; - createKey: PublicKey; - tokenMint: PublicKey; - grantor: PublicKey; - grantorTokenAccount?: PublicKey; - }) { - const performancePackage = getPerformancePackageAddr({ - createKey: params.createKey, - })[0]; - - const grantorTokenAccount = - params.grantorTokenAccount ?? - getAssociatedTokenAddressSync(params.tokenMint, params.grantor, true); - - return this.program.methods - .initializePerformancePackage(params.params) - .accounts({ - performancePackage, - createKey: params.createKey, - tokenMint: params.tokenMint, - grantorTokenAccount, - performancePackageTokenVault: getAssociatedTokenAddressSync( - params.tokenMint, - performancePackage, - true, - ), - grantor: params.grantor, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - public startUnlockIx(params: { - performancePackage: PublicKey; - oracleAccount: PublicKey; - recipient: PublicKey; - }) { - return this.program.methods.startUnlock().accounts({ - performancePackage: params.performancePackage, - oracleAccount: params.oracleAccount, - recipient: params.recipient, - }); - } - - public completeUnlockIx(params: { - performancePackage: PublicKey; - oracleAccount: PublicKey; - tokenMint: PublicKey; - tokenRecipient: PublicKey; - }) { - return this.program.methods.completeUnlock().accounts({ - performancePackage: params.performancePackage, - oracleAccount: params.oracleAccount, - performancePackageTokenVault: getAssociatedTokenAddressSync( - params.tokenMint, - params.performancePackage, - true, - ), - tokenMint: params.tokenMint, - recipientTokenAccount: getAssociatedTokenAddressSync( - params.tokenMint, - params.tokenRecipient, - true, - ), - tokenRecipient: params.tokenRecipient, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - public proposeChangeIx(params: { - params: { - changeType: any; - pdaNonce: number; - }; - performancePackage: PublicKey; - proposer: PublicKey; - }) { - const changeRequestAddress = this.getChangeRequestAddress( - params.performancePackage, - params.proposer, - params.params.pdaNonce, - ); - - return this.program.methods.proposeChange(params.params).accounts({ - changeRequest: changeRequestAddress, - performancePackage: params.performancePackage, - proposer: params.proposer, - systemProgram: SystemProgram.programId, - }); - } - - public executeChangeIx(params: { - performancePackage: PublicKey; - changeRequest: PublicKey; - executor: PublicKey; - }) { - return this.program.methods.executeChange().accounts({ - changeRequest: params.changeRequest, - performancePackage: params.performancePackage, - executor: params.executor, - }); - } - - public changePerformancePackageAuthorityIx(params: { - performancePackage: PublicKey; - currentAuthority: PublicKey; - newPerformancePackageAuthority: PublicKey; - }) { - return this.program.methods - .changePerformancePackageAuthority({ - newPerformancePackageAuthority: params.newPerformancePackageAuthority, - }) - .accounts({ - performancePackage: params.performancePackage, - currentAuthority: params.currentAuthority, - }); - } - - public async getPerformancePackage(performancePackageAddress: PublicKey) { - return await this.program.account.performancePackage.fetch( - performancePackageAddress, - ); - } - - public async getChangeRequest(changeRequestAddress: PublicKey) { - return await this.program.account.changeRequest.fetch(changeRequestAddress); - } - - public getChangeRequestAddress( - performancePackage: PublicKey, - proposer: PublicKey, - pdaNonce: number, - ): PublicKey { - const [changeRequestAddress] = getChangeRequestAddr({ - programId: this.programId, - performancePackage, - proposer, - pdaNonce, - }); - return changeRequestAddress; - } - - public getPerformancePackageTokenAccountAddress( - performancePackage: PublicKey, - ): PublicKey { - const [performancePackageTokenAccountAddress] = - PublicKey.findProgramAddressSync( - [ - Buffer.from("performance_package_token_account"), - performancePackage.toBuffer(), - ], - this.programId, - ); - return performancePackageTokenAccountAddress; - } - - public getEventAuthorityAddress(): PublicKey { - return getEventAuthorityAddr(this.programId)[0]; - } -} diff --git a/sdk/src/v0.6/constants.ts b/sdk/src/v0.6/constants.ts deleted file mode 100644 index 9466cb05d..000000000 --- a/sdk/src/v0.6/constants.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { Keypair, PublicKey } from "@solana/web3.js"; -import * as anchor from "@coral-xyz/anchor"; -import { BN } from "bn.js"; - -export const FUTARCHY_PROGRAM_ID = new PublicKey( - "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq", -); -export const AMM_PROGRAM_ID = new PublicKey( - "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", -); -export const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( - "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", -); -export const LAUNCHPAD_PROGRAM_ID = new PublicKey( - "MooNyh4CBUYEKyXVnjGYQ8mEiJDpGvJMdvrZx1iGeHV", -); -export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( - "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", -); -export const PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID = new PublicKey( - "pbPPQH7jyKoSLu8QYs3rSY3YkDRXEBojKbTgnUg7NDS", -); - -export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", -); - -export const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", -); - -export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", -); - -export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", -); -export const MAINNET_USDC = new PublicKey( - "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", -); - -export const DEVNET_USDC = new PublicKey( - "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", -); -export const DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", -); - -export const USDC_DECIMALS = 6; - -export const AUTOCRAT_LUTS: PublicKey[] = []; - -export const RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DEVNET_RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DAMM_V2_PROGRAM_ID = new PublicKey( - "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", -); - -export const DAMM_V2_POOL_AUTHORITY = new PublicKey( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC", -); - -export const LOW_FEE_RAYDIUM_CONFIG = new PublicKey( - "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2", -); - -export const DEVNET_LOW_FEE_RAYDIUM_CONFIG = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("amm_config"), - new BN(0).toArrayLike(Buffer, "be", 2), - ], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8", -); - -export const DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2", -); - -export const SQUADS_PROGRAM_CONFIG = new PublicKey( - "BSTq9w3kZwNwpBXJEvTZz2G9ZTNyKBvoSeXMvwb4cNZr", -); - -export const SQUADS_PROGRAM_ID = new PublicKey( - "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", -); - -export const SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "5DH2e3cJmFpyi6mk65EGFediunm4ui6BiKNUNrhWtD1b", -); - -export const SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET = new PublicKey( - "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", -); - -export const MAINNET_METEORA_CONFIG = new PublicKey( - "Asv1KQqeop9e4FFvTzEBZhwtTjuWHXPq5thUGtQrzzA3", -); - -export const METADAO_MULTISIG_VAULT = new PublicKey( - "6awyHMshBGVjJ3ozdSJdyyDE1CTAXUwrpNMaRGMsb4sf", -); - -export const PERMISSIONLESS_ACCOUNT = Keypair.fromSecretKey( - Uint8Array.from([ - 249, 158, 188, 171, 243, 143, 1, 48, 87, 243, 209, 153, 144, 106, 23, 88, - 161, 209, 65, 217, 199, 121, 0, 250, 3, 203, 133, 138, 141, 112, 243, 38, - 198, 205, 120, 222, 160, 224, 151, 190, 84, 254, 127, 178, 224, 195, 130, - 243, 145, 73, 20, 91, 9, 69, 222, 184, 23, 1, 2, 196, 202, 206, 153, 192, - ]), -); diff --git a/sdk/src/v0.6/index.ts b/sdk/src/v0.6/index.ts deleted file mode 100644 index 01929e5b2..000000000 --- a/sdk/src/v0.6/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from "./types/index.js"; -export * from "./utils/index.js"; -export * from "./constants.js"; -export * from "./FutarchyClient.js"; -export * from "./ConditionalVaultClient.js"; -export * from "./LaunchpadClient.js"; -export * from "./PriceBasedPerformancePackageClient.js"; diff --git a/sdk/src/v0.6/types/amm.ts b/sdk/src/v0.6/types/amm.ts deleted file mode 100644 index 6d36be8d8..000000000 --- a/sdk/src/v0.6/types/amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type Amm = { - version: "0.5.0"; - name: "amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: Amm = { - version: "0.5.0", - name: "amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk/src/v0.6/types/autocrat.ts b/sdk/src/v0.6/types/autocrat.ts deleted file mode 100644 index a2afb15ee..000000000 --- a/sdk/src/v0.6/types/autocrat.ts +++ /dev/null @@ -1,2377 +0,0 @@ -export type Autocrat = { - version: "0.5.0"; - name: "autocrat"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - { - name: "executeSpendingLimitChange"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultTransaction"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "upgradeMultisigDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rentPayer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "kollan"; - isMut: false; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "fixOmnipairSpendingLimit"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rentPayer"; - isMut: true; - isSigner: true; - }, - { - name: "kollan"; - isMut: false; - isSigner: true; - }, - { - name: "omnipairSpendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ]; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "slotEnqueued"; - type: "u64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "passAmm"; - type: "publicKey"; - }, - { - name: "failAmm"; - type: "publicKey"; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSlots"; - type: "u64"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "InitializeProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "passLpTokensToLock"; - type: "u64"; - }, - { - name: "failLpTokensToLock"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "passAmm"; - type: "publicKey"; - index: false; - }, - { - name: "failAmm"; - type: "publicKey"; - index: false; - }, - { - name: "passLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "failLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSlots"; - type: "u64"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "ExecuteProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLpTokenBalance"; - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; - }, - { - code: 6011; - name: "InsufficientLpTokenLock"; - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; - }, - { - code: 6012; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer than TWAP start delay"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Draft status"; - }, - { - code: 6015; - name: "InvalidTransaction"; - msg: "This Squads transaction should only contain calls to update spending limits"; - }, - ]; -}; - -export const IDL: Autocrat = { - version: "0.5.0", - name: "autocrat", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalParams", - }, - }, - ], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - { - name: "executeSpendingLimitChange", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultTransaction", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "upgradeMultisigDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "rentPayer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "kollan", - isMut: false, - isSigner: true, - }, - ], - args: [], - }, - { - name: "fixOmnipairSpendingLimit", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "rentPayer", - isMut: true, - isSigner: true, - }, - { - name: "kollan", - isMut: false, - isSigner: true, - }, - { - name: "omnipairSpendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ], - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "descriptionUrl", - type: "string", - }, - { - name: "slotEnqueued", - type: "u64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "passAmm", - type: "publicKey", - }, - { - name: "failAmm", - type: "publicKey", - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "passLpTokensLocked", - type: "u64", - }, - { - name: "failLpTokensLocked", - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSlots", - type: "u64", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "InitializeProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "descriptionUrl", - type: "string", - }, - { - name: "passLpTokensToLock", - type: "u64", - }, - { - name: "failLpTokensToLock", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - ], - }, - }, - ], - events: [ - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "passAmm", - type: "publicKey", - index: false, - }, - { - name: "failAmm", - type: "publicKey", - index: false, - }, - { - name: "passLpMint", - type: "publicKey", - index: false, - }, - { - name: "failLpMint", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "passLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "failLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSlots", - type: "u64", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "ExecuteProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLpTokenBalance", - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", - }, - { - code: 6011, - name: "InsufficientLpTokenLock", - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", - }, - { - code: 6012, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer than TWAP start delay", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Draft status", - }, - { - code: 6015, - name: "InvalidTransaction", - msg: "This Squads transaction should only contain calls to update spending limits", - }, - ], -}; diff --git a/sdk/src/v0.6/types/autocrat_migrator.ts b/sdk/src/v0.6/types/autocrat_migrator.ts deleted file mode 100644 index 676d2df3d..000000000 --- a/sdk/src/v0.6/types/autocrat_migrator.ts +++ /dev/null @@ -1,237 +0,0 @@ -export type AutocratMigrator = { - version: "0.1.0"; - name: "autocrat_migrator"; - instructions: [ - { - name: "multiTransfer2"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "multiTransfer4"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "from2"; - isMut: true; - isSigner: false; - }, - { - name: "to2"; - isMut: true; - isSigner: false; - }, - { - name: "from3"; - isMut: true; - isSigner: false; - }, - { - name: "to3"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; -}; - -export const IDL: AutocratMigrator = { - version: "0.1.0", - name: "autocrat_migrator", - instructions: [ - { - name: "multiTransfer2", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "multiTransfer4", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "from2", - isMut: true, - isSigner: false, - }, - { - name: "to2", - isMut: true, - isSigner: false, - }, - { - name: "from3", - isMut: true, - isSigner: false, - }, - { - name: "to3", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], -}; diff --git a/sdk/src/v0.6/types/bid_wall.ts b/sdk/src/v0.6/types/bid_wall.ts deleted file mode 100644 index cbe5015de..000000000 --- a/sdk/src/v0.6/types/bid_wall.ts +++ /dev/null @@ -1,1033 +0,0 @@ -export type BidWall = { - version: "0.6.0"; - name: "bid_wall"; - instructions: [ - { - name: "initializeBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "creator"; - isMut: false; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "creatorQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "daoTreasury"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeBidWallArgs"; - }; - }, - ]; - }, - { - name: "closeBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authorityQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "sellTokens"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "userTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "daoTreasury"; - isMut: false; - isSigner: false; - }, - { - name: "daoTreasuryQuoteTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SellTokensArgs"; - }; - }, - ]; - }, - { - name: "collectFees"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authorityQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "bidWall"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - docs: ["The nonce of the bid wall."]; - type: "u64"; - }, - { - name: "createdTimestamp"; - docs: ["When the bid wall was created."]; - type: "i64"; - }, - { - name: "feesCollected"; - docs: ["The fees collected by the bid wall."]; - type: "u64"; - }, - { - name: "initialAmmBaseReserves"; - docs: ["The initial base reserves of the Futarchy AMM."]; - type: "u64"; - }, - { - name: "initialAmmQuoteReserves"; - docs: ["The initial quote (USDC) reserves of the Futarchy AMM."]; - type: "u64"; - }, - { - name: "initialDaoTreasuryQuoteAmount"; - docs: ["The initial amount of quote tokens in the DAO treasury."]; - type: "u64"; - }, - { - name: "initialNav"; - docs: [ - "The total raise amount of the launch this bid wall is associated with.", - ]; - type: "u64"; - }, - { - name: "creator"; - docs: ["The authority of the bid wall."]; - type: "publicKey"; - }, - { - name: "authority"; - docs: ["The authority of the bid wall."]; - type: "publicKey"; - }, - { - name: "daoTreasury"; - docs: ["The DAO treasury address."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: ["The mint of the token being sold into the bid wall."]; - type: "publicKey"; - }, - { - name: "feeRecipient"; - docs: ["The recipient of the fees collected by the bid wall."]; - type: "publicKey"; - }, - { - name: "durationSeconds"; - docs: [ - "The minimum duration in seconds before the bid wall can be closed.", - ]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "InitializeBidWallArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialAmmBaseReserves"; - type: "u64"; - }, - { - name: "initialAmmQuoteReserves"; - type: "u64"; - }, - { - name: "initialNav"; - type: "u64"; - }, - { - name: "initialDaoTreasuryQuoteAmount"; - type: "u64"; - }, - { - name: "durationSeconds"; - type: "u32"; - }, - ]; - }; - }, - { - name: "SellTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amountIn"; - type: "u64"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "BidWallExpired"; - msg: "Bid wall expired"; - }, - { - code: 6001; - name: "BidWallNotExpired"; - msg: "Bid wall not expired"; - }, - { - code: 6002; - name: "FeeRecipientMismatch"; - msg: "Fee recipient mismatch"; - }, - ]; -}; - -export const IDL: BidWall = { - version: "0.6.0", - name: "bid_wall", - instructions: [ - { - name: "initializeBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "creator", - isMut: false, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "creatorQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "daoTreasury", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeBidWallArgs", - }, - }, - ], - }, - { - name: "closeBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authorityQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "sellTokens", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "userTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "daoTreasury", - isMut: false, - isSigner: false, - }, - { - name: "daoTreasuryQuoteTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SellTokensArgs", - }, - }, - ], - }, - { - name: "collectFees", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authorityQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "bidWall", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - docs: ["The nonce of the bid wall."], - type: "u64", - }, - { - name: "createdTimestamp", - docs: ["When the bid wall was created."], - type: "i64", - }, - { - name: "feesCollected", - docs: ["The fees collected by the bid wall."], - type: "u64", - }, - { - name: "initialAmmBaseReserves", - docs: ["The initial base reserves of the Futarchy AMM."], - type: "u64", - }, - { - name: "initialAmmQuoteReserves", - docs: ["The initial quote (USDC) reserves of the Futarchy AMM."], - type: "u64", - }, - { - name: "initialDaoTreasuryQuoteAmount", - docs: ["The initial amount of quote tokens in the DAO treasury."], - type: "u64", - }, - { - name: "initialNav", - docs: [ - "The total raise amount of the launch this bid wall is associated with.", - ], - type: "u64", - }, - { - name: "creator", - docs: ["The authority of the bid wall."], - type: "publicKey", - }, - { - name: "authority", - docs: ["The authority of the bid wall."], - type: "publicKey", - }, - { - name: "daoTreasury", - docs: ["The DAO treasury address."], - type: "publicKey", - }, - { - name: "baseMint", - docs: ["The mint of the token being sold into the bid wall."], - type: "publicKey", - }, - { - name: "feeRecipient", - docs: ["The recipient of the fees collected by the bid wall."], - type: "publicKey", - }, - { - name: "durationSeconds", - docs: [ - "The minimum duration in seconds before the bid wall can be closed.", - ], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "InitializeBidWallArgs", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialAmmBaseReserves", - type: "u64", - }, - { - name: "initialAmmQuoteReserves", - type: "u64", - }, - { - name: "initialNav", - type: "u64", - }, - { - name: "initialDaoTreasuryQuoteAmount", - type: "u64", - }, - { - name: "durationSeconds", - type: "u32", - }, - ], - }, - }, - { - name: "SellTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "amountIn", - type: "u64", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "BidWallExpired", - msg: "Bid wall expired", - }, - { - code: 6001, - name: "BidWallNotExpired", - msg: "Bid wall not expired", - }, - { - code: 6002, - name: "FeeRecipientMismatch", - msg: "Fee recipient mismatch", - }, - ], -}; diff --git a/sdk/src/v0.6/types/conditional_vault.ts b/sdk/src/v0.6/types/conditional_vault.ts deleted file mode 100644 index 27c245b79..000000000 --- a/sdk/src/v0.6/types/conditional_vault.ts +++ /dev/null @@ -1,1849 +0,0 @@ -export type ConditionalVault = { - version: "0.4.0"; - name: "conditional_vault"; - instructions: [ - { - name: "initializeQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeQuestionArgs"; - }; - }, - ]; - }, - { - name: "resolveQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "oracle"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ResolveQuestionArgs"; - }; - }, - ]; - }, - { - name: "initializeConditionalVault"; - accounts: [ - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "splitTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "mergeTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "redeemTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "addMetadataToConditionalTokens"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMetadataToConditionalTokensArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "conditionalVault"; - type: { - kind: "struct"; - fields: [ - { - name: "question"; - type: "publicKey"; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - }, - { - name: "underlyingTokenAccount"; - type: "publicKey"; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "decimals"; - type: "u8"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "question"; - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - { - name: "payoutDenominator"; - type: "u32"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "AddMetadataToConditionalTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "name"; - type: "string"; - }, - { - name: "symbol"; - type: "string"; - }, - { - name: "uri"; - type: "string"; - }, - ]; - }; - }, - { - name: "InitializeQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "numOutcomes"; - type: "u8"; - }, - ]; - }; - }, - { - name: "ResolveQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - ]; - }; - }, - { - name: "VaultStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Active"; - }, - { - name: "Finalized"; - }, - { - name: "Reverted"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "AddMetadataToConditionalTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMetadata"; - type: "publicKey"; - index: false; - }, - { - name: "name"; - type: "string"; - index: false; - }, - { - name: "symbol"; - type: "string"; - index: false; - }, - { - name: "uri"; - type: "string"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeConditionalVaultEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - index: false; - }, - { - name: "oracle"; - type: "publicKey"; - index: false; - }, - { - name: "numOutcomes"; - type: "u8"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MergeTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RedeemTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "ResolveQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - index: false; - }, - ]; - }, - { - name: "SplitTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "InsufficientUnderlyingTokens"; - msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; - }, - { - code: 6002; - name: "InsufficientConditionalTokens"; - msg: "Insufficient conditional token balance to merge this `amount`"; - }, - { - code: 6003; - name: "InvalidVaultUnderlyingTokenAccount"; - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; - }, - { - code: 6004; - name: "InvalidConditionalTokenMint"; - msg: "This conditional token mint is not this vault's conditional token mint"; - }, - { - code: 6005; - name: "CantRedeemConditionalTokens"; - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens"; - }, - { - code: 6006; - name: "InsufficientNumConditions"; - msg: "Questions need 2 or more conditions"; - }, - { - code: 6007; - name: "InvalidNumPayoutNumerators"; - msg: "Invalid number of payout numerators"; - }, - { - code: 6008; - name: "InvalidConditionals"; - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens"; - }, - { - code: 6009; - name: "ConditionalMintMismatch"; - msg: "Conditional mint not in vault"; - }, - { - code: 6010; - name: "BadConditionalMint"; - msg: "Unable to deserialize a conditional token mint"; - }, - { - code: 6011; - name: "BadConditionalTokenAccount"; - msg: "Unable to deserialize a conditional token account"; - }, - { - code: 6012; - name: "ConditionalTokenMintMismatch"; - msg: "User conditional token account mint does not match conditional mint"; - }, - { - code: 6013; - name: "PayoutZero"; - msg: "Payouts must sum to 1 or more"; - }, - { - code: 6014; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - { - code: 6015; - name: "ConditionalTokenMetadataAlreadySet"; - msg: "Conditional token metadata already set"; - }, - { - code: 6016; - name: "UnauthorizedConditionalTokenAccount"; - msg: "Conditional token account is not owned by the authority"; - }, - ]; -}; - -export const IDL: ConditionalVault = { - version: "0.4.0", - name: "conditional_vault", - instructions: [ - { - name: "initializeQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeQuestionArgs", - }, - }, - ], - }, - { - name: "resolveQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "oracle", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ResolveQuestionArgs", - }, - }, - ], - }, - { - name: "initializeConditionalVault", - accounts: [ - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "splitTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "mergeTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "redeemTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "addMetadataToConditionalTokens", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMetadataToConditionalTokensArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "conditionalVault", - type: { - kind: "struct", - fields: [ - { - name: "question", - type: "publicKey", - }, - { - name: "underlyingTokenMint", - type: "publicKey", - }, - { - name: "underlyingTokenAccount", - type: "publicKey", - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "decimals", - type: "u8", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "question", - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ], - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - { - name: "payoutDenominator", - type: "u32", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "AddMetadataToConditionalTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "name", - type: "string", - }, - { - name: "symbol", - type: "string", - }, - { - name: "uri", - type: "string", - }, - ], - }, - }, - { - name: "InitializeQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "numOutcomes", - type: "u8", - }, - ], - }, - }, - { - name: "ResolveQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - ], - }, - }, - { - name: "VaultStatus", - type: { - kind: "enum", - variants: [ - { - name: "Active", - }, - { - name: "Finalized", - }, - { - name: "Reverted", - }, - ], - }, - }, - ], - events: [ - { - name: "AddMetadataToConditionalTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMint", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMetadata", - type: "publicKey", - index: false, - }, - { - name: "name", - type: "string", - index: false, - }, - { - name: "symbol", - type: "string", - index: false, - }, - { - name: "uri", - type: "string", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeConditionalVaultEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "underlyingTokenMint", - type: "publicKey", - index: false, - }, - { - name: "vaultUnderlyingTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "questionId", - type: { - array: ["u8", 32], - }, - index: false, - }, - { - name: "oracle", - type: "publicKey", - index: false, - }, - { - name: "numOutcomes", - type: "u8", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MergeTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "RedeemTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "ResolveQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - index: false, - }, - ], - }, - { - name: "SplitTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "InsufficientUnderlyingTokens", - msg: "Insufficient underlying token balance to mint this amount of conditional tokens", - }, - { - code: 6002, - name: "InsufficientConditionalTokens", - msg: "Insufficient conditional token balance to merge this `amount`", - }, - { - code: 6003, - name: "InvalidVaultUnderlyingTokenAccount", - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", - }, - { - code: 6004, - name: "InvalidConditionalTokenMint", - msg: "This conditional token mint is not this vault's conditional token mint", - }, - { - code: 6005, - name: "CantRedeemConditionalTokens", - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens", - }, - { - code: 6006, - name: "InsufficientNumConditions", - msg: "Questions need 2 or more conditions", - }, - { - code: 6007, - name: "InvalidNumPayoutNumerators", - msg: "Invalid number of payout numerators", - }, - { - code: 6008, - name: "InvalidConditionals", - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens", - }, - { - code: 6009, - name: "ConditionalMintMismatch", - msg: "Conditional mint not in vault", - }, - { - code: 6010, - name: "BadConditionalMint", - msg: "Unable to deserialize a conditional token mint", - }, - { - code: 6011, - name: "BadConditionalTokenAccount", - msg: "Unable to deserialize a conditional token account", - }, - { - code: 6012, - name: "ConditionalTokenMintMismatch", - msg: "User conditional token account mint does not match conditional mint", - }, - { - code: 6013, - name: "PayoutZero", - msg: "Payouts must sum to 1 or more", - }, - { - code: 6014, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - { - code: 6015, - name: "ConditionalTokenMetadataAlreadySet", - msg: "Conditional token metadata already set", - }, - { - code: 6016, - name: "UnauthorizedConditionalTokenAccount", - msg: "Conditional token account is not owned by the authority", - }, - ], -}; diff --git a/sdk/src/v0.6/types/damm_v2_cpi.ts b/sdk/src/v0.6/types/damm_v2_cpi.ts deleted file mode 100644 index 448829271..000000000 --- a/sdk/src/v0.6/types/damm_v2_cpi.ts +++ /dev/null @@ -1,747 +0,0 @@ -export type DammV2Cpi = { - version: "0.1.0"; - name: "damm_v2_cpi"; - instructions: [ - { - name: "initializePoolWithDynamicConfig"; - accounts: [ - { - name: "creator"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: true; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Address paying to create the pool. Can be anyone"]; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "payerTokenA"; - isMut: true; - isSigner: false; - }, - { - name: "payerTokenB"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeCustomizablePoolParameters"; - }; - }, - ]; - }, - { - name: "claimPositionFee"; - accounts: [ - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: false; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAAccount"; - isMut: true; - isSigner: false; - docs: ["The user token a account"]; - }, - { - name: "tokenBAccount"; - isMut: true; - isSigner: false; - docs: ["The user token b account"]; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - docs: ["The vault token account for input token"]; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - docs: ["The vault token account for output token"]; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - docs: ["The mint of token a"]; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - docs: ["The mint of token b"]; - }, - { - name: "positionNftAccount"; - isMut: false; - isSigner: false; - docs: ["The token account for nft"]; - }, - { - name: "owner"; - isMut: false; - isSigner: true; - docs: ["owner of position"]; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - docs: ["Token a program"]; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - docs: ["Token b program"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - types: [ - { - name: "PoolFeeParameters"; - docs: ["Information regarding fee charges"]; - type: { - kind: "struct"; - fields: [ - { - name: "baseFee"; - docs: ["Base fee"]; - type: { - defined: "BaseFeeParameters"; - }; - }, - { - name: "padding"; - docs: ["padding"]; - type: { - array: ["u8", 3]; - }; - }, - { - name: "dynamicFee"; - docs: ["dynamic fee"]; - type: { - option: { - defined: "DynamicFeeParameters"; - }; - }; - }, - ]; - }; - }, - { - name: "BaseFeeParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "cliffFeeNumerator"; - type: "u64"; - }, - { - name: "numberOfPeriod"; - type: "u16"; - }, - { - name: "periodFrequency"; - type: "u64"; - }, - { - name: "reductionFactor"; - type: "u64"; - }, - { - name: "feeSchedulerMode"; - type: "u8"; - }, - ]; - }; - }, - { - name: "DynamicFeeParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "binStep"; - type: "u16"; - }, - { - name: "binStepU128"; - type: "u128"; - }, - { - name: "filterPeriod"; - type: "u16"; - }, - { - name: "decayPeriod"; - type: "u16"; - }, - { - name: "reductionFactor"; - type: "u16"; - }, - { - name: "maxVolatilityAccumulator"; - type: "u32"; - }, - { - name: "variableFeeControl"; - type: "u32"; - }, - ]; - }; - }, - { - name: "InitializeCustomizablePoolParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "poolFees"; - docs: ["pool fees"]; - type: { - defined: "PoolFeeParameters"; - }; - }, - { - name: "sqrtMinPrice"; - docs: ["sqrt min price"]; - type: "u128"; - }, - { - name: "sqrtMaxPrice"; - docs: ["sqrt max price"]; - type: "u128"; - }, - { - name: "hasAlphaVault"; - docs: ["has alpha vault"]; - type: "bool"; - }, - { - name: "liquidity"; - docs: ["initialize liquidity"]; - type: "u128"; - }, - { - name: "sqrtPrice"; - docs: [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value", - ]; - type: "u128"; - }, - { - name: "activationType"; - docs: ["activation type"]; - type: "u8"; - }, - { - name: "collectFeeMode"; - docs: ["collect fee mode"]; - type: "u8"; - }, - { - name: "activationPoint"; - docs: ["activation point"]; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - ]; -}; - -export const IDL: DammV2Cpi = { - version: "0.1.0", - name: "damm_v2_cpi", - instructions: [ - { - name: "initializePoolWithDynamicConfig", - accounts: [ - { - name: "creator", - isMut: false, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: true, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Address paying to create the pool. Can be anyone"], - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: true, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "payerTokenA", - isMut: true, - isSigner: false, - }, - { - name: "payerTokenB", - isMut: true, - isSigner: false, - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeCustomizablePoolParameters", - }, - }, - ], - }, - { - name: "claimPositionFee", - accounts: [ - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: false, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAAccount", - isMut: true, - isSigner: false, - docs: ["The user token a account"], - }, - { - name: "tokenBAccount", - isMut: true, - isSigner: false, - docs: ["The user token b account"], - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - docs: ["The vault token account for input token"], - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - docs: ["The vault token account for output token"], - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - docs: ["The mint of token a"], - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - docs: ["The mint of token b"], - }, - { - name: "positionNftAccount", - isMut: false, - isSigner: false, - docs: ["The token account for nft"], - }, - { - name: "owner", - isMut: false, - isSigner: true, - docs: ["owner of position"], - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - docs: ["Token a program"], - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - docs: ["Token b program"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - types: [ - { - name: "PoolFeeParameters", - docs: ["Information regarding fee charges"], - type: { - kind: "struct", - fields: [ - { - name: "baseFee", - docs: ["Base fee"], - type: { - defined: "BaseFeeParameters", - }, - }, - { - name: "padding", - docs: ["padding"], - type: { - array: ["u8", 3], - }, - }, - { - name: "dynamicFee", - docs: ["dynamic fee"], - type: { - option: { - defined: "DynamicFeeParameters", - }, - }, - }, - ], - }, - }, - { - name: "BaseFeeParameters", - type: { - kind: "struct", - fields: [ - { - name: "cliffFeeNumerator", - type: "u64", - }, - { - name: "numberOfPeriod", - type: "u16", - }, - { - name: "periodFrequency", - type: "u64", - }, - { - name: "reductionFactor", - type: "u64", - }, - { - name: "feeSchedulerMode", - type: "u8", - }, - ], - }, - }, - { - name: "DynamicFeeParameters", - type: { - kind: "struct", - fields: [ - { - name: "binStep", - type: "u16", - }, - { - name: "binStepU128", - type: "u128", - }, - { - name: "filterPeriod", - type: "u16", - }, - { - name: "decayPeriod", - type: "u16", - }, - { - name: "reductionFactor", - type: "u16", - }, - { - name: "maxVolatilityAccumulator", - type: "u32", - }, - { - name: "variableFeeControl", - type: "u32", - }, - ], - }, - }, - { - name: "InitializeCustomizablePoolParameters", - type: { - kind: "struct", - fields: [ - { - name: "poolFees", - docs: ["pool fees"], - type: { - defined: "PoolFeeParameters", - }, - }, - { - name: "sqrtMinPrice", - docs: ["sqrt min price"], - type: "u128", - }, - { - name: "sqrtMaxPrice", - docs: ["sqrt max price"], - type: "u128", - }, - { - name: "hasAlphaVault", - docs: ["has alpha vault"], - type: "bool", - }, - { - name: "liquidity", - docs: ["initialize liquidity"], - type: "u128", - }, - { - name: "sqrtPrice", - docs: [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value", - ], - type: "u128", - }, - { - name: "activationType", - docs: ["activation type"], - type: "u8", - }, - { - name: "collectFeeMode", - docs: ["collect fee mode"], - type: "u8", - }, - { - name: "activationPoint", - docs: ["activation point"], - type: { - option: "u64", - }, - }, - ], - }, - }, - ], -}; diff --git a/sdk/src/v0.6/types/futarchy.ts b/sdk/src/v0.6/types/futarchy.ts deleted file mode 100644 index 99270d126..000000000 --- a/sdk/src/v0.6/types/futarchy.ts +++ /dev/null @@ -1,6913 +0,0 @@ -export type Futarchy = { - version: "0.6.1"; - name: "futarchy"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "stakeToProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "StakeToProposalParams"; - }; - }, - ]; - }, - { - name: "unstakeFromProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "UnstakeFromProposalParams"; - }; - }, - ]; - }, - { - name: "launchProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - { - name: "resizeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "spotSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "SpotSwapParams"; - }; - }, - ]; - }, - { - name: "conditionalSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "proposal"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "trader"; - isMut: false; - isSigner: true; - }, - { - name: "userInputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userOutputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalVaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ConditionalSwapParams"; - }; - }, - ]; - }, - { - name: "provideLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProvider"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProvideLiquidityParams"; - }; - }, - ]; - }, - { - name: "withdrawLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "positionAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "WithdrawLiquidityParams"; - }; - }, - ]; - }, - { - name: "collectFees"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "baseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeSpendingLimitChange"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultTransaction"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "sponsorProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "teamAddress"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "collectMeteoraDammFees"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigPermissionlessAccount"; - isMut: false; - isSigner: true; - }, - { - name: "meteoraClaimPositionFeesAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: false; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAAccount"; - isMut: true; - isSigner: false; - docs: ["Token account of base tokens recipient"]; - }, - { - name: "tokenBAccount"; - isMut: true; - isSigner: false; - docs: ["Token account of quote tokens recipient"]; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: false; - isSigner: false; - }, - { - name: "owner"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "initiateVaultSpendOptimisticProposal"; - accounts: [ - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsSpendingLimit"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigPermissionlessAccount"; - isMut: false; - isSigner: true; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoQuoteVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: true; - isSigner: true; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "recipientQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitiateVaultSpendOptimisticProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeOptimisticProposal"; - accounts: [ - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "adminApproveExecuteMultisigProposal"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "ammPosition"; - type: { - kind: "struct"; - fields: [ - { - name: "dao"; - type: "publicKey"; - }, - { - name: "positionAuthority"; - type: "publicKey"; - }, - { - name: "liquidity"; - type: "u128"; - }, - ]; - }; - }, - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "amm"; - docs: ["Embedded FutarchyAmm - 1:1 relationship"]; - type: { - defined: "FutarchyAmm"; - }; - }, - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ]; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ]; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ]; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - { - name: "optimisticProposal"; - type: { - option: { - defined: "OptimisticProposal"; - }; - }; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: "bool"; - }, - ]; - }; - }, - { - name: "oldDao"; - type: { - kind: "struct"; - fields: [ - { - name: "amm"; - docs: ["Embedded FutarchyAmm - 1:1 relationship"]; - type: { - defined: "FutarchyAmm"; - }; - }, - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ]; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ]; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ]; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "timestampEnqueued"; - type: "i64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSeconds"; - type: "u32"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - { - name: "passBaseMint"; - type: "publicKey"; - }, - { - name: "passQuoteMint"; - type: "publicKey"; - }, - { - name: "failBaseMint"; - type: "publicKey"; - }, - { - name: "failQuoteMint"; - type: "publicKey"; - }, - { - name: "isTeamSponsored"; - type: "bool"; - }, - ]; - }; - }, - { - name: "stakeAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "proposal"; - type: "publicKey"; - }, - { - name: "staker"; - type: "publicKey"; - }, - { - name: "amount"; - type: "u64"; - }, - { - name: "bump"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "daoSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ConditionalSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "market"; - type: { - defined: "Market"; - }; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitiateVaultSpendOptimisticProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ProvideLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLiquidity"; - docs: ["The minimum liquidity you will be assigned"]; - type: "u128"; - }, - { - name: "positionAuthority"; - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "SpotSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "StakeToProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UnstakeFromProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "secondsPerProposal"; - type: { - option: "u32"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "twapStartDelaySeconds"; - type: { - option: "u32"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "baseToStake"; - type: { - option: "u64"; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: { - option: "i16"; - }; - }, - { - name: "teamAddress"; - type: { - option: "publicKey"; - }; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: { - option: "bool"; - }; - }, - ]; - }; - }, - { - name: "WithdrawLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "liquidityToWithdraw"; - docs: ["How much liquidity to withdraw"]; - type: "u128"; - }, - { - name: "minBaseAmount"; - docs: ["Minimum base tokens to receive"]; - type: "u64"; - }, - { - name: "minQuoteAmount"; - docs: ["Minimum quote tokens to receive"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "OptimisticProposal"; - type: { - kind: "struct"; - fields: [ - { - name: "squadsProposal"; - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ]; - type: "publicKey"; - }, - { - name: "enqueuedTimestamp"; - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ]; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "FutarchyAmm"; - type: { - kind: "struct"; - fields: [ - { - name: "state"; - type: { - defined: "PoolState"; - }; - }, - { - name: "totalLiquidity"; - type: "u128"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "lastUpdatedTimestamp"; - type: "i64"; - }, - { - name: "createdAtTimestamp"; - type: "i64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySeconds"; - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ]; - type: "u32"; - }, - ]; - }; - }, - { - name: "Pool"; - type: { - kind: "struct"; - fields: [ - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "quoteReserves"; - type: "u64"; - }, - { - name: "baseReserves"; - type: "u64"; - }, - { - name: "quoteProtocolFeeBalance"; - type: "u64"; - }, - { - name: "baseProtocolFeeBalance"; - type: "u64"; - }, - ]; - }; - }, - { - name: "PoolState"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - { - name: "Futarchy"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - { - name: "pass"; - type: { - defined: "Pool"; - }; - }, - { - name: "fail"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - ]; - }; - }, - { - name: "Market"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - }, - { - name: "Pass"; - }, - { - name: "Fail"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - { - name: "Token"; - type: { - kind: "enum"; - variants: [ - { - name: "Base"; - }, - { - name: "Quote"; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Draft"; - fields: [ - { - name: "amountStaked"; - type: "u64"; - }, - ]; - }, - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "CollectFeesEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - index: false; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "baseFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: "bool"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSeconds"; - type: "u32"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "StakeToProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "UnstakeFromProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "timestampEnqueued"; - type: "i64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - { - name: "isTeamSponsored"; - type: "bool"; - index: false; - }, - ]; - }, - { - name: "SpotSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ConditionalSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "trader"; - type: "publicKey"; - index: false; - }, - { - name: "market"; - type: { - defined: "Market"; - }; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ProvideLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "positionAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "liquidityMinted"; - type: "u128"; - index: false; - }, - { - name: "minLiquidity"; - type: "u128"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "WithdrawLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityWithdrawn"; - type: "u128"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "SponsorProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CollectMeteoraDammFeesEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "pool"; - type: "publicKey"; - index: false; - }, - { - name: "baseTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "baseFeesCollected"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitiateVaultSpendOptimisticProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "daoQuoteVaultAccount"; - type: "publicKey"; - index: false; - }, - { - name: "recipientQuoteAccount"; - type: "publicKey"; - index: false; - }, - { - name: "enqueuedTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "FinalizeOptimisticProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLiquidity"; - msg: "More liquidity needs to be in the AMM to launch this proposal"; - }, - { - code: 6011; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay"; - }, - { - code: 6012; - name: "PassThresholdTooHigh"; - msg: "Pass threshold must be less than 10%"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Draft status"; - }, - { - code: 6015; - name: "CastingOverflow"; - msg: "Casting overflow. If you're seeing this, please report this"; - }, - { - code: 6016; - name: "InsufficientBalance"; - msg: "Insufficient balance"; - }, - { - code: 6017; - name: "ZeroLiquidityRemove"; - msg: "Cannot remove zero liquidity"; - }, - { - code: 6018; - name: "SwapSlippageExceeded"; - msg: "Swap slippage exceeded"; - }, - { - code: 6019; - name: "AssertFailed"; - msg: "Assert failed"; - }, - { - code: 6020; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - { - code: 6021; - name: "ProposalNotInDraftState"; - msg: "Proposal is not in draft state"; - }, - { - code: 6022; - name: "InsufficientTokenBalance"; - msg: "Insufficient token balance"; - }, - { - code: 6023; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6024; - name: "InsufficientStakeToLaunch"; - msg: "Insufficient stake to launch proposal"; - }, - { - code: 6025; - name: "StakerNotFound"; - msg: "Staker not found in proposal"; - }, - { - code: 6026; - name: "PoolNotInSpotState"; - msg: "Pool must be in spot state"; - }, - { - code: 6027; - name: "InvalidDaoCreateLiquidity"; - msg: "If you're providing liquidity, you must provide both base and quote token accounts"; - }, - { - code: 6028; - name: "InvalidStakeAccount"; - msg: "Invalid stake account"; - }, - { - code: 6029; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6030; - name: "ProposalNotActive"; - msg: "Proposal needs to be active to perform a conditional swap"; - }, - { - code: 6031; - name: "InvalidTransaction"; - msg: "This Squads transaction should only contain calls to update spending limits"; - }, - { - code: 6032; - name: "ProposalAlreadySponsored"; - msg: "Proposal has already been sponsored"; - }, - { - code: 6033; - name: "InvalidTeamSponsoredPassThreshold"; - msg: "Team sponsored pass threshold must be between -10% and 10%"; - }, - { - code: 6034; - name: "InvalidTargetK"; - msg: "Target K must be greater than the current K"; - }, - { - code: 6035; - name: "InvalidTransactionMessage"; - msg: "Failed to compile transaction message for Squads vault transaction"; - }, - { - code: 6036; - name: "InvalidRecipient"; - msg: "Invalid recipient"; - }, - { - code: 6037; - name: "OptimisticGovernanceDisabled"; - msg: "Optimistic governance is disabled"; - }, - { - code: 6038; - name: "ActiveOptimisticProposalAlreadyEnqueued"; - msg: "An active optimistic proposal is already enqueued"; - }, - { - code: 6039; - name: "NoActiveOptimisticProposal"; - msg: "No active optimistic proposal"; - }, - { - code: 6040; - name: "OptimisticProposalAlreadyPassed"; - msg: "Optimistic proposal has already passed"; - }, - { - code: 6041; - name: "CannotSponsorOptimisticProposalChallenge"; - msg: "Team cannot sponsor a challenge to an optimistic proposal"; - }, - { - code: 6042; - name: "InvalidSpendingLimitMint"; - msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; - }, - ]; -}; - -export const IDL: Futarchy = { - version: "0.6.1", - name: "futarchy", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "stakeToProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "StakeToProposalParams", - }, - }, - ], - }, - { - name: "unstakeFromProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "UnstakeFromProposalParams", - }, - }, - ], - }, - { - name: "launchProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - { - name: "resizeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "spotSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "SpotSwapParams", - }, - }, - ], - }, - { - name: "conditionalSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "proposal", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "trader", - isMut: false, - isSigner: true, - }, - { - name: "userInputAccount", - isMut: true, - isSigner: false, - }, - { - name: "userOutputAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalVaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ConditionalSwapParams", - }, - }, - ], - }, - { - name: "provideLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProvider", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProvideLiquidityParams", - }, - }, - ], - }, - { - name: "withdrawLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "positionAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "WithdrawLiquidityParams", - }, - }, - ], - }, - { - name: "collectFees", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "baseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeSpendingLimitChange", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultTransaction", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "sponsorProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "teamAddress", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "collectMeteoraDammFees", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigPermissionlessAccount", - isMut: false, - isSigner: true, - }, - { - name: "meteoraClaimPositionFeesAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: false, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAAccount", - isMut: true, - isSigner: false, - docs: ["Token account of base tokens recipient"], - }, - { - name: "tokenBAccount", - isMut: true, - isSigner: false, - docs: ["Token account of quote tokens recipient"], - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: false, - isSigner: false, - }, - { - name: "owner", - isMut: false, - isSigner: false, - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "initiateVaultSpendOptimisticProposal", - accounts: [ - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsSpendingLimit", - isMut: false, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigPermissionlessAccount", - isMut: false, - isSigner: true, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoQuoteVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: true, - isSigner: true, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "recipientQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitiateVaultSpendOptimisticProposalParams", - }, - }, - ], - }, - { - name: "finalizeOptimisticProposal", - accounts: [ - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "adminApproveExecuteMultisigProposal", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "ammPosition", - type: { - kind: "struct", - fields: [ - { - name: "dao", - type: "publicKey", - }, - { - name: "positionAuthority", - type: "publicKey", - }, - { - name: "liquidity", - type: "u128", - }, - ], - }, - }, - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "amm", - docs: ["Embedded FutarchyAmm - 1:1 relationship"], - type: { - defined: "FutarchyAmm", - }, - }, - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ], - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ], - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ], - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - { - name: "optimisticProposal", - type: { - option: { - defined: "OptimisticProposal", - }, - }, - }, - { - name: "isOptimisticGovernanceEnabled", - type: "bool", - }, - ], - }, - }, - { - name: "oldDao", - type: { - kind: "struct", - fields: [ - { - name: "amm", - docs: ["Embedded FutarchyAmm - 1:1 relationship"], - type: { - defined: "FutarchyAmm", - }, - }, - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ], - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ], - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ], - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "timestampEnqueued", - type: "i64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSeconds", - type: "u32", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - { - name: "passBaseMint", - type: "publicKey", - }, - { - name: "passQuoteMint", - type: "publicKey", - }, - { - name: "failBaseMint", - type: "publicKey", - }, - { - name: "failQuoteMint", - type: "publicKey", - }, - { - name: "isTeamSponsored", - type: "bool", - }, - ], - }, - }, - { - name: "stakeAccount", - type: { - kind: "struct", - fields: [ - { - name: "proposal", - type: "publicKey", - }, - { - name: "staker", - type: "publicKey", - }, - { - name: "amount", - type: "u64", - }, - { - name: "bump", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "daoSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ConditionalSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "market", - type: { - defined: "Market", - }, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitiateVaultSpendOptimisticProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "ProvideLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLiquidity", - docs: ["The minimum liquidity you will be assigned"], - type: "u128", - }, - { - name: "positionAuthority", - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ], - type: "publicKey", - }, - ], - }, - }, - { - name: "SpotSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "inputAmount", - type: "u64", - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "StakeToProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UnstakeFromProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "secondsPerProposal", - type: { - option: "u32", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "twapStartDelaySeconds", - type: { - option: "u32", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "baseToStake", - type: { - option: "u64", - }, - }, - { - name: "teamSponsoredPassThresholdBps", - type: { - option: "i16", - }, - }, - { - name: "teamAddress", - type: { - option: "publicKey", - }, - }, - { - name: "isOptimisticGovernanceEnabled", - type: { - option: "bool", - }, - }, - ], - }, - }, - { - name: "WithdrawLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "liquidityToWithdraw", - docs: ["How much liquidity to withdraw"], - type: "u128", - }, - { - name: "minBaseAmount", - docs: ["Minimum base tokens to receive"], - type: "u64", - }, - { - name: "minQuoteAmount", - docs: ["Minimum quote tokens to receive"], - type: "u64", - }, - ], - }, - }, - { - name: "OptimisticProposal", - type: { - kind: "struct", - fields: [ - { - name: "squadsProposal", - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ], - type: "publicKey", - }, - { - name: "enqueuedTimestamp", - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ], - type: "i64", - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "FutarchyAmm", - type: { - kind: "struct", - fields: [ - { - name: "state", - type: { - defined: "PoolState", - }, - }, - { - name: "totalLiquidity", - type: "u128", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "ammBaseVault", - type: "publicKey", - }, - { - name: "ammQuoteVault", - type: "publicKey", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "lastUpdatedTimestamp", - type: "i64", - }, - { - name: "createdAtTimestamp", - type: "i64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySeconds", - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ], - type: "u32", - }, - ], - }, - }, - { - name: "Pool", - type: { - kind: "struct", - fields: [ - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "quoteReserves", - type: "u64", - }, - { - name: "baseReserves", - type: "u64", - }, - { - name: "quoteProtocolFeeBalance", - type: "u64", - }, - { - name: "baseProtocolFeeBalance", - type: "u64", - }, - ], - }, - }, - { - name: "PoolState", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - ], - }, - { - name: "Futarchy", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - { - name: "pass", - type: { - defined: "Pool", - }, - }, - { - name: "fail", - type: { - defined: "Pool", - }, - }, - ], - }, - ], - }, - }, - { - name: "Market", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - }, - { - name: "Pass", - }, - { - name: "Fail", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - { - name: "Token", - type: { - kind: "enum", - variants: [ - { - name: "Base", - }, - { - name: "Quote", - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Draft", - fields: [ - { - name: "amountStaked", - type: "u64", - }, - ], - }, - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - ], - }, - }, - ], - events: [ - { - name: "CollectFeesEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "ammBaseVault", - type: "publicKey", - index: false, - }, - { - name: "ammQuoteVault", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteFeesCollected", - type: "u64", - index: false, - }, - { - name: "baseFeesCollected", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "twapStartDelaySeconds", - type: "u32", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "twapStartDelaySeconds", - type: "u32", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - { - name: "isOptimisticGovernanceEnabled", - type: "bool", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSeconds", - type: "u32", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "StakeToProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "UnstakeFromProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "timestampEnqueued", - type: "i64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - { - name: "isTeamSponsored", - type: "bool", - index: false, - }, - ], - }, - { - name: "SpotSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ConditionalSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "trader", - type: "publicKey", - index: false, - }, - { - name: "market", - type: { - defined: "Market", - }, - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ProvideLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "positionAuthority", - type: "publicKey", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "liquidityMinted", - type: "u128", - index: false, - }, - { - name: "minLiquidity", - type: "u128", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "WithdrawLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "liquidityWithdrawn", - type: "u128", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "SponsorProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CollectMeteoraDammFeesEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "pool", - type: "publicKey", - index: false, - }, - { - name: "baseTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteFeesCollected", - type: "u64", - index: false, - }, - { - name: "baseFeesCollected", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitiateVaultSpendOptimisticProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "daoQuoteVaultAccount", - type: "publicKey", - index: false, - }, - { - name: "recipientQuoteAccount", - type: "publicKey", - index: false, - }, - { - name: "enqueuedTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "FinalizeOptimisticProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLiquidity", - msg: "More liquidity needs to be in the AMM to launch this proposal", - }, - { - code: 6011, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay", - }, - { - code: 6012, - name: "PassThresholdTooHigh", - msg: "Pass threshold must be less than 10%", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Draft status", - }, - { - code: 6015, - name: "CastingOverflow", - msg: "Casting overflow. If you're seeing this, please report this", - }, - { - code: 6016, - name: "InsufficientBalance", - msg: "Insufficient balance", - }, - { - code: 6017, - name: "ZeroLiquidityRemove", - msg: "Cannot remove zero liquidity", - }, - { - code: 6018, - name: "SwapSlippageExceeded", - msg: "Swap slippage exceeded", - }, - { - code: 6019, - name: "AssertFailed", - msg: "Assert failed", - }, - { - code: 6020, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - { - code: 6021, - name: "ProposalNotInDraftState", - msg: "Proposal is not in draft state", - }, - { - code: 6022, - name: "InsufficientTokenBalance", - msg: "Insufficient token balance", - }, - { - code: 6023, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6024, - name: "InsufficientStakeToLaunch", - msg: "Insufficient stake to launch proposal", - }, - { - code: 6025, - name: "StakerNotFound", - msg: "Staker not found in proposal", - }, - { - code: 6026, - name: "PoolNotInSpotState", - msg: "Pool must be in spot state", - }, - { - code: 6027, - name: "InvalidDaoCreateLiquidity", - msg: "If you're providing liquidity, you must provide both base and quote token accounts", - }, - { - code: 6028, - name: "InvalidStakeAccount", - msg: "Invalid stake account", - }, - { - code: 6029, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6030, - name: "ProposalNotActive", - msg: "Proposal needs to be active to perform a conditional swap", - }, - { - code: 6031, - name: "InvalidTransaction", - msg: "This Squads transaction should only contain calls to update spending limits", - }, - { - code: 6032, - name: "ProposalAlreadySponsored", - msg: "Proposal has already been sponsored", - }, - { - code: 6033, - name: "InvalidTeamSponsoredPassThreshold", - msg: "Team sponsored pass threshold must be between -10% and 10%", - }, - { - code: 6034, - name: "InvalidTargetK", - msg: "Target K must be greater than the current K", - }, - { - code: 6035, - name: "InvalidTransactionMessage", - msg: "Failed to compile transaction message for Squads vault transaction", - }, - { - code: 6036, - name: "InvalidRecipient", - msg: "Invalid recipient", - }, - { - code: 6037, - name: "OptimisticGovernanceDisabled", - msg: "Optimistic governance is disabled", - }, - { - code: 6038, - name: "ActiveOptimisticProposalAlreadyEnqueued", - msg: "An active optimistic proposal is already enqueued", - }, - { - code: 6039, - name: "NoActiveOptimisticProposal", - msg: "No active optimistic proposal", - }, - { - code: 6040, - name: "OptimisticProposalAlreadyPassed", - msg: "Optimistic proposal has already passed", - }, - { - code: 6041, - name: "CannotSponsorOptimisticProposalChallenge", - msg: "Team cannot sponsor a challenge to an optimistic proposal", - }, - { - code: 6042, - name: "InvalidSpendingLimitMint", - msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", - }, - ], -}; diff --git a/sdk/src/v0.6/types/futarchy_amm.ts b/sdk/src/v0.6/types/futarchy_amm.ts deleted file mode 100644 index c1aef0d19..000000000 --- a/sdk/src/v0.6/types/futarchy_amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type FutarchyAmm = { - version: "0.4.1"; - name: "futarchy_amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: FutarchyAmm = { - version: "0.4.1", - name: "futarchy_amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk/src/v0.6/types/index.ts b/sdk/src/v0.6/types/index.ts deleted file mode 100644 index f00207d02..000000000 --- a/sdk/src/v0.6/types/index.ts +++ /dev/null @@ -1,248 +0,0 @@ -import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; -export { AmmProgram, AmmIDL }; - -import { - Launchpad as LaunchpadProgram, - IDL as LaunchpadIDL, -} from "./launchpad.js"; -export { LaunchpadProgram, LaunchpadIDL }; - -import { - Launchpad as v0_6_0_Launchpad, - IDL as v0_6_0_LaunchpadIDL, -} from "./v0.6.0-launchpad.js"; -export { v0_6_0_Launchpad, v0_6_0_LaunchpadIDL }; - -import { - ConditionalVault as ConditionalVaultProgram, - IDL as ConditionalVaultIDL, -} from "./conditional_vault.js"; -export { ConditionalVaultProgram, ConditionalVaultIDL }; - -import { Futarchy as FutarchyProgram, IDL as FutarchyIDL } from "./futarchy.js"; -export { FutarchyProgram, FutarchyIDL }; - -import { - Futarchy as v0_6_0_Futarchy, - IDL as v0_6_0_FutarchyIDL, -} from "./v0.6.0-futarchy.js"; -export { v0_6_0_Futarchy, v0_6_0_FutarchyIDL }; - -import { - PriceBasedPerformancePackage as PriceBasedPerformancePackageProgram, - IDL as PriceBasedPerformancePackageIDL, -} from "./price_based_performance_package.js"; -export { PriceBasedPerformancePackageProgram, PriceBasedPerformancePackageIDL }; - -export { LowercaseKeys } from "./utils.js"; - -import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; - -export type Question = IdlAccounts["question"]; -export type ConditionalVault = - IdlAccounts["conditionalVault"]; - -export type InitializeDaoParams = - IdlTypes["InitializeDaoParams"]; -export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; -export type InitializePerformancePackageParams = - IdlTypes["InitializePerformancePackageParams"]; - -export type Dao = IdlAccounts["dao"]; -export type Proposal = IdlAccounts["proposal"]; -export type Amm = IdlAccounts["amm"]; -export type Launch = IdlAccounts["launch"]; -export type FundingRecord = IdlAccounts["fundingRecord"]; -export type PerformancePackage = - IdlAccounts["performancePackage"]; - -export type OracleConfig = - IdlTypes["OracleConfig"]; -export type Tranche = IdlTypes["Tranche"]; - -// export type OracleConfig = IdlTypes["OracleConfig"]; -// export type SharedLiquidityPool = -// IdlAccounts["sharedLiquidityPool"]; -// export type SharedLiquidityPoolPosition = -// IdlAccounts["liquidityPosition"]; - -export type SwapEvent = IdlEvents["SwapEvent"]; -export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; -export type RemoveLiquidityEvent = - IdlEvents["RemoveLiquidityEvent"]; -export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; -export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; -export type AmmEvent = - | SwapEvent - | AddLiquidityEvent - | RemoveLiquidityEvent - | CreateAmmEvent - | CrankThatTwapEvent; - -export type AddMetadataToConditionalTokensEvent = - IdlEvents["AddMetadataToConditionalTokensEvent"]; -export type InitializeConditionalVaultEvent = - IdlEvents["InitializeConditionalVaultEvent"]; -export type InitializeQuestionEvent = - IdlEvents["InitializeQuestionEvent"]; -export type MergeTokensEvent = - IdlEvents["MergeTokensEvent"]; -export type RedeemTokensEvent = - IdlEvents["RedeemTokensEvent"]; -export type ResolveQuestionEvent = - IdlEvents["ResolveQuestionEvent"]; -export type SplitTokensEvent = - IdlEvents["SplitTokensEvent"]; -export type ConditionalVaultEvent = - | AddMetadataToConditionalTokensEvent - | InitializeConditionalVaultEvent - | InitializeQuestionEvent - | MergeTokensEvent - | RedeemTokensEvent - | ResolveQuestionEvent - | SplitTokensEvent; - -export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; -export type LaunchCompletedEvent = - IdlEvents["LaunchCompletedEvent"]; -export type LaunchFundedEvent = - IdlEvents["LaunchFundedEvent"]; -export type LaunchInitializedEvent = - IdlEvents["LaunchInitializedEvent"]; -export type LaunchRefundedEvent = - IdlEvents["LaunchRefundedEvent"]; -export type LaunchStartedEvent = - IdlEvents["LaunchStartedEvent"]; -export type LaunchCloseEvent = IdlEvents["LaunchCloseEvent"]; -export type LaunchpadEvent = - | LaunchClaimEvent - | LaunchCompletedEvent - | LaunchFundedEvent - | LaunchInitializedEvent - | LaunchRefundedEvent - | LaunchStartedEvent - | LaunchCloseEvent; - -export type v0_6_0_LaunchClaimEvent = - IdlEvents["LaunchClaimEvent"]; -export type v0_6_0_LaunchCompletedEvent = - IdlEvents["LaunchCompletedEvent"]; -export type v0_6_0_LaunchFundedEvent = - IdlEvents["LaunchFundedEvent"]; -export type v0_6_0_LaunchInitializedEvent = - IdlEvents["LaunchInitializedEvent"]; -export type v0_6_0_LaunchRefundedEvent = - IdlEvents["LaunchRefundedEvent"]; -export type v0_6_0_LaunchStartedEvent = - IdlEvents["LaunchStartedEvent"]; -export type v0_6_0_LaunchCloseEvent = - IdlEvents["LaunchCloseEvent"]; -export type v0_6_0_LaunchpadEvent = - | v0_6_0_LaunchClaimEvent - | v0_6_0_LaunchCompletedEvent - | v0_6_0_LaunchFundedEvent - | v0_6_0_LaunchInitializedEvent - | v0_6_0_LaunchRefundedEvent - | v0_6_0_LaunchStartedEvent - | v0_6_0_LaunchCloseEvent; - -export type CollectFeesEvent = IdlEvents["CollectFeesEvent"]; -export type InitializeDaoEvent = - IdlEvents["InitializeDaoEvent"]; -export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; -export type InitializeProposalEvent = - IdlEvents["InitializeProposalEvent"]; -export type StakeToProposalEvent = - IdlEvents["StakeToProposalEvent"]; -export type UnstakeFromProposalEvent = - IdlEvents["UnstakeFromProposalEvent"]; -export type LaunchProposalEvent = - IdlEvents["LaunchProposalEvent"]; -export type FinalizeProposalEvent = - IdlEvents["FinalizeProposalEvent"]; -export type SpotSwapEvent = IdlEvents["SpotSwapEvent"]; -export type ConditionalSwapEvent = - IdlEvents["ConditionalSwapEvent"]; -export type ProvideLiquidityEvent = - IdlEvents["ProvideLiquidityEvent"]; -export type WithdrawLiquidityEvent = - IdlEvents["WithdrawLiquidityEvent"]; -export type SponsorProposalEvent = - IdlEvents["SponsorProposalEvent"]; -export type InitiateVaultSpendOptimisticProposalEvent = - IdlEvents["InitiateVaultSpendOptimisticProposalEvent"]; -export type FinalizeOptimisticProposalEvent = - IdlEvents["FinalizeOptimisticProposalEvent"]; -export type FutarchyEvent = - | CollectFeesEvent - | InitializeDaoEvent - | UpdateDaoEvent - | InitializeProposalEvent - | StakeToProposalEvent - | UnstakeFromProposalEvent - | LaunchProposalEvent - | FinalizeProposalEvent - | SpotSwapEvent - | ConditionalSwapEvent - | ProvideLiquidityEvent - | WithdrawLiquidityEvent - | SponsorProposalEvent - | InitiateVaultSpendOptimisticProposalEvent - | FinalizeOptimisticProposalEvent; - -export type v0_6_0_CollectFeesEvent = - IdlEvents["CollectFeesEvent"]; -export type v0_6_0_InitializeDaoEvent = - IdlEvents["InitializeDaoEvent"]; -export type v0_6_0_UpdateDaoEvent = - IdlEvents["UpdateDaoEvent"]; -export type v0_6_0_InitializeProposalEvent = - IdlEvents["InitializeProposalEvent"]; -export type v0_6_0_StakeToProposalEvent = - IdlEvents["StakeToProposalEvent"]; -export type v0_6_0_UnstakeFromProposalEvent = - IdlEvents["UnstakeFromProposalEvent"]; -export type v0_6_0_LaunchProposalEvent = - IdlEvents["LaunchProposalEvent"]; -export type v0_6_0_FinalizeProposalEvent = - IdlEvents["FinalizeProposalEvent"]; -export type v0_6_0_SpotSwapEvent = IdlEvents["SpotSwapEvent"]; -export type v0_6_0_ConditionalSwapEvent = - IdlEvents["ConditionalSwapEvent"]; -export type v0_6_0_ProvideLiquidityEvent = - IdlEvents["ProvideLiquidityEvent"]; -export type v0_6_0_WithdrawLiquidityEvent = - IdlEvents["WithdrawLiquidityEvent"]; -export type v0_6_0_FutarchyEvent = - | v0_6_0_CollectFeesEvent - | v0_6_0_InitializeDaoEvent - | v0_6_0_UpdateDaoEvent - | v0_6_0_InitializeProposalEvent - | v0_6_0_StakeToProposalEvent - | v0_6_0_UnstakeFromProposalEvent - | v0_6_0_LaunchProposalEvent - | v0_6_0_FinalizeProposalEvent - | v0_6_0_SpotSwapEvent - | v0_6_0_ConditionalSwapEvent - | v0_6_0_ProvideLiquidityEvent - | v0_6_0_WithdrawLiquidityEvent; - -export type PerformancePackageInitializedEvent = - IdlEvents["PerformancePackageInitialized"]; -export type UnlockStartedEvent = - IdlEvents["UnlockStarted"]; -export type UnlockCompletedEvent = - IdlEvents["UnlockCompleted"]; -export type ChangeProposedEvent = - IdlEvents["ChangeProposed"]; -export type ChangeExecutedEvent = - IdlEvents["ChangeExecuted"]; -export type PerformancePackageAuthorityChangedEvent = - IdlEvents["PerformancePackageAuthorityChanged"]; -export type PriceBasedPerformancePackageEvent = - | PerformancePackageInitializedEvent - | UnlockStartedEvent - | UnlockCompletedEvent - | ChangeProposedEvent - | ChangeExecutedEvent - | PerformancePackageAuthorityChangedEvent; diff --git a/sdk/src/v0.6/types/launchpad.ts b/sdk/src/v0.6/types/launchpad.ts deleted file mode 100644 index bbfbca5a7..000000000 --- a/sdk/src/v0.6/types/launchpad.ts +++ /dev/null @@ -1,2813 +0,0 @@ -export type Launchpad = { - version: "0.6.1"; - name: "launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CompleteLaunchArgs"; - }; - }, - ]; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "returnFunds"; - accounts: [ - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "recipientQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ReturnFundsArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "finalRaiseAmount"; - docs: ["The final raise amount."]; - type: { - option: "u64"; - }; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "CompleteLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "finalRaiseAmount"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ReturnFundsArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - index: false; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - index: false; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "finalRaiseAmount"; - type: { - option: "u64"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchFundsReturnedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "usdcReturned"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6012; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6013; - name: "InvalidPriceBasedPremineAmount"; - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; - }, - { - code: 6014; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; - }, - { - code: 6015; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6016; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be greater than or equal to the minimum raise amount"; - }, - { - code: 6017; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6018; - name: "MoneyAlreadyRefunded"; - msg: "Money already refunded"; - }, - { - code: 6019; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6020; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6021; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; - }, - { - code: 6022; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - ]; -}; - -export const IDL: Launchpad = { - version: "0.6.1", - name: "launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CompleteLaunchArgs", - }, - }, - ], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "returnFunds", - accounts: [ - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "recipientQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ReturnFundsArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "finalRaiseAmount", - docs: ["The final raise amount."], - type: { - option: "u64", - }, - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "CompleteLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "finalRaiseAmount", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "ReturnFundsArgs", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "performancePackageGrantee", - type: "publicKey", - index: false, - }, - { - name: "performancePackageTokenAmount", - type: "u64", - index: false, - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - index: false, - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - index: false, - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "finalRaiseAmount", - type: { - option: "u64", - }, - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - { - name: "LaunchFundsReturnedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "usdcReturned", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6012, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6013, - name: "InvalidPriceBasedPremineAmount", - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", - }, - { - code: 6014, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", - }, - { - code: 6015, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6016, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be greater than or equal to the minimum raise amount", - }, - { - code: 6017, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6018, - name: "MoneyAlreadyRefunded", - msg: "Money already refunded", - }, - { - code: 6019, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6020, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6021, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", - }, - { - code: 6022, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - ], -}; diff --git a/sdk/src/v0.6/types/launchpad_v7.ts b/sdk/src/v0.6/types/launchpad_v7.ts deleted file mode 100644 index 64f065a02..000000000 --- a/sdk/src/v0.6/types/launchpad_v7.ts +++ /dev/null @@ -1,3053 +0,0 @@ -export type LaunchpadV7 = { - version: "0.7.0"; - name: "launchpad_v7"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - isOptional: true; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "setFundingRecordApproval"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "approvedAmount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claimAdditionalTokenAllocation"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipientTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - { - name: "approvedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - { - name: "totalApprovedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ]; - type: "u64"; - }, - { - name: "additionalTokensAmount"; - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ]; - type: "u64"; - }, - { - name: "additionalTokensRecipient"; - docs: [ - "The token account that will receive the additional tokens.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "additionalTokensClaimed"; - docs: ["Are the additional tokens claimed"]; - type: "bool"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - index: false; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - index: false; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "FundingRecordApprovalSetEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "approvedAmount"; - type: "u64"; - index: false; - }, - { - name: "totalApproved"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "totalApprovedAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - index: false; - }, - { - name: "additionalTokensRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6012; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6013; - name: "InvalidPriceBasedPremineAmount"; - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; - }, - { - code: 6014; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; - }, - { - code: 6015; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6016; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be greater than or equal to the minimum raise amount"; - }, - { - code: 6017; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6018; - name: "MoneyAlreadyRefunded"; - msg: "Money already refunded"; - }, - { - code: 6019; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6020; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6021; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; - }, - { - code: 6022; - name: "FinalRaiseAmountAlreadySet"; - msg: "The final raise amount has already been set"; - }, - { - code: 6023; - name: "TotalApprovedAmountTooLow"; - msg: "Total approved amount must be greater than or equal to the minimum raise amount"; - }, - { - code: 6024; - name: "InvalidAdditionalTokensRecipient"; - msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0"; - }, - { - code: 6025; - name: "NoAdditionalTokensRecipientSet"; - msg: "No additional tokens recipient set"; - }, - { - code: 6026; - name: "AdditionalTokensAlreadyClaimed"; - msg: "Additional tokens already claimed"; - }, - ]; -}; - -export const IDL: LaunchpadV7 = { - version: "0.7.0", - name: "launchpad_v7", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - isOptional: true, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "setFundingRecordApproval", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "approvedAmount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claimAdditionalTokenAllocation", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipientTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - { - name: "approvedAmount", - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - { - name: "totalApprovedAmount", - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ], - type: "u64", - }, - { - name: "additionalTokensAmount", - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ], - type: "u64", - }, - { - name: "additionalTokensRecipient", - docs: [ - "The token account that will receive the additional tokens.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "additionalTokensClaimed", - docs: ["Are the additional tokens claimed"], - type: "bool", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - { - name: "teamAddress", - type: "publicKey", - }, - { - name: "additionalTokensAmount", - type: "u64", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "performancePackageGrantee", - type: "publicKey", - index: false, - }, - { - name: "performancePackageTokenAmount", - type: "u64", - index: false, - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - index: false, - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - index: false, - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - ], - }, - { - name: "FundingRecordApprovalSetEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "approvedAmount", - type: "u64", - index: false, - }, - { - name: "totalApproved", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "totalApprovedAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "additionalTokensAmount", - type: "u64", - index: false, - }, - { - name: "additionalTokensRecipient", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6012, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6013, - name: "InvalidPriceBasedPremineAmount", - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", - }, - { - code: 6014, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", - }, - { - code: 6015, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6016, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be greater than or equal to the minimum raise amount", - }, - { - code: 6017, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6018, - name: "MoneyAlreadyRefunded", - msg: "Money already refunded", - }, - { - code: 6019, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6020, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6021, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", - }, - { - code: 6022, - name: "FinalRaiseAmountAlreadySet", - msg: "The final raise amount has already been set", - }, - { - code: 6023, - name: "TotalApprovedAmountTooLow", - msg: "Total approved amount must be greater than or equal to the minimum raise amount", - }, - { - code: 6024, - name: "InvalidAdditionalTokensRecipient", - msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0", - }, - { - code: 6025, - name: "NoAdditionalTokensRecipientSet", - msg: "No additional tokens recipient set", - }, - { - code: 6026, - name: "AdditionalTokensAlreadyClaimed", - msg: "Additional tokens already claimed", - }, - ], -}; diff --git a/sdk/src/v0.6/types/optimistic_timelock.ts b/sdk/src/v0.6/types/optimistic_timelock.ts deleted file mode 100644 index fa1f43135..000000000 --- a/sdk/src/v0.6/types/optimistic_timelock.ts +++ /dev/null @@ -1,1023 +0,0 @@ -export type OptimisticTimelock = { - version: "0.3.0"; - name: "optimistic_timelock"; - instructions: [ - { - name: "createTimelock"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: true; - isSigner: true; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "enqueuers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "enqueuerCooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setDelayInSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "delayInSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setAuthority"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - ]; - }, - { - name: "setOptimisticProposerCooldownSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "cooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "addOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "enqueuer"; - type: "publicKey"; - }, - ]; - }, - { - name: "removeOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "optimisticProposer"; - type: "publicKey"; - }, - ]; - }, - { - name: "createTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "addTransaction"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }, - { - name: "sealTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "enqueueTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeTransactionBatch"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "timelock"; - type: { - kind: "struct"; - fields: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "signerBump"; - type: "u8"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "optimisticProposers"; - type: { - vec: { - defined: "OptimisticProposer"; - }; - }; - }, - { - name: "optimisticProposerCooldownSlots"; - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "transactionBatch"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "TransactionBatchStatus"; - }; - }, - { - name: "transactions"; - type: { - vec: { - defined: "Transaction"; - }; - }; - }, - { - name: "timelock"; - type: "publicKey"; - }, - { - name: "enqueuedSlot"; - type: "u64"; - }, - { - name: "transactionBatchAuthority"; - type: "publicKey"; - }, - { - name: "enqueuerType"; - type: { - defined: "AuthorityType"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "OptimisticProposer"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "lastSlotEnqueued"; - type: "u64"; - }, - ]; - }; - }, - { - name: "Transaction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - { - name: "didExecute"; - type: "bool"; - }, - ]; - }; - }, - { - name: "TransactionAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "AuthorityType"; - type: { - kind: "enum"; - variants: [ - { - name: "OptimisticProposer"; - }, - { - name: "TimelockAuthority"; - }, - ]; - }; - }, - { - name: "TransactionBatchStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Created"; - }, - { - name: "Sealed"; - }, - { - name: "Enqueued"; - }, - { - name: "Cancelled"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NotReady"; - msg: "This transaction is not yet ready to be executed"; - }, - { - code: 6001; - name: "CannotAddTransactions"; - msg: "Can only add instructions when transaction batch status is `Created`"; - }, - { - code: 6002; - name: "CannotSealTransactionBatch"; - msg: "Can only seal the transaction batch when status is `Created`"; - }, - { - code: 6003; - name: "CannotEnqueueTransactionBatch"; - msg: "Can only enqueue the timelock running once the status is `Sealed`"; - }, - { - code: 6004; - name: "CannotCancelTimelock"; - msg: "Can only cancel the transactions if the status `Enqueued`"; - }, - { - code: 6005; - name: "CanOnlyCancelDuringTimelockPeriod"; - msg: "Can only cancel the transactions during the timelock period"; - }, - { - code: 6006; - name: "CannotExecuteTransactions"; - msg: "Can only execute the transactions if the status is `Enqueued`"; - }, - { - code: 6007; - name: "NoAuthority"; - msg: "The signer is neither the timelock authority nor an optimistic proposer"; - }, - { - code: 6008; - name: "InsufficientPermissions"; - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority"; - }, - { - code: 6009; - name: "OptimisticProposerCooldown"; - msg: "This optimistic proposer is still in its cooldown period"; - }, - ]; -}; - -export const IDL: OptimisticTimelock = { - version: "0.3.0", - name: "optimistic_timelock", - instructions: [ - { - name: "createTimelock", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: true, - isSigner: true, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "enqueuers", - type: { - vec: "publicKey", - }, - }, - { - name: "enqueuerCooldownSlots", - type: "u64", - }, - ], - }, - { - name: "setDelayInSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "delayInSlots", - type: "u64", - }, - ], - }, - { - name: "setAuthority", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - ], - }, - { - name: "setOptimisticProposerCooldownSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "cooldownSlots", - type: "u64", - }, - ], - }, - { - name: "addOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "enqueuer", - type: "publicKey", - }, - ], - }, - { - name: "removeOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "optimisticProposer", - type: "publicKey", - }, - ], - }, - { - name: "createTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: true, - }, - ], - args: [], - }, - { - name: "addTransaction", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - { - name: "sealTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "enqueueTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeTransactionBatch", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "timelock", - type: { - kind: "struct", - fields: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "signerBump", - type: "u8", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "optimisticProposers", - type: { - vec: { - defined: "OptimisticProposer", - }, - }, - }, - { - name: "optimisticProposerCooldownSlots", - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "transactionBatch", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "TransactionBatchStatus", - }, - }, - { - name: "transactions", - type: { - vec: { - defined: "Transaction", - }, - }, - }, - { - name: "timelock", - type: "publicKey", - }, - { - name: "enqueuedSlot", - type: "u64", - }, - { - name: "transactionBatchAuthority", - type: "publicKey", - }, - { - name: "enqueuerType", - type: { - defined: "AuthorityType", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "OptimisticProposer", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "lastSlotEnqueued", - type: "u64", - }, - ], - }, - }, - { - name: "Transaction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - { - name: "didExecute", - type: "bool", - }, - ], - }, - }, - { - name: "TransactionAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "AuthorityType", - type: { - kind: "enum", - variants: [ - { - name: "OptimisticProposer", - }, - { - name: "TimelockAuthority", - }, - ], - }, - }, - { - name: "TransactionBatchStatus", - type: { - kind: "enum", - variants: [ - { - name: "Created", - }, - { - name: "Sealed", - }, - { - name: "Enqueued", - }, - { - name: "Cancelled", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NotReady", - msg: "This transaction is not yet ready to be executed", - }, - { - code: 6001, - name: "CannotAddTransactions", - msg: "Can only add instructions when transaction batch status is `Created`", - }, - { - code: 6002, - name: "CannotSealTransactionBatch", - msg: "Can only seal the transaction batch when status is `Created`", - }, - { - code: 6003, - name: "CannotEnqueueTransactionBatch", - msg: "Can only enqueue the timelock running once the status is `Sealed`", - }, - { - code: 6004, - name: "CannotCancelTimelock", - msg: "Can only cancel the transactions if the status `Enqueued`", - }, - { - code: 6005, - name: "CanOnlyCancelDuringTimelockPeriod", - msg: "Can only cancel the transactions during the timelock period", - }, - { - code: 6006, - name: "CannotExecuteTransactions", - msg: "Can only execute the transactions if the status is `Enqueued`", - }, - { - code: 6007, - name: "NoAuthority", - msg: "The signer is neither the timelock authority nor an optimistic proposer", - }, - { - code: 6008, - name: "InsufficientPermissions", - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority", - }, - { - code: 6009, - name: "OptimisticProposerCooldown", - msg: "This optimistic proposer is still in its cooldown period", - }, - ], -}; diff --git a/sdk/src/v0.6/types/price_based_performance_package.ts b/sdk/src/v0.6/types/price_based_performance_package.ts deleted file mode 100644 index e72df8588..000000000 --- a/sdk/src/v0.6/types/price_based_performance_package.ts +++ /dev/null @@ -1,1893 +0,0 @@ -export type PriceBasedPerformancePackage = { - version: "0.6.0"; - name: "price_based_performance_package"; - constants: [ - { - name: "MAX_TRANCHES"; - type: { - defined: "usize"; - }; - value: "10"; - }, - ]; - instructions: [ - { - name: "initializePerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "grantorTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "grantor"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializePerformancePackageParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: true; - docs: ["Only the token recipient can start unlock"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The token mint - validated via has_one constraint on locker"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ]; - }, - { - name: "tokenRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Payer for creating the ATA if needed"]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "proposeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProposeChangeParams"; - }; - }, - ]; - }, - { - name: "executeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "executor"; - isMut: true; - isSigner: true; - docs: [ - "The party executing the change (must be opposite of proposer)", - ]; - }, - ]; - args: []; - }, - { - name: "changePerformancePackageAuthority"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "currentAuthority"; - isMut: false; - isSigner: true; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ChangePerformancePackageAuthorityParams"; - }; - }, - ]; - }, - { - name: "burnPerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "spillAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "performancePackage"; - type: { - kind: "struct"; - fields: [ - { - name: "tranches"; - docs: ["The tranches that make up the performance package"]; - type: { - vec: { - defined: "StoredTranche"; - }; - }; - }, - { - name: "totalTokenAmount"; - docs: ["Total amount of tokens in the performance package"]; - type: "u64"; - }, - { - name: "alreadyUnlockedAmount"; - docs: ["Amount of tokens already unlocked"]; - type: "u64"; - }, - { - name: "minUnlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: [ - "Length of time in seconds for TWAP calculation, between 1 day and 1 year", - ]; - type: "u32"; - }, - { - name: "recipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "PerformancePackageState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - { - name: "performancePackageAuthority"; - docs: [ - "The authorized locker authority that can execute changes, usually the organization", - ]; - type: "publicKey"; - }, - { - name: "tokenMint"; - docs: ["The mint of the locked tokens"]; - type: "publicKey"; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of the performance package, used for indexing events", - ]; - type: "u64"; - }, - { - name: "performancePackageTokenVault"; - docs: ["The vault that stores the tokens"]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "changeRequest"; - type: { - kind: "struct"; - fields: [ - { - name: "performancePackage"; - docs: ["The performance package this change applies to"]; - type: "publicKey"; - }, - { - name: "changeType"; - docs: ["What is being changed"]; - type: { - defined: "ChangeType"; - }; - }, - { - name: "proposedAt"; - docs: ["When the change was proposed"]; - type: "i64"; - }, - { - name: "proposerType"; - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ]; - type: { - defined: "ProposerType"; - }; - }, - { - name: "pdaNonce"; - docs: ["Used to derive the PDA along with the proposer"]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "performancePackageSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ChangePerformancePackageAuthorityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "newPerformancePackageAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitializePerformancePackageParams"; - type: { - kind: "struct"; - fields: [ - { - name: "tranches"; - type: { - vec: { - defined: "Tranche"; - }; - }; - }, - { - name: "minUnlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u32"; - }, - { - name: "grantee"; - type: "publicKey"; - }, - { - name: "performancePackageAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ProposeChangeParams"; - type: { - kind: "struct"; - fields: [ - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - }, - { - name: "pdaNonce"; - type: "u32"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "Tranche"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: ["The price at which this tranch unlocks"]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens in this tranch"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "StoredTranche"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "isUnlocked"; - type: "bool"; - }, - ]; - }; - }, - { - name: "PerformancePackageState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - { - name: "Unlocked"; - }, - ]; - }; - }, - { - name: "ChangeType"; - type: { - kind: "enum"; - variants: [ - { - name: "Oracle"; - fields: [ - { - name: "newOracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - ]; - }, - { - name: "Recipient"; - fields: [ - { - name: "newRecipient"; - type: "publicKey"; - }, - ]; - }, - ]; - }; - }, - { - name: "ProposerType"; - type: { - kind: "enum"; - variants: [ - { - name: "Recipient"; - }, - { - name: "Authority"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "PerformancePackageInitialized"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "ChangeProposed"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - ]; - }, - { - name: "ChangeExecuted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "executor"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - ]; - }, - { - name: "PerformancePackageAuthorityChanged"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "UnlockTimestampInThePast"; - msg: "Unlock timestamp must be in the future"; - }, - { - code: 6002; - name: "InvalidPerformancePackageState"; - msg: "Performance package is not in the expected state"; - }, - { - code: 6003; - name: "TwapPeriodNotElapsed"; - msg: "TWAP calculation failed"; - }, - { - code: 6004; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6005; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - { - code: 6006; - name: "UnauthorizedChangeRequest"; - msg: "Unauthorized to create or execute change request"; - }, - { - code: 6007; - name: "InvalidChangeRequest"; - msg: "Change request does not match locker"; - }, - { - code: 6008; - name: "UnauthorizedLockerAuthority"; - msg: "Unauthorized locker authority"; - }, - { - code: 6009; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6010; - name: "TranchePriceThresholdsNotMonotonic"; - msg: "Tranche price thresholds must be monotonically increasing"; - }, - { - code: 6011; - name: "TrancheTokenAmountZero"; - msg: "Tranche token amount must be greater than 0"; - }, - { - code: 6012; - name: "InvalidTwapLength"; - msg: "TWAP length must be greater than or equal to 1 day and less than 1 year"; - }, - { - code: 6013; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - ]; -}; - -export const IDL: PriceBasedPerformancePackage = { - version: "0.6.0", - name: "price_based_performance_package", - constants: [ - { - name: "MAX_TRANCHES", - type: { - defined: "usize", - }, - value: "10", - }, - ], - instructions: [ - { - name: "initializePerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "grantorTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "grantor", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializePerformancePackageParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: true, - docs: ["Only the token recipient can start unlock"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The token mint - validated via has_one constraint on locker"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ], - }, - { - name: "tokenRecipient", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Payer for creating the ATA if needed"], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "proposeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProposeChangeParams", - }, - }, - ], - }, - { - name: "executeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "executor", - isMut: true, - isSigner: true, - docs: [ - "The party executing the change (must be opposite of proposer)", - ], - }, - ], - args: [], - }, - { - name: "changePerformancePackageAuthority", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "currentAuthority", - isMut: false, - isSigner: true, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ChangePerformancePackageAuthorityParams", - }, - }, - ], - }, - { - name: "burnPerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "spillAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "performancePackage", - type: { - kind: "struct", - fields: [ - { - name: "tranches", - docs: ["The tranches that make up the performance package"], - type: { - vec: { - defined: "StoredTranche", - }, - }, - }, - { - name: "totalTokenAmount", - docs: ["Total amount of tokens in the performance package"], - type: "u64", - }, - { - name: "alreadyUnlockedAmount", - docs: ["Amount of tokens already unlocked"], - type: "u64", - }, - { - name: "minUnlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: [ - "Length of time in seconds for TWAP calculation, between 1 day and 1 year", - ], - type: "u32", - }, - { - name: "recipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "PerformancePackageState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - { - name: "performancePackageAuthority", - docs: [ - "The authorized locker authority that can execute changes, usually the organization", - ], - type: "publicKey", - }, - { - name: "tokenMint", - docs: ["The mint of the locked tokens"], - type: "publicKey", - }, - { - name: "seqNum", - docs: [ - "The sequence number of the performance package, used for indexing events", - ], - type: "u64", - }, - { - name: "performancePackageTokenVault", - docs: ["The vault that stores the tokens"], - type: "publicKey", - }, - ], - }, - }, - { - name: "changeRequest", - type: { - kind: "struct", - fields: [ - { - name: "performancePackage", - docs: ["The performance package this change applies to"], - type: "publicKey", - }, - { - name: "changeType", - docs: ["What is being changed"], - type: { - defined: "ChangeType", - }, - }, - { - name: "proposedAt", - docs: ["When the change was proposed"], - type: "i64", - }, - { - name: "proposerType", - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ], - type: { - defined: "ProposerType", - }, - }, - { - name: "pdaNonce", - docs: ["Used to derive the PDA along with the proposer"], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "performancePackageSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ChangePerformancePackageAuthorityParams", - type: { - kind: "struct", - fields: [ - { - name: "newPerformancePackageAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitializePerformancePackageParams", - type: { - kind: "struct", - fields: [ - { - name: "tranches", - type: { - vec: { - defined: "Tranche", - }, - }, - }, - { - name: "minUnlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u32", - }, - { - name: "grantee", - type: "publicKey", - }, - { - name: "performancePackageAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "ProposeChangeParams", - type: { - kind: "struct", - fields: [ - { - name: "changeType", - type: { - defined: "ChangeType", - }, - }, - { - name: "pdaNonce", - type: "u32", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "Tranche", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: ["The price at which this tranch unlocks"], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens in this tranch"], - type: "u64", - }, - ], - }, - }, - { - name: "StoredTranche", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "isUnlocked", - type: "bool", - }, - ], - }, - }, - { - name: "PerformancePackageState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - { - name: "Unlocked", - }, - ], - }, - }, - { - name: "ChangeType", - type: { - kind: "enum", - variants: [ - { - name: "Oracle", - fields: [ - { - name: "newOracleConfig", - type: { - defined: "OracleConfig", - }, - }, - ], - }, - { - name: "Recipient", - fields: [ - { - name: "newRecipient", - type: "publicKey", - }, - ], - }, - ], - }, - }, - { - name: "ProposerType", - type: { - kind: "enum", - variants: [ - { - name: "Recipient", - }, - { - name: "Authority", - }, - ], - }, - }, - ], - events: [ - { - name: "PerformancePackageInitialized", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - ], - }, - { - name: "ChangeProposed", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - ], - }, - { - name: "ChangeExecuted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "executor", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - ], - }, - { - name: "PerformancePackageAuthorityChanged", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "UnlockTimestampInThePast", - msg: "Unlock timestamp must be in the future", - }, - { - code: 6002, - name: "InvalidPerformancePackageState", - msg: "Performance package is not in the expected state", - }, - { - code: 6003, - name: "TwapPeriodNotElapsed", - msg: "TWAP calculation failed", - }, - { - code: 6004, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6005, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - { - code: 6006, - name: "UnauthorizedChangeRequest", - msg: "Unauthorized to create or execute change request", - }, - { - code: 6007, - name: "InvalidChangeRequest", - msg: "Change request does not match locker", - }, - { - code: 6008, - name: "UnauthorizedLockerAuthority", - msg: "Unauthorized locker authority", - }, - { - code: 6009, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6010, - name: "TranchePriceThresholdsNotMonotonic", - msg: "Tranche price thresholds must be monotonically increasing", - }, - { - code: 6011, - name: "TrancheTokenAmountZero", - msg: "Tranche token amount must be greater than 0", - }, - { - code: 6012, - name: "InvalidTwapLength", - msg: "TWAP length must be greater than or equal to 1 day and less than 1 year", - }, - { - code: 6013, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - ], -}; diff --git a/sdk/src/v0.6/types/price_based_token_lock.ts b/sdk/src/v0.6/types/price_based_token_lock.ts deleted file mode 100644 index 3ac0813bb..000000000 --- a/sdk/src/v0.6/types/price_based_token_lock.ts +++ /dev/null @@ -1,887 +0,0 @@ -export type PriceBasedTokenLock = { - version: "0.1.0"; - name: "price_based_token_lock"; - constants: [ - { - name: "SEED"; - type: "string"; - value: '"anchor"'; - }, - ]; - instructions: [ - { - name: "initializeLocker"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "fromTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "tokenAuthority"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "recipientTokenAccount"; - isMut: false; - isSigner: false; - docs: [ - "The recipient's token account where tokens will be sent when unlocked", - ]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeLockerParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The recipient's token account where tokens will be sent"]; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "locker"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: [ - "The price threshold that must be met for tokens to be unlocked", - ]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens locked"]; - type: "u64"; - }, - { - name: "unlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: ["Length of time in seconds for TWAP calculation"]; - type: "u64"; - }, - { - name: "tokenRecipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "InitializeLockerParams"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "unlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u64"; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "LockerState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - { - name: "Unlocked"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LockerInitialized"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "unlockTimestamp"; - type: "i64"; - index: false; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - index: false; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "InvalidLockerState"; - msg: "Locker is not in the expected state"; - }, - { - code: 6002; - name: "TwapCalculationFailed"; - msg: "TWAP calculation failed"; - }, - { - code: 6003; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6004; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - ]; -}; - -export const IDL: PriceBasedTokenLock = { - version: "0.1.0", - name: "price_based_token_lock", - constants: [ - { - name: "SEED", - type: "string", - value: '"anchor"', - }, - ], - instructions: [ - { - name: "initializeLocker", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "fromTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "tokenAuthority", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "recipientTokenAccount", - isMut: false, - isSigner: false, - docs: [ - "The recipient's token account where tokens will be sent when unlocked", - ], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeLockerParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: ["The recipient's token account where tokens will be sent"], - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "locker", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: [ - "The price threshold that must be met for tokens to be unlocked", - ], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens locked"], - type: "u64", - }, - { - name: "unlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: ["Length of time in seconds for TWAP calculation"], - type: "u64", - }, - { - name: "tokenRecipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "LockerState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "InitializeLockerParams", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "unlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u64", - }, - { - name: "tokenRecipient", - type: "publicKey", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "LockerState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - { - name: "Unlocked", - }, - ], - }, - }, - ], - events: [ - { - name: "LockerInitialized", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "unlockTimestamp", - type: "i64", - index: false, - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - index: false, - }, - { - name: "tokenRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "InvalidLockerState", - msg: "Locker is not in the expected state", - }, - { - code: 6002, - name: "TwapCalculationFailed", - msg: "TWAP calculation failed", - }, - { - code: 6003, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6004, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - ], -}; diff --git a/sdk/src/v0.6/types/price_based_unlock.ts b/sdk/src/v0.6/types/price_based_unlock.ts deleted file mode 100644 index bd6db4a3f..000000000 --- a/sdk/src/v0.6/types/price_based_unlock.ts +++ /dev/null @@ -1,1717 +0,0 @@ -export type PriceBasedUnlock = { - version: "0.1.0"; - name: "price_based_unlock"; - constants: [ - { - name: "SEED"; - type: "string"; - value: '"anchor"'; - }, - ]; - instructions: [ - { - name: "initializeLocker"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "fromTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "tokenAuthority"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeLockerParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: true; - docs: ["Only the token recipient can start unlock"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The token mint - validated via has_one constraint on locker"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ]; - }, - { - name: "tokenRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Payer for creating the ATA if needed"]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "proposeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProposeChangeParams"; - }; - }, - ]; - }, - { - name: "executeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "executor"; - isMut: true; - isSigner: true; - docs: [ - "The party executing the change (must be opposite of proposer)", - ]; - }, - ]; - args: []; - }, - { - name: "changeLockerAuthority"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "currentAuthority"; - isMut: false; - isSigner: true; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ChangeLockerAuthorityParams"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "locker"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: ["The price threshold for 100% unlocking (max price target)"]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens locked"]; - type: "u64"; - }, - { - name: "tokensAlreadyUnlocked"; - docs: ["The amount of tokens already unlocked"]; - type: "u64"; - }, - { - name: "unlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: ["Length of time in seconds for TWAP calculation"]; - type: "u64"; - }, - { - name: "tokenRecipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - { - name: "lockerAuthority"; - docs: ["The authorized locker authority that can execute changes"]; - type: "publicKey"; - }, - { - name: "tokenMint"; - docs: ["The mint of the locked tokens"]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "changeRequest"; - type: { - kind: "struct"; - fields: [ - { - name: "locker"; - docs: ["The locker this change applies to"]; - type: "publicKey"; - }, - { - name: "changeType"; - docs: ["What is being changed"]; - type: { - defined: "ChangeType"; - }; - }, - { - name: "proposedAt"; - docs: ["When the change was proposed"]; - type: "i64"; - }, - { - name: "previousState"; - docs: ["The locker state before the change was proposed"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "proposer"; - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ]; - type: "publicKey"; - }, - { - name: "pdaNonce"; - docs: ["Used to derive the PDA along with the proposer"]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "lockerSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ChangeLockerAuthorityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "newLockerAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitializeLockerParams"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "unlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u64"; - }, - { - name: "beneficiary"; - type: "publicKey"; - }, - { - name: "lockerAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ProposeChangeParams"; - type: { - kind: "struct"; - fields: [ - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - }, - { - name: "pdaNonce"; - type: "u32"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "LockerState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - { - name: "Unlocked"; - }, - ]; - }; - }, - { - name: "ChangeType"; - type: { - kind: "enum"; - variants: [ - { - name: "Oracle"; - fields: [ - { - name: "newOracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - ]; - }, - { - name: "Recipient"; - fields: [ - { - name: "newRecipient"; - type: "publicKey"; - }, - ]; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LockerInitialized"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "unlockTimestamp"; - type: "i64"; - index: false; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - index: false; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "TokensClaimed"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "tokensAlreadyUnlocked"; - type: "u64"; - index: false; - }, - { - name: "totalTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "currentPrice"; - type: "u128"; - index: false; - }, - { - name: "unlockPercentage"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "ChangeProposed"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - { - name: "proposedAt"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "ChangeExecuted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "executor"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - { - name: "executedAt"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "LockerAuthorityChanged"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "changedAt"; - type: "i64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "UnlockTimestampInThePast"; - msg: "Unlock timestamp must be in the future"; - }, - { - code: 6002; - name: "InvalidLockerState"; - msg: "Locker is not in the expected state"; - }, - { - code: 6003; - name: "TwapCalculationFailed"; - msg: "TWAP calculation failed"; - }, - { - code: 6004; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6005; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - { - code: 6006; - name: "UnauthorizedChangeRequest"; - msg: "Unauthorized to create or execute change request"; - }, - { - code: 6007; - name: "InvalidChangeRequest"; - msg: "Change request does not match locker"; - }, - { - code: 6008; - name: "UnauthorizedLockerAuthority"; - msg: "Unauthorized locker authority"; - }, - { - code: 6009; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - ]; -}; - -export const IDL: PriceBasedUnlock = { - version: "0.1.0", - name: "price_based_unlock", - constants: [ - { - name: "SEED", - type: "string", - value: '"anchor"', - }, - ], - instructions: [ - { - name: "initializeLocker", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "fromTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "tokenAuthority", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeLockerParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: true, - docs: ["Only the token recipient can start unlock"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The token mint - validated via has_one constraint on locker"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ], - }, - { - name: "tokenRecipient", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Payer for creating the ATA if needed"], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "proposeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProposeChangeParams", - }, - }, - ], - }, - { - name: "executeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "executor", - isMut: true, - isSigner: true, - docs: [ - "The party executing the change (must be opposite of proposer)", - ], - }, - ], - args: [], - }, - { - name: "changeLockerAuthority", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "currentAuthority", - isMut: false, - isSigner: true, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ChangeLockerAuthorityParams", - }, - }, - ], - }, - ], - accounts: [ - { - name: "locker", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: ["The price threshold for 100% unlocking (max price target)"], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens locked"], - type: "u64", - }, - { - name: "tokensAlreadyUnlocked", - docs: ["The amount of tokens already unlocked"], - type: "u64", - }, - { - name: "unlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: ["Length of time in seconds for TWAP calculation"], - type: "u64", - }, - { - name: "tokenRecipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "LockerState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - { - name: "lockerAuthority", - docs: ["The authorized locker authority that can execute changes"], - type: "publicKey", - }, - { - name: "tokenMint", - docs: ["The mint of the locked tokens"], - type: "publicKey", - }, - ], - }, - }, - { - name: "changeRequest", - type: { - kind: "struct", - fields: [ - { - name: "locker", - docs: ["The locker this change applies to"], - type: "publicKey", - }, - { - name: "changeType", - docs: ["What is being changed"], - type: { - defined: "ChangeType", - }, - }, - { - name: "proposedAt", - docs: ["When the change was proposed"], - type: "i64", - }, - { - name: "previousState", - docs: ["The locker state before the change was proposed"], - type: { - defined: "LockerState", - }, - }, - { - name: "proposer", - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ], - type: "publicKey", - }, - { - name: "pdaNonce", - docs: ["Used to derive the PDA along with the proposer"], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "lockerSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ChangeLockerAuthorityParams", - type: { - kind: "struct", - fields: [ - { - name: "newLockerAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitializeLockerParams", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "unlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u64", - }, - { - name: "beneficiary", - type: "publicKey", - }, - { - name: "lockerAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "ProposeChangeParams", - type: { - kind: "struct", - fields: [ - { - name: "changeType", - type: { - defined: "ChangeType", - }, - }, - { - name: "pdaNonce", - type: "u32", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "LockerState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - { - name: "Unlocked", - }, - ], - }, - }, - { - name: "ChangeType", - type: { - kind: "enum", - variants: [ - { - name: "Oracle", - fields: [ - { - name: "newOracleConfig", - type: { - defined: "OracleConfig", - }, - }, - ], - }, - { - name: "Recipient", - fields: [ - { - name: "newRecipient", - type: "publicKey", - }, - ], - }, - ], - }, - }, - ], - events: [ - { - name: "LockerInitialized", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "unlockTimestamp", - type: "i64", - index: false, - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - index: false, - }, - { - name: "tokenRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - ], - }, - { - name: "TokensClaimed", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "tokensAlreadyUnlocked", - type: "u64", - index: false, - }, - { - name: "totalTokenAmount", - type: "u64", - index: false, - }, - { - name: "currentPrice", - type: "u128", - index: false, - }, - { - name: "unlockPercentage", - type: "u128", - index: false, - }, - ], - }, - { - name: "ChangeProposed", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - { - name: "proposedAt", - type: "i64", - index: false, - }, - ], - }, - { - name: "ChangeExecuted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "executor", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - { - name: "executedAt", - type: "i64", - index: false, - }, - ], - }, - { - name: "LockerAuthorityChanged", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - { - name: "changedAt", - type: "i64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "UnlockTimestampInThePast", - msg: "Unlock timestamp must be in the future", - }, - { - code: 6002, - name: "InvalidLockerState", - msg: "Locker is not in the expected state", - }, - { - code: 6003, - name: "TwapCalculationFailed", - msg: "TWAP calculation failed", - }, - { - code: 6004, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6005, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - { - code: 6006, - name: "UnauthorizedChangeRequest", - msg: "Unauthorized to create or execute change request", - }, - { - code: 6007, - name: "InvalidChangeRequest", - msg: "Change request does not match locker", - }, - { - code: 6008, - name: "UnauthorizedLockerAuthority", - msg: "Unauthorized locker authority", - }, - { - code: 6009, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - ], -}; diff --git a/sdk/src/v0.6/types/shared_liquidity_manager.ts b/sdk/src/v0.6/types/shared_liquidity_manager.ts deleted file mode 100644 index 124942da9..000000000 --- a/sdk/src/v0.6/types/shared_liquidity_manager.ts +++ /dev/null @@ -1,177 +0,0 @@ -export type SharedLiquidityManager = { - version: "0.1.0"; - name: "shared_liquidity_manager"; - docs: ["TODO:", "- add unstake", "- add unit tests"]; - instructions: []; - errors: [ - { - code: 6000; - name: "InsufficientStake"; - msg: "Insufficient stake amount"; - }, - { - code: 6001; - name: "ProposalNotFinalized"; - msg: "Proposal is not finalized"; - }, - { - code: 6002; - name: "NoLpTokensToRemove"; - msg: "No LP tokens to remove from AMM"; - }, - { - code: 6003; - name: "NoTokensFromAmm"; - msg: "No tokens received from AMM removal"; - }, - { - code: 6004; - name: "InsufficientReservesReturned"; - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)"; - }, - { - code: 6005; - name: "PoolInUse"; - msg: "Pool is currently being used by an active proposal"; - }, - { - code: 6006; - name: "InsufficientLpShares"; - msg: "User does not have enough LP shares to withdraw"; - }, - { - code: 6007; - name: "SlippageExceeded"; - msg: "Slippage exceeded minimum token amounts"; - }, - { - code: 6008; - name: "NoLpTokensInPool"; - msg: "No LP tokens in pool's LP token account"; - }, - { - code: 6009; - name: "NotEnoughLpTokens"; - msg: "Not enough LP tokens to provide liquidity to proposal"; - }, - { - code: 6010; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6011; - name: "NoActiveProposal"; - msg: "No active proposal"; - }, - { - code: 6012; - name: "ProposalNotInDraftStatus"; - msg: "Proposal is not in draft status"; - }, - { - code: 6013; - name: "ProposalAlreadyActive"; - msg: "Proposal already active"; - }, - { - code: 6014; - name: "AmmAlreadyHasLiquidity"; - msg: "AMM already has liquidity"; - }, - { - code: 6015; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - ]; -}; - -export const IDL: SharedLiquidityManager = { - version: "0.1.0", - name: "shared_liquidity_manager", - docs: ["TODO:", "- add unstake", "- add unit tests"], - instructions: [], - errors: [ - { - code: 6000, - name: "InsufficientStake", - msg: "Insufficient stake amount", - }, - { - code: 6001, - name: "ProposalNotFinalized", - msg: "Proposal is not finalized", - }, - { - code: 6002, - name: "NoLpTokensToRemove", - msg: "No LP tokens to remove from AMM", - }, - { - code: 6003, - name: "NoTokensFromAmm", - msg: "No tokens received from AMM removal", - }, - { - code: 6004, - name: "InsufficientReservesReturned", - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)", - }, - { - code: 6005, - name: "PoolInUse", - msg: "Pool is currently being used by an active proposal", - }, - { - code: 6006, - name: "InsufficientLpShares", - msg: "User does not have enough LP shares to withdraw", - }, - { - code: 6007, - name: "SlippageExceeded", - msg: "Slippage exceeded minimum token amounts", - }, - { - code: 6008, - name: "NoLpTokensInPool", - msg: "No LP tokens in pool's LP token account", - }, - { - code: 6009, - name: "NotEnoughLpTokens", - msg: "Not enough LP tokens to provide liquidity to proposal", - }, - { - code: 6010, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6011, - name: "NoActiveProposal", - msg: "No active proposal", - }, - { - code: 6012, - name: "ProposalNotInDraftStatus", - msg: "Proposal is not in draft status", - }, - { - code: 6013, - name: "ProposalAlreadyActive", - msg: "Proposal already active", - }, - { - code: 6014, - name: "AmmAlreadyHasLiquidity", - msg: "AMM already has liquidity", - }, - { - code: 6015, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - ], -}; diff --git a/sdk/src/v0.6/types/utils.ts b/sdk/src/v0.6/types/utils.ts deleted file mode 100644 index c878debe7..000000000 --- a/sdk/src/v0.6/types/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; -}; diff --git a/sdk/src/v0.6/utils/cu.ts b/sdk/src/v0.6/utils/cu.ts deleted file mode 100644 index b55cbac95..000000000 --- a/sdk/src/v0.6/utils/cu.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const MaxCUs = { - initializeDao: 40_000, - createIdempotent: 25_000, - initializeConditionalVault: 45_000, - mintConditionalTokens: 35_000, - initializeAmm: 120_000, - addLiquidity: 120_000, - initializeProposal: 60_000, -}; - -export const DEFAULT_CU_PRICE = 1; diff --git a/sdk/src/v0.6/utils/filters.ts b/sdk/src/v0.6/utils/filters.ts deleted file mode 100644 index aee93f618..000000000 --- a/sdk/src/v0.6/utils/filters.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GetProgramAccountsFilter, PublicKey } from "@solana/web3.js"; - -export const filterPositionsByUser = ( - userAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: 8, // discriminator - bytes: userAddr.toBase58(), - }, -}); - -export const filterPositionsByAmm = ( - ammAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: - 8 + // discriminator - 32, // user address - bytes: ammAddr.toBase58(), - }, -}); diff --git a/sdk/src/v0.6/utils/index.ts b/sdk/src/v0.6/utils/index.ts deleted file mode 100644 index ee7438b0a..000000000 --- a/sdk/src/v0.6/utils/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export * from "./filters.js"; -export * from "./pda.js"; -export * from "./priceMath.js"; -export * from "./metadata.js"; -export * from "./cu.js"; -export * from "./instruction.js"; - -import { AccountMeta, ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; - -export enum PriorityFeeTier { - NORMAL = 35, - HIGH = 3571, - TURBO = 357142, -} - -export const addComputeUnits = (num_units: number = 1_400_000) => - ComputeBudgetProgram.setComputeUnitLimit({ - units: num_units, - }); - -export const addPriorityFee = (pf: number) => - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: pf, - }); - -export const pubkeyToAccountInfo = ( - pubkey: PublicKey, - isWritable: boolean, - isSigner = false, -): AccountMeta => { - return { - pubkey: pubkey, - isSigner: isSigner, - isWritable: isWritable, - }; -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/sdk/src/v0.6/utils/instruction.ts b/sdk/src/v0.6/utils/instruction.ts deleted file mode 100644 index f18e48834..000000000 --- a/sdk/src/v0.6/utils/instruction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { TransactionInstruction } from "@solana/web3.js"; - -export class InstructionUtils { - public static async getInstructions( - ...methodBuilders: any[] - ): Promise { - let instructions: TransactionInstruction[] = []; - - for (const methodBuilder of methodBuilders) { - instructions.push(...(await methodBuilder.transaction()).instructions); - } - - return instructions; - } -} diff --git a/sdk/src/v0.6/utils/metadata.ts b/sdk/src/v0.6/utils/metadata.ts deleted file mode 100644 index ef17bbdb8..000000000 --- a/sdk/src/v0.6/utils/metadata.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BN from "bn.js"; -import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { Connection } from "@solana/web3.js"; -import { bundlrUploader } from "@metaplex-foundation/umi-uploader-bundlr"; -import { UmiPlugin } from "@metaplex-foundation/umi"; - -export const assetImageMap: Record = { - fMETA: "https://arweave.net/tGxvOjMZw7B0qHsdCcIMO57oH5g5OaItOZdXo3BXKz8", - fUSDC: "https://arweave.net/DpvxeAyVbaoivhIVCLjdf566k2SwVn0YVBL0sTOezWk", - pMETA: "https://arweave.net/iuqi7PRRESdDxj1oRyk2WzR90_zdFcmZsuWicv3XGfs", - pUSDC: "https://arweave.net/e4IO7F59F_RKCiuB--_ABPot7Qh1yFsGkWzVhcXuKDU", -}; - -// Upload some JSON, returning its URL -export const uploadConditionalTokenMetadataJson = async ( - connection: Connection, - identityPlugin: UmiPlugin, - proposalNumber: number, - symbol: string, - // proposal: BN, - // conditionalToken: string, - // image: string -): Promise => { - // use bundlr, targeting arweave - const umi = createUmi(connection); - umi.use(bundlrUploader()); - umi.use(identityPlugin); - - return umi.uploader.uploadJson({ - name: `Proposal ${proposalNumber}: ${symbol}`, - image: assetImageMap[symbol], - symbol, - description: "A conditional token for use in futarchy.", - }); -}; diff --git a/sdk/src/v0.6/utils/pda.ts b/sdk/src/v0.6/utils/pda.ts deleted file mode 100644 index a1c8836b3..000000000 --- a/sdk/src/v0.6/utils/pda.ts +++ /dev/null @@ -1,238 +0,0 @@ -import { AccountMeta, PublicKey } from "@solana/web3.js"; -import { utils } from "@coral-xyz/anchor"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - fromWeb3JsPublicKey, - toWeb3JsPublicKey, -} from "@metaplex-foundation/umi-web3js-adapters"; -import { - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, - PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - RAYDIUM_CP_SWAP_PROGRAM_ID, - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, -} from "../constants.js"; -import { LAUNCHPAD_PROGRAM_ID, FUTARCHY_PROGRAM_ID } from "../constants.js"; - -export const getEventAuthorityAddr = (programId: PublicKey) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("__event_authority")], - programId, - ); -}; - -export const getQuestionAddr = ( - programId: PublicKey, - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, -) => { - if (questionId.length != 32) { - throw new Error("questionId must be 32 bytes"); - } - - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("question"), - Buffer.from(questionId), - oracle.toBuffer(), - new BN(numOutcomes).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getVaultAddr = ( - programId: PublicKey, - question: PublicKey, - underlyingTokenMint: PublicKey, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_vault"), - question.toBuffer(), - underlyingTokenMint.toBuffer(), - ], - programId, - ); -}; - -export const getConditionalTokenMintAddr = ( - programId: PublicKey, - vault: PublicKey, - index: number, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_token"), - vault.toBuffer(), - new BN(index).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getDownAndUpMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { down: PublicKey; up: PublicKey } => { - return { - down: getConditionalTokenMintAddr(programId, vault, 0)[0], - up: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getFailAndPassMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { fail: PublicKey; pass: PublicKey } => { - return { - fail: getConditionalTokenMintAddr(programId, vault, 0)[0], - pass: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getMetadataAddr = (mint: PublicKey) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("metadata"), - MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - MPL_TOKEN_METADATA_PROGRAM_ID, - ); -}; - -export const getDaoAddr = ({ - nonce, - daoCreator, - programId = FUTARCHY_PROGRAM_ID, -}: { - nonce: BN; - daoCreator: PublicKey; - programId?: PublicKey; -}): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("dao"), - daoCreator.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -/** - * @deprecated Use getAutocratProposalAddr instead - */ -export const getProposalAddr = ( - programId: PublicKey, - squadsProposal: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("proposal"), squadsProposal.toBuffer()], - programId, - ); -}; - -export const getProposalAddrV2 = ({ - programId = FUTARCHY_PROGRAM_ID, - squadsProposal, -}: { - programId?: PublicKey; - squadsProposal: PublicKey; -}): [PublicKey, number] => { - return getProposalAddr(programId, squadsProposal); -}; - -export function getLaunchAddr( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - tokenMint: PublicKey, -): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch"), tokenMint.toBuffer()], - programId, - ); -} - -export const getLaunchSignerAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_signer"), launch.toBuffer()], - programId, - ); -}; - -export const getFundingRecordAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, - funder: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], - programId, - ); -}; - -export const getStakeRecordAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - draftProposal: PublicKey, - staker: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("stake_record"), draftProposal.toBuffer(), staker.toBuffer()], - programId, - ); -}; - -export const getStakeAddr = ( - programId: PublicKey = FUTARCHY_PROGRAM_ID, - draftProposal: PublicKey, - staker: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("stake"), draftProposal.toBuffer(), staker.toBuffer()], - programId, - ); -}; - -export const getPerformancePackageAddr = ({ - programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - createKey, -}: { - programId?: PublicKey; - createKey: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("performance_package"), createKey.toBuffer()], - programId, - ); -}; - -export const getChangeRequestAddr = ({ - programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - performancePackage, - proposer, - pdaNonce, -}: { - programId?: PublicKey; - performancePackage: PublicKey; - proposer: PublicKey; - pdaNonce: number; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("change_request"), - performancePackage.toBuffer(), - proposer.toBuffer(), - Buffer.from(new Uint8Array(new Uint32Array([pdaNonce]).buffer)), - ], - programId, - ); -}; diff --git a/sdk/src/v0.6/utils/priceMath.ts b/sdk/src/v0.6/utils/priceMath.ts deleted file mode 100644 index 4e7addb3c..000000000 --- a/sdk/src/v0.6/utils/priceMath.ts +++ /dev/null @@ -1,197 +0,0 @@ -import BN from "bn.js"; -import { Amm } from "../types/index.js"; -import { AmmMath as V3AmmMath } from "../../v0.3/utils/ammMath.js"; - -const BN_TEN = new BN(10); -const PRICE_SCALE = BN_TEN.pow(new BN(12)); -const PRICE_SCALE_NUMBER = 1e12; - -export type AddLiquiditySimulation = { - baseAmount: BN; - quoteAmount: BN; - expectedLpTokens: BN; - minLpTokens?: BN; - maxBaseAmount?: BN; -}; - -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - -export type RemoveLiquiditySimulation = { - expectedBaseOut: BN; - expectedQuoteOut: BN; - minBaseOut?: BN; - minQuoteOut?: BN; -}; - -export class AmmMath { - // Re-export common methods from v0.3 - public static getHumanPriceFromReserves = V3AmmMath.getHumanPriceFromReserves; - public static getAmmPriceFromReserves = V3AmmMath.getAmmPriceFromReserves; - public static getChainAmount = V3AmmMath.getChainAmount; - public static getHumanAmount = V3AmmMath.getHumanAmount; - public static getAmmPrice = V3AmmMath.getAmmPrice; - public static getAmmPrices = V3AmmMath.getAmmPrices; - public static scale = V3AmmMath.scale; - public static addSlippage = V3AmmMath.addSlippage; - public static subtractSlippage = V3AmmMath.subtractSlippage; - public static simulateAddLiquidity = V3AmmMath.simulateAddLiquidity; - public static simulateRemoveLiquidity = V3AmmMath.simulateRemoveLiquidity; - - public static getHumanPrice( - ammPrice: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - const decimalScalar = BN_TEN.pow( - new BN(quoteDecimals - baseDecimals).abs(), - ); - const price1e12 = - quoteDecimals > baseDecimals - ? ammPrice.div(decimalScalar) - : ammPrice.mul(decimalScalar); - - // in case the BN is too large to cast to number, we try - try { - return price1e12.toNumber() / 1e12; - } catch (e) { - // BN tried to cast into number larger than 53 bits so we we do division via BN methods first, then cast to number(so it is smaller before the cast) - return price1e12.div(new BN(1e12)).toNumber(); - } - } - - public static getTwap(amm: Amm): BN { - return amm.oracle.aggregator.div( - amm.oracle.lastUpdatedSlot.sub(amm.createdAtSlot), - ); - } - - public static simulateSwapInner( - inputAmount: BN, - inputReserves: BN, - outputReserves: BN, - ): BN { - if (inputReserves.eqn(0) || outputReserves.eqn(0)) { - throw new Error("reserves must be non-zero"); - } - - let inputAmountWithFee: BN = inputAmount.muln(990); - - let numerator: BN = inputAmountWithFee.mul(outputReserves); - let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); - - return numerator.div(denominator); - } - - // public static simulateSwap( - // inputAmount: BN, - // swapType: SwapType, - // baseReserves: BN, - // quoteReserves: BN, - // slippageBps?: BN - // ): SwapSimulation { - // let inputReserves: BN, outputReserves: BN; - // if (swapType.buy) { - // inputReserves = quoteReserves; - // outputReserves = baseReserves; - // } else { - // inputReserves = baseReserves; - // outputReserves = quoteReserves; - // } - - // let expectedOut = this.simulateSwapInner( - // inputAmount, - // inputReserves, - // outputReserves - // ); - - // let minExpectedOut; - // if (slippageBps) { - // minExpectedOut = AmmMath.subtractSlippage(expectedOut, slippageBps); - // } - - // let newBaseReserves: BN, newQuoteReserves: BN; - // if (swapType.buy) { - // newBaseReserves = baseReserves.sub(expectedOut); - // newQuoteReserves = quoteReserves.add(inputAmount); - // } else { - // newBaseReserves = baseReserves.add(inputAmount); - // newQuoteReserves = quoteReserves.sub(expectedOut); - // } - - // return { - // expectedOut, - // newBaseReserves, - // newQuoteReserves, - // minExpectedOut, - // }; - // } - - // /** - // * Calculates the optimal swap amount and mergeable tokens without using square roots. - // * @param userBalanceIn BN – Tokens that a user wants to dispose of. - // * @param ammReserveIn BN – Amount of tokens in the AMM of the token that the user wants to dispose of. - // * @param ammReserveOut BN – Amount of tokens in the AMM of the token that the user wants to receive. - // * @returns An object containing the optimal swap amount, expected quote received, and expected mergeable tokens. - // */ - - // public static calculateOptimalSwapForMerge( - // userBalanceIn: BN, - // ammReserveIn: BN, - // ammReserveOut: BN, - // slippageBps: BN - // ): { - // optimalSwapAmount: BN; - // userInAfterSwap: BN; - // expectedOut: BN; - // minimumExpectedOut: BN; - // } { - // // essentially, we want to calculate the swap amount so that the remaining user balance = received token amount - - // // solve this system of equations for swapAmount, outputAmount (we only care about swap amount tho) - // // (baseReserve + swapAmount) * (quoteReserve - outputAmount) = baseReserve * quoteReserve - // // baseAmount - swapAmount = outputAmount - - // //solve equation - // // (baseReserve + .99*swapAmount) * (quoteReserve - (userTokens - swapAmount)) = baseReserve * quoteReserve - // // multiplying out the left hand side and subtracting baseReserve * quoteReserve from both sides yields the following: - // // baseReserve*quoteReserve - baseReserve*userTokens + baseReserve*swapAmount + .99*swapAmount*quoteReserve - .99*swapAmount*userTokens + .99*swapAmount^2 = baseReserve*quoteReserve - // // .99*swapAmount^2 + baseReserve*swapAmount + .99*swapAmount*quoteReserve - baseReserve*userTokens - .99*swapAmount*userTokens = 0 - // // in the quadratic equation, a = .99, b = (baseReserve + .99*quoteReserve - .99*userTokens), c = -baseReserve*userTokens - // // x = (-b + sqrt(b^2 - 4ac)) / 2a - - // let a = 0.99; - // let b = - // Number(ammReserveIn) + - // 0.99 * Number(ammReserveOut) - - // 0.99 * Number(userBalanceIn); - // let c = -Number(ammReserveIn) * Number(userBalanceIn); - - // let x = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a); - // //this should mathematically return a positive number assuming userBalanceIn, ammReserveIn, and ammReserveOut are all positive (which they should be) - // // -b + Math.sqrt(b ** 2 - 4 * a * c) > 0 because -4*a*c > 0 and sqrt(b**2 + positive number) > b - - // const swapAmount = x; - - // let expectedOut = this.simulateSwapInner( - // new BN(swapAmount), - // ammReserveIn, - // ammReserveOut - // ); - // let minimumExpectedOut = - // Number(expectedOut) - (Number(expectedOut) * Number(slippageBps)) / 10000; - // return { - // optimalSwapAmount: new BN(swapAmount), - // userInAfterSwap: new BN(Number(userBalanceIn) - swapAmount), - // expectedOut: expectedOut, - // minimumExpectedOut: new BN(minimumExpectedOut), - // }; - // } -} - -// Add backwards compatibility alias -export { AmmMath as PriceMath }; diff --git a/sdk/src/v0.7/BidWallClient.ts b/sdk/src/v0.7/BidWallClient.ts deleted file mode 100644 index 7652baf70..000000000 --- a/sdk/src/v0.7/BidWallClient.ts +++ /dev/null @@ -1,314 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; -import { - MAINNET_USDC, - BID_WALL_PROGRAM_ID, - METADAO_MULTISIG_VAULT, -} from "../v0.7/constants.js"; -import { BidWallProgram, BidWallIDL, BidWall } from "../v0.7/types/index.js"; -import BN from "bn.js"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { getBidWallAddr, getEventAuthorityAddr } from "../v0.7/utils/pda.js"; - -export type CreateBidWallClientParams = { - provider: AnchorProvider; - bidWallProgramId?: PublicKey; -}; - -export class BidWallClient { - public readonly provider: AnchorProvider; - public readonly bidWallProgram: Program; - public readonly programId: PublicKey; - - constructor(provider: AnchorProvider, bidWallProgramId: PublicKey) { - this.provider = provider; - this.programId = bidWallProgramId; - this.bidWallProgram = new Program( - BidWallIDL, - bidWallProgramId, - provider, - ); - } - - public static createClient( - createBidWallClientParams: CreateBidWallClientParams, - ): BidWallClient { - let { provider, bidWallProgramId } = createBidWallClientParams; - - return new BidWallClient(provider, bidWallProgramId || BID_WALL_PROGRAM_ID); - } - - async fetchBidWall(bidWall: PublicKey): Promise { - return this.bidWallProgram.account.bidWall.fetchNullable(bidWall); - } - - async deserializeBidWall(accountInfo: AccountInfo): Promise { - return this.bidWallProgram.coder.accounts.decode( - "bidWall", - accountInfo.data, - ); - } - - initializeBidWallIx({ - amount, - durationSeconds, - initialAmmQuoteReserves, - daoTreasury, - authority, - baseMint, - creator = this.provider.publicKey, - nonce = new BN(0), - feeRecipient = METADAO_MULTISIG_VAULT, - quoteMint = MAINNET_USDC, - payer = this.provider.publicKey, - }: { - amount: number; - durationSeconds: number; - initialAmmQuoteReserves: number; - daoTreasury: PublicKey; - creator?: PublicKey; - nonce?: BN; - authority?: PublicKey; - baseMint: PublicKey; - feeRecipient?: PublicKey; - quoteMint?: PublicKey; - payer?: PublicKey; - }) { - const [bidWall] = getBidWallAddr({ creator, baseMint, nonce }); - - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - - const creatorQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - creator, - true, - ); - - return this.bidWallProgram.methods - .initializeBidWall({ - amount: new BN(amount), - nonce, - durationSeconds, - initialAmmQuoteReserves: new BN(initialAmmQuoteReserves), - }) - .accounts({ - bidWall, - payer, - bidWallQuoteTokenAccount, - creator, - creatorQuoteTokenAccount, - authority: authority ?? creator, - baseMint, - quoteMint, - feeRecipient, - daoTreasury, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }); - } - - sellTokensIx({ - amount, - minAmountOut = 0, - bidWall, - baseMint, - daoTreasury, - quoteMint = MAINNET_USDC, - user = this.provider.publicKey, - }: { - amount: number; - minAmountOut?: number; - bidWall: PublicKey; - baseMint: PublicKey; - daoTreasury: PublicKey; - quoteMint: PublicKey; - user: PublicKey; - }) { - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - - const userTokenAccount = getAssociatedTokenAddressSync( - baseMint, - user, - true, - ); - - const userQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - user, - true, - ); - - const daoTreasuryQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - daoTreasury, - true, - ); - - return this.bidWallProgram.methods - .sellTokens({ - amountIn: new BN(amount), - minAmountOut: new BN(minAmountOut), - }) - .accounts({ - bidWall, - user, - userTokenAccount, - userQuoteTokenAccount, - bidWallQuoteTokenAccount, - baseMint, - quoteMint, - daoTreasury, - daoTreasuryQuoteTokenAccount, - tokenProgram: TOKEN_PROGRAM_ID, - }); - } - - collectFeesIx({ - bidWall, - admin = this.provider.publicKey, - quoteMint = MAINNET_USDC, - }: { - bidWall: PublicKey; - admin?: PublicKey; - quoteMint?: PublicKey; - }) { - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - - const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - METADAO_MULTISIG_VAULT, - true, - ); - - return this.bidWallProgram.methods.collectFees().accounts({ - bidWall, - cranker: admin, - bidWallQuoteTokenAccount, - feeRecipientQuoteTokenAccount, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - }); - } - - closeBidWallIx({ - bidWall, - authority, - baseMint, - feeRecipient = METADAO_MULTISIG_VAULT, - quoteMint = MAINNET_USDC, - }: { - bidWall: PublicKey; - authority: PublicKey; - baseMint: PublicKey; - feeRecipient: PublicKey; - quoteMint: PublicKey; - }) { - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - const authorityQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - authority, - true, - ); - const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - feeRecipient, - true, - ); - - return this.bidWallProgram.methods.closeBidWall().accounts({ - bidWall, - authority, - feeRecipient, - bidWallQuoteTokenAccount, - authorityQuoteTokenAccount, - feeRecipientQuoteTokenAccount, - baseMint, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }); - } - - cancelBidWallIx({ - bidWall, - authority, - baseMint, - feeRecipient = METADAO_MULTISIG_VAULT, - quoteMint = MAINNET_USDC, - payer = this.provider.publicKey, - }: { - bidWall: PublicKey; - authority: PublicKey; - baseMint: PublicKey; - feeRecipient: PublicKey; - quoteMint: PublicKey; - payer: PublicKey; - }) { - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - const authorityQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - authority, - true, - ); - const feeRecipientQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - feeRecipient, - true, - ); - - return this.bidWallProgram.methods.cancelBidWall().accounts({ - bidWall, - payer, - authority, - feeRecipient, - bidWallQuoteTokenAccount, - authorityQuoteTokenAccount, - feeRecipientQuoteTokenAccount, - baseMint, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }); - } - - public getBidWallAddress({ - baseMint, - creator, - nonce, - }: { - baseMint: PublicKey; - creator: PublicKey; - nonce: BN; - }): PublicKey { - return getBidWallAddr({ baseMint, creator, nonce })[0]; - } - - public getEventAuthorityAddress(): PublicKey { - return getEventAuthorityAddr(this.programId)[0]; - } -} diff --git a/sdk/src/v0.7/ConditionalVaultClient.ts b/sdk/src/v0.7/ConditionalVaultClient.ts deleted file mode 100644 index 047e0a46f..000000000 --- a/sdk/src/v0.7/ConditionalVaultClient.ts +++ /dev/null @@ -1,475 +0,0 @@ -import { AnchorProvider, Program, utils } from "@coral-xyz/anchor"; -import { - AccountInfo, - AddressLookupTableAccount, - Keypair, - PublicKey, - SystemProgram, -} from "@solana/web3.js"; - -import { ConditionalVaultProgram, ConditionalVaultIDL } from "./types/index.js"; - -import BN from "bn.js"; -import { - CONDITIONAL_VAULT_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, -} from "./constants.js"; -import { - getQuestionAddr, - getMetadataAddr, - getVaultAddr, - getConditionalTokenMintAddr, -} from "./utils/index.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createAssociatedTokenAccountInstruction, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { ConditionalVault, Question } from "./types/index.js"; - -export type CreateVaultClientParams = { - provider: AnchorProvider; - conditionalVaultProgramId?: PublicKey; -}; - -export class ConditionalVaultClient { - public readonly provider: AnchorProvider; - public readonly vaultProgram: Program; - - constructor(provider: AnchorProvider, conditionalVaultProgramId: PublicKey) { - this.provider = provider; - this.vaultProgram = new Program( - ConditionalVaultIDL, - conditionalVaultProgramId, - provider, - ); - } - - public static createClient( - createVaultClientParams: CreateVaultClientParams, - ): ConditionalVaultClient { - let { provider, conditionalVaultProgramId } = createVaultClientParams; - - return new ConditionalVaultClient( - provider, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - ); - } - - async fetchQuestion(question: PublicKey): Promise { - return this.vaultProgram.account.question.fetchNullable(question); - } - - async fetchVault(vault: PublicKey): Promise { - return this.vaultProgram.account.conditionalVault.fetchNullable(vault); - } - - async deserializeQuestion( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "question", - accountInfo.data, - ); - } - - async deserializeVault( - accountInfo: AccountInfo, - ): Promise { - return this.vaultProgram.coder.accounts.decode( - "conditionalVault", - accountInfo.data, - ); - } - - initializeQuestionIx( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ) { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - return this.vaultProgram.methods - .initializeQuestion({ - questionId: Array.from(questionId), - oracle, - numOutcomes, - }) - .accounts({ - question, - }); - } - - async initializeQuestion( - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, - ): Promise { - const [question] = getQuestionAddr( - this.vaultProgram.programId, - questionId, - oracle, - numOutcomes, - ); - - await this.initializeQuestionIx(questionId, oracle, numOutcomes).rpc(); - - return question; - } - - initializeVaultIx( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - payer: PublicKey = this.provider.publicKey, - ) { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - const vaultUnderlyingTokenAccount = getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ); - - return this.vaultProgram.methods - .initializeConditionalVault() - .accounts({ - vault, - question, - underlyingTokenMint, - vaultUnderlyingTokenAccount, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - vaultUnderlyingTokenAccount, - vault, - underlyingTokenMint, - ), - ]) - .remainingAccounts( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - } - - // TODO remove `numOucomes` - - async initializeVault( - question: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - ): Promise { - const [vault] = getVaultAddr( - this.vaultProgram.programId, - question, - underlyingTokenMint, - ); - - await this.initializeVaultIx( - question, - underlyingTokenMint, - numOutcomes, - ).rpc(); - - return vault; - } - - resolveQuestionIx( - question: PublicKey, - oracle: Keypair, - payoutNumerators: number[], - ) { - return this.vaultProgram.methods - .resolveQuestion({ - payoutNumerators, - }) - .accounts({ - question, - oracle: oracle.publicKey, - }) - .signers([oracle]); - } - - getConditionalTokenMints(vault: PublicKey, numOutcomes: number): PublicKey[] { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - return conditionalTokenMintAddrs; - } - - getRemainingAccounts( - conditionalTokenMints: PublicKey[], - userConditionalAccounts: PublicKey[], - ) { - return conditionalTokenMints - .concat(userConditionalAccounts) - .map((account) => ({ - pubkey: account, - isWritable: true, - isSigner: false, - })); - } - - // Helper method to get conditional token accounts and instructions - getConditionalTokenAccountsAndInstructions( - vault: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - const userConditionalAccounts = conditionalTokenMintAddrs.map((mint) => - getAssociatedTokenAddressSync(mint, user, true), - ); - - const preInstructions = conditionalTokenMintAddrs.map((mint) => - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(mint, user, true), - user, - mint, - ), - ); - - const remainingAccounts = this.getRemainingAccounts( - conditionalTokenMintAddrs, - userConditionalAccounts, - ); - - return { userConditionalAccounts, preInstructions, remainingAccounts }; - } - - splitTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - const { preInstructions, remainingAccounts } = - this.getConditionalTokenAccountsAndInstructions( - vault, - numOutcomes, - user, - payer, - ); - - return this.vaultProgram.methods - .splitTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions(preInstructions) - .remainingAccounts(remainingAccounts); - } - - mergeTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - amount: BN, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = this.getConditionalTokenMints( - vault, - numOutcomes, - ); - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .mergeTokens(amount) - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - redeemTokensIx( - question: PublicKey, - vault: PublicKey, - underlyingTokenMint: PublicKey, - numOutcomes: number, - user: PublicKey = this.provider.publicKey, - payer: PublicKey = this.provider.publicKey, - ) { - let conditionalTokenMintAddrs = []; - for (let i = 0; i < numOutcomes; i++) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - i, - ); - conditionalTokenMintAddrs.push(conditionalTokenMint); - } - - let userConditionalAccounts = []; - for (let conditionalTokenMint of conditionalTokenMintAddrs) { - userConditionalAccounts.push( - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - ); - } - - let ix = this.vaultProgram.methods - .redeemTokens() - .accounts({ - question, - authority: user, - vault, - vaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - vault, - true, - ), - userUnderlyingTokenAccount: getAssociatedTokenAddressSync( - underlyingTokenMint, - user, - true, - ), - }) - .preInstructions( - conditionalTokenMintAddrs.map((conditionalTokenMint) => { - return createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(conditionalTokenMint, user, true), - user, - conditionalTokenMint, - ); - }), - ) - .remainingAccounts( - conditionalTokenMintAddrs - .concat(userConditionalAccounts) - .map((conditionalTokenMint) => { - return { - pubkey: conditionalTokenMint, - isWritable: true, - isSigner: false, - }; - }), - ); - - return ix; - } - - addMetadataToConditionalTokensIx( - vault: PublicKey, - index: number, - name: string, - symbol: string, - uri: string, - payer: PublicKey = this.provider.publicKey, - ) { - const [conditionalTokenMint] = getConditionalTokenMintAddr( - this.vaultProgram.programId, - vault, - index, - ); - - const [conditionalTokenMetadata] = getMetadataAddr(conditionalTokenMint); - - return this.vaultProgram.methods - .addMetadataToConditionalTokens({ - name, - symbol, - uri, - }) - .accounts({ - payer, - vault, - conditionalTokenMint, - conditionalTokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.7/FutarchyClient.ts b/sdk/src/v0.7/FutarchyClient.ts deleted file mode 100644 index 10d9f6aee..000000000 --- a/sdk/src/v0.7/FutarchyClient.ts +++ /dev/null @@ -1,1242 +0,0 @@ -import { AnchorProvider, IdlTypes, Program } from "@coral-xyz/anchor"; -import { - AccountInfo, - AccountMeta, - AddressLookupTableAccount, - ComputeBudgetProgram, - Connection, - Keypair, - PublicKey, - SystemProgram, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { InitializeDaoParams, UpdateDaoParams } from "./types/index.js"; - -// import { Autocrat, IDL as AutocratIDL } from "./types/autocrat.js"; -import { Futarchy, IDL as FutarchyIDL } from "./types/futarchy.js"; -import { - ConditionalVault, - IDL as ConditionalVaultIDL, -} from "./types/conditional_vault.js"; - -import BN from "bn.js"; -import { - AMM_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - CONDITIONAL_VAULT_PROGRAM_ID, - MAINNET_USDC, - PERMISSIONLESS_ACCOUNT, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - SQUADS_PROGRAM_ID, - USDC_DECIMALS, - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - MAINNET_METEORA_CONFIG, - METADAO_MULTISIG_VAULT, - DAMM_V2_PROGRAM_ID, - LAUNCHPAD_PROGRAM_ID, - DAMM_V2_POOL_AUTHORITY, -} from "./constants.js"; -import { - DEFAULT_CU_PRICE, - InstructionUtils, - MaxCUs, - getConditionalTokenMintAddr, - getDaoAddr, - getEventAuthorityAddr, - getProposalAddr, - getProposalAddrV2, - getQuestionAddr, - getVaultAddr, -} from "./utils/index.js"; -import { ConditionalVaultClient } from "./ConditionalVaultClient.js"; -import { - createAssociatedTokenAccountIdempotentInstruction, - createTransferInstruction, - getAssociatedTokenAddressSync, - unpackMint, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { sha256 } from "@noble/hashes/sha256"; -import { Dao, Proposal } from "./types/index.js"; - -import * as multisig from "@sqds/multisig"; -import { TransactionMessage } from "@solana/web3.js"; -import { getStakeAddr } from "./utils/index.js"; - -export type CreateClientParams = { - provider: AnchorProvider; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; -}; - -export type ProposalVaults = { - baseVault: PublicKey; - quoteVault: PublicKey; -}; - -export class FutarchyClient { - public readonly provider: AnchorProvider; - public readonly autocrat: Program; - public readonly vaultClient: ConditionalVaultClient; - public readonly luts: AddressLookupTableAccount[]; - - constructor( - provider: AnchorProvider, - autocratProgramId: PublicKey, - conditionalVaultProgramId: PublicKey, - luts: AddressLookupTableAccount[], - ) { - this.provider = provider; - this.autocrat = new Program( - FutarchyIDL, - autocratProgramId, - provider, - ); - this.vaultClient = ConditionalVaultClient.createClient({ - provider, - conditionalVaultProgramId, - }); - this.luts = luts; - } - - public static createClient( - createAutocratClientParams: CreateClientParams, - ): FutarchyClient { - let { provider, autocratProgramId, conditionalVaultProgramId } = - createAutocratClientParams; - - const luts: AddressLookupTableAccount[] = []; - - return new FutarchyClient( - provider, - autocratProgramId || FUTARCHY_PROGRAM_ID, - conditionalVaultProgramId || CONDITIONAL_VAULT_PROGRAM_ID, - luts, - ); - } - - getProgramId(): PublicKey { - return this.autocrat.programId; - } - - async getProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetch(proposal); - } - - async getDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetch(dao); - } - - async fetchProposal(proposal: PublicKey): Promise { - return this.autocrat.account.proposal.fetchNullable(proposal); - } - - async fetchDao(dao: PublicKey): Promise { - return this.autocrat.account.dao.fetchNullable(dao); - } - - async deserializeProposal( - accountInfo: AccountInfo, - ): Promise { - return this.autocrat.coder.accounts.decode("proposal", accountInfo.data); - } - - async deserializeDao(accountInfo: AccountInfo): Promise { - return this.autocrat.coder.accounts.decode("dao", accountInfo.data); - } - - getProposalPdas( - proposal: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - dao: PublicKey, - ): { - question: PublicKey; - baseVault: PublicKey; - quoteVault: PublicKey; - passBaseMint: PublicKey; - passQuoteMint: PublicKey; - failBaseMint: PublicKey; - failQuoteMint: PublicKey; - } { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const [question] = getQuestionAddr( - vaultProgramId, - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - const [baseVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - baseMint, - ); - const [quoteVault] = getVaultAddr( - this.vaultClient.vaultProgram.programId, - question, - quoteMint, - ); - - const [failBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 0, - ); - const [failQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 0, - ); - - const [passBaseMint] = getConditionalTokenMintAddr( - vaultProgramId, - baseVault, - 1, - ); - const [passQuoteMint] = getConditionalTokenMintAddr( - vaultProgramId, - quoteVault, - 1, - ); - - return { - question, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - }; - } - - initializeDaoIx({ - baseMint, - params, - provideLiquidity = false, - quoteMint = MAINNET_USDC, - squadsProgramConfigTreasury = SQUADS_PROGRAM_CONFIG_TREASURY, - }: { - baseMint: PublicKey; - params: InitializeDaoParams; - provideLiquidity?: boolean; - quoteMint?: PublicKey; - squadsProgramConfigTreasury?: PublicKey; - }) { - const [dao] = getDaoAddr({ - nonce: params.nonce, - daoCreator: this.provider.publicKey, - }); - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - let daoCreatorBaseAccount = null; - let daoCreatorQuoteAccount = null; - if (provideLiquidity) { - daoCreatorBaseAccount = getAssociatedTokenAddressSync( - baseMint, - this.provider.publicKey, - true, - ); - daoCreatorQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - this.provider.publicKey, - true, - ); - } - - const spendingLimit = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - })[0]; - - return this.autocrat.methods.initializeDao(params).accounts({ - dao, - baseMint, - quoteMint, - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury, - squadsProgram: SQUADS_PROGRAM_ID, - spendingLimit, - futarchyAmmBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - futarchyAmmQuoteVault: getAssociatedTokenAddressSync( - quoteMint, - dao, - true, - ), - }); - } - - launchProposalIx({ - proposal, - dao, - baseMint, - quoteMint, - squadsProposal, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - squadsProposal: PublicKey; - }) { - const { - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; - - return this.autocrat.methods - .launchProposal() - .accounts({ - proposal, - dao, - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - squadsMultisig, - squadsProposal, - payer: this.provider.publicKey, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]); - } - - spotSwapIx({ - dao, - baseMint, - quoteMint = MAINNET_USDC, - swapType, - inputAmount, - minOutputAmount = new BN(0), - trader = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - swapType: "buy" | "sell"; - inputAmount: BN; - minOutputAmount?: BN; - trader?: PublicKey; - }) { - return this.autocrat.methods - .spotSwap({ - swapType: swapType === "buy" ? { buy: {} } : { sell: {} }, - inputAmount, - minOutputAmount, - }) - .accounts({ - dao, - userBaseAccount: getAssociatedTokenAddressSync(baseMint, trader, true), - userQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - trader, - true, - ), - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - user: trader, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, trader, true), - trader, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(quoteMint, trader, true), - trader, - quoteMint, - ), - ]); - } - - provideLiquidityIx({ - dao, - baseMint, - quoteMint, - quoteAmount, - maxBaseAmount, - minLiquidity = new BN(0), - positionAuthority = this.provider.publicKey, - liquidityProvider = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - quoteAmount: BN; - maxBaseAmount: BN; - minLiquidity?: BN; - positionAuthority?: PublicKey; - liquidityProvider?: PublicKey; - }) { - const ammPosition = PublicKey.findProgramAddressSync( - [ - Buffer.from("amm_position"), - dao.toBuffer(), - positionAuthority.toBuffer(), - ], - this.getProgramId(), - )[0]; - - return this.autocrat.methods - .provideLiquidity({ - quoteAmount, - maxBaseAmount, - minLiquidity, - positionAuthority, - }) - .accounts({ - dao, - liquidityProvider, - liquidityProviderBaseAccount: getAssociatedTokenAddressSync( - baseMint, - liquidityProvider, - true, - ), - liquidityProviderQuoteAccount: getAssociatedTokenAddressSync( - quoteMint, - liquidityProvider, - true, - ), - payer: this.provider.publicKey, - systemProgram: SystemProgram.programId, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - ammPosition, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, liquidityProvider, true), - liquidityProvider, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(quoteMint, liquidityProvider, true), - liquidityProvider, - quoteMint, - ), - ]); - } - - conditionalSwapIx({ - dao, - trader = this.provider.publicKey, - payer = this.provider.publicKey, - baseMint, - quoteMint = MAINNET_USDC, - proposal, - market, - swapType, - inputAmount, - minOutputAmount, - }: { - dao: PublicKey; - trader?: PublicKey; - payer?: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - proposal: PublicKey; - market: "pass" | "fail"; - swapType: "buy" | "sell"; - inputAmount: BN; - minOutputAmount: BN; - }) { - const { - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - baseVault, - quoteVault, - question, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - let inputMint: PublicKey, outputMint: PublicKey; - - if (market == "pass" && swapType == "buy") { - inputMint = passQuoteMint; - outputMint = passBaseMint; - } else if (market == "pass" && swapType == "sell") { - inputMint = passBaseMint; - outputMint = passQuoteMint; - } else if (market == "fail" && swapType == "buy") { - inputMint = failQuoteMint; - outputMint = failBaseMint; - } else if (market == "fail" && swapType == "sell") { - inputMint = failBaseMint; - outputMint = failQuoteMint; - } else { - throw new Error( - "Either `market` or `swapType` is incorrectly configured", - ); - } - - return this.autocrat.methods - .conditionalSwap({ - market: market == "pass" ? { pass: {} } : { fail: {} }, - swapType: swapType == "buy" ? { buy: {} } : { sell: {} }, - inputAmount, - minOutputAmount, - }) - .accounts({ - dao, - proposal, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - baseVault, - quoteVault, - userInputAccount: getAssociatedTokenAddressSync( - inputMint, - trader, - true, - ), - userOutputAccount: getAssociatedTokenAddressSync( - outputMint, - trader, - true, - ), - baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - baseMint, - baseVault, - true, - ), - quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - quoteMint, - quoteVault, - true, - ), - passBaseMint, - failBaseMint, - passQuoteMint, - failQuoteMint, - conditionalVaultProgram: this.vaultClient.vaultProgram.programId, - vaultEventAuthority: getEventAuthorityAddr( - this.vaultClient.vaultProgram.programId, - )[0], - question, - }); - } - - squadsProposalCreateTx({ - dao, - instructions, - transactionIndex, - payer = this.provider.publicKey, - }: { - dao: PublicKey; - instructions: TransactionInstruction[]; - transactionIndex: bigint; - payer?: PublicKey; - }): { tx: Transaction; squadsProposal: PublicKey } { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - const transactionMessage = new TransactionMessage({ - payerKey: payer, - recentBlockhash: "", // this doesn't get used - instructions, - }); - - const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - vaultIndex: 0, - ephemeralSigners: 0, - transactionMessage, - }); - - const proposalCreate = multisig.instructions.proposalCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - }); - - const [squadsProposal] = multisig.getProposalPda({ - multisigPda, - transactionIndex: transactionIndex, - }); - - const tx = new Transaction().add(vaultTxCreate, proposalCreate); - - return { tx, squadsProposal }; - } - - async initializeProposal( - dao: PublicKey, - squadsProposal: PublicKey, - ): Promise { - const storedDao = await this.getDao(dao); - - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); - - await this.vaultClient.initializeQuestion( - sha256(`Will ${proposal} pass?/FAIL/PASS`), - proposal, - 2, - ); - - const { question } = this.getProposalPdas( - proposal, - storedDao.baseMint, - storedDao.quoteMint, - dao, - ); - - // it's important that these happen in a single atomic transaction - await this.vaultClient - .initializeVaultIx(question, storedDao.baseMint, 2) - .postInstructions( - await InstructionUtils.getInstructions( - this.vaultClient.initializeVaultIx(question, storedDao.quoteMint, 2), - ), - ) - .rpc(); - - await this.initializeProposalIx( - squadsProposal, - dao, - storedDao.baseMint, - storedDao.quoteMint, - question, - ) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]) - .rpc(); - - return proposal; - } - - initializeProposalIx( - squadsProposal: PublicKey, - dao: PublicKey, - baseMint: PublicKey, - quoteMint: PublicKey, - question: PublicKey, - proposer: PublicKey = this.provider.publicKey, - ) { - let [proposal] = getProposalAddr(this.autocrat.programId, squadsProposal); - const { - baseVault, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - } = this.getProposalPdas(proposal, baseMint, quoteMint, dao); - - let [futarchyAmm] = PublicKey.findProgramAddressSync( - [Buffer.from("futarchy_amm")], - this.getProgramId(), - ); - - const squadsMultisig = multisig.getMultisigPda({ createKey: dao })[0]; - - return this.autocrat.methods - .initializeProposal() - .accounts({ - question, - proposal, - squadsProposal, - dao, - baseVault, - quoteVault, - proposer, - squadsMultisig, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(passBaseMint, futarchyAmm, true), - futarchyAmm, - passBaseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(passQuoteMint, futarchyAmm, true), - futarchyAmm, - passQuoteMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(failBaseMint, futarchyAmm, true), - futarchyAmm, - failBaseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(failQuoteMint, futarchyAmm, true), - futarchyAmm, - failQuoteMint, - ), - ]); - } - - async finalizeProposal(proposal: PublicKey) { - let storedProposal = await this.getProposal(proposal); - let storedDao = await this.getDao(storedProposal.dao); - - return this.finalizeProposalIx( - proposal, - storedProposal.squadsProposal, - storedProposal.dao, - storedDao.baseMint, - storedDao.quoteMint, - ).rpc(); - } - - finalizeProposalIxV2({ - squadsProposal, - dao, - baseMint, - quoteMint = MAINNET_USDC, - }: { - squadsProposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - }) { - const [proposal] = getProposalAddrV2({ squadsProposal }); - - return this.finalizeProposalIx( - proposal, - squadsProposal, - dao, - baseMint, - quoteMint, - ); - } - - /** - * @deprecated use `finalizeProposalIxV2` instead - */ - finalizeProposalIx( - proposal: PublicKey, - squadsProposal: PublicKey, - dao: PublicKey, - daoToken: PublicKey, - usdc: PublicKey, - ) { - let vaultProgramId = this.vaultClient.vaultProgram.programId; - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - const { - question, - quoteVault, - passBaseMint, - passQuoteMint, - failBaseMint, - failQuoteMint, - baseVault, - } = this.getProposalPdas(proposal, daoToken, usdc, dao); - - const [vaultEventAuthority] = getEventAuthorityAddr(vaultProgramId); - - return this.autocrat.methods - .finalizeProposal() - .accounts({ - proposal, - dao, - squadsProposal, - squadsMultisig: multisigPda, - squadsMultisigProgram: SQUADS_PROGRAM_ID, - quoteVault, - question, - quoteVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - usdc, - quoteVault, - true, - ), - passQuoteMint, - failQuoteMint, - passBaseMint, - failBaseMint, - ammPassQuoteVault: getAssociatedTokenAddressSync( - passQuoteMint, - dao, - true, - ), - ammFailQuoteVault: getAssociatedTokenAddressSync( - failQuoteMint, - dao, - true, - ), - ammQuoteVault: getAssociatedTokenAddressSync(usdc, dao, true), - ammPassBaseVault: getAssociatedTokenAddressSync( - passBaseMint, - dao, - true, - ), - ammFailBaseVault: getAssociatedTokenAddressSync( - failBaseMint, - dao, - true, - ), - ammBaseVault: getAssociatedTokenAddressSync(daoToken, dao, true), - baseVault, - baseVaultUnderlyingTokenAccount: getAssociatedTokenAddressSync( - daoToken, - baseVault, - true, - ), - vaultProgram: this.vaultClient.vaultProgram.programId, - vaultEventAuthority, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - ]); - } - - updateDaoIx({ dao, params }: { dao: PublicKey; params: UpdateDaoParams }) { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - - return this.autocrat.methods.updateDao(params).accounts({ - dao, - squadsMultisigVault, - }); - } - - stakeToProposalIx({ - proposal, - dao, - baseMint, - amount, - staker = this.provider.publicKey, - payer = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - amount: BN; - staker?: PublicKey; - payer?: PublicKey; - }) { - const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0]; - - return this.autocrat.methods - .stakeToProposal({ amount }) - .accounts({ - proposal, - dao, - stakerBaseAccount: getAssociatedTokenAddressSync( - baseMint, - staker, - true, - ), - proposalBaseAccount: getAssociatedTokenAddressSync( - baseMint, - proposal, - true, - ), - stakeAccount, - staker, - payer, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(baseMint, staker, true), - staker, - baseMint, - ), - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(baseMint, proposal, true), - proposal, - baseMint, - ), - ]); - } - - unstakeFromProposalIx({ - proposal, - dao, - baseMint, - amount, - staker = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - baseMint: PublicKey; - amount: BN; - staker?: PublicKey; - }) { - const stakeAccount = getStakeAddr(FUTARCHY_PROGRAM_ID, proposal, staker)[0]; - - return this.autocrat.methods.unstakeFromProposal({ amount }).accounts({ - proposal, - dao, - stakerBaseAccount: getAssociatedTokenAddressSync(baseMint, staker, true), - proposalBaseAccount: getAssociatedTokenAddressSync( - baseMint, - proposal, - true, - ), - stakeAccount, - staker, - baseMint, - tokenProgram: TOKEN_PROGRAM_ID, - }); - } - - collectFeesIx({ - dao, - baseMint, - quoteMint, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - }) { - // Hardcode destination to MetaDAO multisig vault - const baseTokenAccount = getAssociatedTokenAddressSync( - baseMint, - METADAO_MULTISIG_VAULT, - true, - ); - const quoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - METADAO_MULTISIG_VAULT, - true, - ); - - return this.autocrat.methods.collectFees().accounts({ - dao, - admin: this.provider.publicKey, - ammBaseVault: getAssociatedTokenAddressSync(baseMint, dao, true), - ammQuoteVault: getAssociatedTokenAddressSync(quoteMint, dao, true), - baseTokenAccount, - quoteTokenAccount, - }); - } - - sponsorProposalIx({ - proposal, - dao, - teamAddress = this.provider.publicKey, - }: { - proposal: PublicKey; - dao: PublicKey; - teamAddress?: PublicKey; - }) { - return this.autocrat.methods.sponsorProposal().accounts({ - proposal, - dao, - teamAddress, - }); - } - - collectMeteoraDammFeesIx({ - dao, - baseMint, - quoteMint = MAINNET_USDC, - transactionIndex, - meteoraConfig = MAINNET_METEORA_CONFIG, - admin = this.provider.publicKey, - }: { - dao: PublicKey; - baseMint: PublicKey; - quoteMint?: PublicKey; - transactionIndex: bigint; - meteoraConfig?: PublicKey; - admin?: PublicKey; - }) { - // Squads accounts - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - const squadsMultisigVaultTransaction = multisig.getTransactionPda({ - multisigPda, - index: transactionIndex, - })[0]; - const squadsMultisigProposal = multisig.getProposalPda({ - multisigPda, - transactionIndex, - })[0]; - - // Token accounts for receiving fees - const baseTokenAccount = getAssociatedTokenAddressSync( - baseMint, - METADAO_MULTISIG_VAULT, - true, - ); - const quoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - METADAO_MULTISIG_VAULT, - true, - ); - - // Helper function to sort mints for Meteora pool PDA - const sortMints = ( - mint1: PublicKey, - mint2: PublicKey, - ): [Buffer, Buffer] => { - const buf1 = mint1.toBuffer(); - const buf2 = mint2.toBuffer(); - if (Buffer.compare(buf1, buf2) > 0) { - return [buf1, buf2]; - } - return [buf2, buf1]; - }; - - const [sortedMint1, sortedMint2] = sortMints(baseMint, quoteMint); - - // Meteora DAMM accounts - const [pool] = PublicKey.findProgramAddressSync( - [Buffer.from("pool"), meteoraConfig.toBuffer(), sortedMint1, sortedMint2], - DAMM_V2_PROGRAM_ID, - ); - - const [positionNftMint] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_mint"), baseMint.toBuffer()], - LAUNCHPAD_PROGRAM_ID, - ); - - const [positionNftAccount] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [position] = PublicKey.findProgramAddressSync( - [Buffer.from("position"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - - return this.autocrat.methods.collectMeteoraDammFees().accounts({ - dao, - admin, - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsMultisigVaultTransaction, - squadsMultisigProposal, - squadsMultisigPermissionlessAccount: PERMISSIONLESS_ACCOUNT.publicKey, - meteoraClaimPositionFeesAccounts: { - dammV2Program: DAMM_V2_PROGRAM_ID, - dammV2EventAuthority, - poolAuthority: DAMM_V2_POOL_AUTHORITY, - pool, - position, - tokenAAccount: baseTokenAccount, - tokenBAccount: quoteTokenAccount, - tokenAVault, - tokenBVault, - tokenAMint: baseMint, - tokenBMint: quoteMint, - positionNftAccount, - owner: squadsMultisigVault, - tokenAProgram: TOKEN_PROGRAM_ID, - tokenBProgram: TOKEN_PROGRAM_ID, - }, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - squadsProgram: SQUADS_PROGRAM_ID, - }); - } - - initiateVaultSpendOptimisticProposalIx({ - dao, - quoteMint = MAINNET_USDC, - amount, - recipient, - transactionIndex, - proposer = this.provider.publicKey, - payer = this.provider.publicKey, - }: { - dao: PublicKey; - quoteMint?: PublicKey; - amount: BN; - recipient: PublicKey; - transactionIndex: bigint; - proposer?: PublicKey; - payer?: PublicKey; - }) { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - const squadsMultisigVault = multisig.getVaultPda({ - multisigPda, - index: 0, - })[0]; - const squadsSpendingLimit = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - })[0]; - const squadsProposal = multisig.getProposalPda({ - multisigPda, - transactionIndex, - })[0]; - const squadsVaultTransaction = multisig.getTransactionPda({ - multisigPda, - index: transactionIndex, - })[0]; - - const daoQuoteVaultAccount = getAssociatedTokenAddressSync( - quoteMint, - squadsMultisigVault, - true, - ); - const recipientQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - recipient, - true, - ); - - // Build the SPL token transfer instruction for the vault transaction - const transferIx = createTransferInstruction( - daoQuoteVaultAccount, - recipientQuoteAccount, - squadsMultisigVault, - BigInt(amount.toString()), - ); - - // Use the vault as the payerKey so it deduplicates with the transfer authority, - // producing a clean message with exactly 1 signer (the vault). - const transactionMessage = new TransactionMessage({ - payerKey: squadsMultisigVault, - recentBlockhash: "", - instructions: [transferIx], - }); - - const vaultTxCreate = multisig.instructions.vaultTransactionCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - vaultIndex: 0, - ephemeralSigners: 0, - transactionMessage, - }); - - const proposalCreate = multisig.instructions.proposalCreate({ - multisigPda, - transactionIndex, - creator: PERMISSIONLESS_ACCOUNT.publicKey, - rentPayer: payer, - }); - - return this.autocrat.methods - .initiateVaultSpendOptimisticProposal({ amount }) - .accounts({ - squadsMultisig: multisigPda, - squadsMultisigVault, - squadsSpendingLimit, - squadsProposal, - squadsVaultTransaction, - dao, - daoQuoteVaultAccount, - proposer, - recipient, - recipientQuoteAccount, - squadsProgram: SQUADS_PROGRAM_ID, - tokenProgram: TOKEN_PROGRAM_ID, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - recipientQuoteAccount, - recipient, - quoteMint, - ), - vaultTxCreate, - proposalCreate, - ]); - } - - finalizeOptimisticProposalIx({ - dao, - squadsProposal, - }: { - dao: PublicKey; - squadsProposal: PublicKey; - }) { - const multisigPda = multisig.getMultisigPda({ createKey: dao })[0]; - - return this.autocrat.methods.finalizeOptimisticProposal().accounts({ - squadsMultisig: multisigPda, - squadsProposal, - dao, - squadsProgram: SQUADS_PROGRAM_ID, - }); - } -} diff --git a/sdk/src/v0.7/LaunchpadClient.ts b/sdk/src/v0.7/LaunchpadClient.ts deleted file mode 100644 index 70c31f45c..000000000 --- a/sdk/src/v0.7/LaunchpadClient.ts +++ /dev/null @@ -1,766 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Keypair, - AccountInfo, - ComputeBudgetProgram, - SystemProgram, -} from "@solana/web3.js"; -import { - LaunchpadV7 as Launchpad, - IDL as LaunchpadIDL, -} from "./types/launchpad_v7.js"; -import { - LAUNCHPAD_PROGRAM_ID, - RAYDIUM_AUTHORITY, - LOW_FEE_RAYDIUM_CONFIG, - RAYDIUM_CP_SWAP_PROGRAM_ID, - RAYDIUM_CREATE_POOL_FEE_RECEIVE, - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - DEVNET_RAYDIUM_AUTHORITY, - DEVNET_LOW_FEE_RAYDIUM_CONFIG, - DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE, - MPL_TOKEN_METADATA_PROGRAM_ID, - MAINNET_USDC, - DEVNET_USDC, - SQUADS_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG, - SQUADS_PROGRAM_CONFIG_TREASURY, - DAMM_V2_PROGRAM_ID, - SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET, - MAINNET_METEORA_CONFIG, - METADAO_MULTISIG_VAULT, -} from "./constants.js"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - createAssociatedTokenAccountIdempotentInstruction, - getAssociatedTokenAddressSync, - TOKEN_2022_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { FundingRecord, Launch } from "./types/index.js"; -import { - getDaoAddr, - getEventAuthorityAddr, - getFundingRecordAddr, - getLaunchAddr, - getLaunchSignerAddr, - getMetadataAddr, - getPerformancePackageAddr, -} from "./utils/pda.js"; -import { FutarchyClient } from "./FutarchyClient.js"; -import * as anchor from "@coral-xyz/anchor"; -import * as multisig from "@sqds/multisig"; -import { PriceBasedPerformancePackageClient } from "./PriceBasedPerformancePackageClient.js"; -import { BidWallClient } from "./BidWallClient.js"; - -export type CreateLaunchpadClientParams = { - provider: AnchorProvider; - launchpadProgramId?: PublicKey; - autocratProgramId?: PublicKey; - conditionalVaultProgramId?: PublicKey; - priceBasedUnlockProgramId?: PublicKey; - bidWallProgramId?: PublicKey; -}; - -export class LaunchpadClient { - public launchpad: Program; - public provider: AnchorProvider; - public autocratClient: FutarchyClient; - public priceBasedUnlock: PriceBasedPerformancePackageClient; - public bidWall: BidWallClient; - - private constructor(params: CreateLaunchpadClientParams) { - this.provider = params.provider; - this.launchpad = new Program( - LaunchpadIDL, - params.launchpadProgramId || LAUNCHPAD_PROGRAM_ID, - this.provider, - ); - this.autocratClient = FutarchyClient.createClient({ - provider: this.provider, - autocratProgramId: params.autocratProgramId, - conditionalVaultProgramId: params.conditionalVaultProgramId, - }); - this.priceBasedUnlock = PriceBasedPerformancePackageClient.createClient({ - provider: this.provider, - priceBasedTokenLockProgramId: params.priceBasedUnlockProgramId, - }); - this.bidWall = BidWallClient.createClient({ - provider: this.provider, - bidWallProgramId: params.bidWallProgramId, - }); - } - - static createClient(params: CreateLaunchpadClientParams): LaunchpadClient { - return new LaunchpadClient(params); - } - - getProgramId(): PublicKey { - return this.launchpad.programId; - } - - async getLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetch(launch); - } - - async fetchLaunch(launch: PublicKey): Promise { - return await this.launchpad.account.launch.fetchNullable(launch); - } - - async deserializeLaunch(accountInfo: AccountInfo): Promise { - return this.launchpad.coder.accounts.decode("launch", accountInfo.data); - } - - async getFundingRecord(fundingRecord: PublicKey): Promise { - return await this.launchpad.account.fundingRecord.fetch(fundingRecord); - } - - async fetchFundingRecord( - fundingRecord: PublicKey, - ): Promise { - return await this.launchpad.account.fundingRecord.fetchNullable( - fundingRecord, - ); - } - - async deserializeFundingRecord( - accountInfo: AccountInfo, - ): Promise { - return this.launchpad.coder.accounts.decode( - "fundingRecord", - accountInfo.data, - ); - } - - initializeLaunchIx({ - tokenName, - tokenSymbol, - tokenUri, - minimumRaiseAmount, - secondsForLaunch = 60 * 60 * 24 * 5, // 5 days - baseMint, - quoteMint = MAINNET_USDC, - monthlySpendingLimitAmount, - monthlySpendingLimitMembers, - performancePackageGrantee, - performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, - teamAddress, - launchAuthority = this.provider.publicKey, - payer = this.provider.publicKey, - additionalTokensRecipient, - additionalTokensAmount, - accumulatorActivationDelaySeconds = 0, - hasBidWall = false, - }: { - tokenName: string; - tokenSymbol: string; - tokenUri: string; - minimumRaiseAmount: BN; - secondsForLaunch?: number; - baseMint: PublicKey; - quoteMint?: PublicKey; - monthlySpendingLimitAmount: BN; - monthlySpendingLimitMembers: PublicKey[]; - performancePackageGrantee: PublicKey; - performancePackageTokenAmount: BN; - monthsUntilInsidersCanUnlock: number; - teamAddress: PublicKey; - launchAuthority?: PublicKey; - payer?: PublicKey; - additionalTokensRecipient?: PublicKey; - additionalTokensAmount?: BN; - accumulatorActivationDelaySeconds?: number; - hasBidWall: boolean; - }) { - const [launch] = getLaunchAddr(this.launchpad.programId, baseMint); - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const quoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - - const baseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - const [tokenMetadata] = getMetadataAddr(baseMint); - - return this.launchpad.methods - .initializeLaunch({ - minimumRaiseAmount, - secondsForLaunch, - tokenName, - tokenSymbol, - tokenUri, - monthlySpendingLimitAmount, - monthlySpendingLimitMembers, - performancePackageGrantee, - performancePackageTokenAmount, - monthsUntilInsidersCanUnlock, - teamAddress, - additionalTokensAmount: additionalTokensAmount ?? new BN(0), - accumulatorActivationDelaySeconds, - hasBidWall, - }) - .accounts({ - launch, - launchSigner, - quoteVault, - baseVault, - launchAuthority, - quoteMint, - baseMint, - tokenMetadata, - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - payer, - additionalTokensRecipient: additionalTokensRecipient ?? null, - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - payer, - getAssociatedTokenAddressSync(quoteMint, launchSigner, true), - launchSigner, - quoteMint, - ), - ]); - // .signers([tokenMintKp]); - } - - startLaunchIx({ - launch, - launchAuthority = this.provider.publicKey, - }: { - launch: PublicKey; - launchAuthority?: PublicKey; - }) { - return this.launchpad.methods.startLaunch().accounts({ - launch, - launchAuthority, - }); - } - - fundIx({ - launch, - amount, - funder = this.provider.publicKey, - quoteMint = MAINNET_USDC, - }: { - launch: PublicKey; - amount: BN; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods.fund(amount).accounts({ - launch, - launchQuoteVault, - fundingRecord, - funder, - funderQuoteAccount, - }); - } - - closeLaunchIx({ launch }: { launch: PublicKey }) { - return this.launchpad.methods.closeLaunch().accounts({ - launch, - }); - } - - completeLaunchIx({ - launch, - quoteMint = MAINNET_USDC, - baseMint, - launchAuthority, - isDevnet = false, - meteoraConfig = MAINNET_METEORA_CONFIG, - feeRecipient = METADAO_MULTISIG_VAULT, - }: { - launch: PublicKey; - quoteMint?: PublicKey; - baseMint: PublicKey; - launchAuthority: PublicKey | null; - isDevnet?: boolean; - meteoraConfig?: PublicKey; - feeRecipient?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const launchBaseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - - // const daoKp = Keypair.generate(); - const [dao] = getDaoAddr({ - nonce: new BN(0), - daoCreator: launchSigner, - }); - - const [futarchyEventAuthority] = getEventAuthorityAddr( - this.autocratClient.getProgramId(), - ); - - const [tokenMetadata] = getMetadataAddr(baseMint); - - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ - multisigPda, - index: 0, - }); - - const [spendingLimit] = multisig.getSpendingLimitPda({ - multisigPda, - createKey: dao, - }); - - const treasuryQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - multisigVault, - true, - ); - - const [ammPosition] = PublicKey.findProgramAddressSync( - [Buffer.from("amm_position"), dao.toBuffer(), multisigVault.toBuffer()], - this.autocratClient.getProgramId(), - ); - - const [performancePackage] = getPerformancePackageAddr({ - createKey: launchSigner, - }); - const performancePackageTokenAccount = getAssociatedTokenAddressSync( - baseMint, - performancePackage, - true, - ); - - const [poolAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("pool_authority")], - DAMM_V2_PROGRAM_ID, - ); - - const [positionNftMint] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_mint"), baseMint.toBuffer()], - LAUNCHPAD_PROGRAM_ID, - ); - - const [positionNftAccount] = PublicKey.findProgramAddressSync( - [Buffer.from("position_nft_account"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - function getFirstKey(key1: PublicKey, key2: PublicKey) { - const buf1 = key1.toBuffer(); - const buf2 = key2.toBuffer(); - // Buf1 > buf2 - if (Buffer.compare(buf1, buf2) === 1) { - return buf1; - } - return buf2; - } - - function getSecondKey(key1: PublicKey, key2: PublicKey) { - const buf1 = key1.toBuffer(); - const buf2 = key2.toBuffer(); - // Buf1 > buf2 - if (Buffer.compare(buf1, buf2) === 1) { - return buf2; - } - return buf1; - } - - const [pool] = PublicKey.findProgramAddressSync( - [ - Buffer.from("pool"), - meteoraConfig.toBuffer(), - getFirstKey(baseMint, quoteMint), - getSecondKey(baseMint, quoteMint), - ], - DAMM_V2_PROGRAM_ID, - ); - - const [position] = PublicKey.findProgramAddressSync( - [Buffer.from("position"), positionNftMint.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenAVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), baseMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [tokenBVault] = PublicKey.findProgramAddressSync( - [Buffer.from("token_vault"), quoteMint.toBuffer(), pool.toBuffer()], - DAMM_V2_PROGRAM_ID, - ); - - const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( - [Buffer.from("damm_pool_creator_authority")], - LAUNCHPAD_PROGRAM_ID, - ); - - const [dammV2EventAuthority] = getEventAuthorityAddr(DAMM_V2_PROGRAM_ID); - - const bidWall = this.bidWall.getBidWallAddress({ - baseMint, - creator: launchSigner, - nonce: new BN(0), - }); - const bidWallQuoteTokenAccount = getAssociatedTokenAddressSync( - quoteMint, - bidWall, - true, - ); - - return this.launchpad.methods - .completeLaunch() - .accounts({ - launch, - launchSigner, - launchQuoteVault, - launchBaseVault, - launchAuthority, - dao, - treasuryQuoteAccount, - quoteMint, - baseMint, - tokenMetadata, - daoOwnedLpPosition: ammPosition, - futarchyAmmQuoteVault: getAssociatedTokenAddressSync( - quoteMint, - dao, - true, - ), - futarchyAmmBaseVault: getAssociatedTokenAddressSync( - baseMint, - dao, - true, - ), - staticAccounts: { - futarchyProgram: this.autocratClient.getProgramId(), - tokenMetadataProgram: MPL_TOKEN_METADATA_PROGRAM_ID, - futarchyEventAuthority, - squadsProgram: SQUADS_PROGRAM_ID, - squadsProgramConfig: SQUADS_PROGRAM_CONFIG, - squadsProgramConfigTreasury: isDevnet - ? SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET - : SQUADS_PROGRAM_CONFIG_TREASURY, - bidWallProgram: this.bidWall.programId, - bidWallEventAuthority: this.bidWall.getEventAuthorityAddress(), - }, - squadsMultisig: multisigPda, - squadsMultisigVault: multisigVault, - spendingLimit, - bidWall, - bidWallQuoteTokenAccount, - feeRecipient, - meteoraAccounts: { - dammV2Program: DAMM_V2_PROGRAM_ID, - positionNftMint, - baseMint, - quoteMint, - config: meteoraConfig, - token2022Program: TOKEN_2022_PROGRAM_ID, - positionNftAccount, - pool, - // baseMint, - // quoteMint, - poolCreatorAuthority, - position, - tokenAVault, - tokenBVault, - poolAuthority, - dammV2EventAuthority, - }, - // poolCreatorAuthority, - }) - .preInstructions([ - ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000 }), - ComputeBudgetProgram.requestHeapFrame({ bytes: 255 * 1024 }), - ]); - } - - refundIx({ - launch, - funder = this.provider.publicKey, - quoteMint = MAINNET_USDC, - }: { - launch: PublicKey; - funder?: PublicKey; - quoteMint?: PublicKey; - }) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - const launchQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - launchSigner, - true, - ); - const funderQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - funder, - true, - ); - - return this.launchpad.methods.refund().accounts({ - launch, - launchSigner, - launchQuoteVault, - funder, - funderQuoteAccount, - fundingRecord, - }); - } - - claimIx( - launch: PublicKey, - baseMint: PublicKey, - funder: PublicKey = this.provider.publicKey, - ) { - const [launchSigner] = getLaunchSignerAddr( - this.launchpad.programId, - launch, - ); - const [fundingRecord] = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - ); - - return this.launchpad.methods - .claim() - .accounts({ - launch, - fundingRecord, - launchSigner, - funder, - funderTokenAccount: getAssociatedTokenAddressSync( - baseMint, - funder, - true, - ), - baseMint, - launchBaseVault: getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ), - }) - .preInstructions([ - createAssociatedTokenAccountIdempotentInstruction( - this.provider.publicKey, - getAssociatedTokenAddressSync(baseMint, funder, true), - funder, - baseMint, - ), - ]); - } - - setFundingRecordApprovalIx({ - launch, - funder, - launchAuthority = this.provider.publicKey, - approvedAmount, - }: { - launch: PublicKey; - funder: PublicKey; - launchAuthority?: PublicKey; - approvedAmount: BN; - }) { - let fundingRecord = getFundingRecordAddr( - this.launchpad.programId, - launch, - funder, - )[0]; - - return this.launchpad.methods - .setFundingRecordApproval(approvedAmount) - .accounts({ - launch, - fundingRecord, - launchAuthority, - }); - } - - claimAdditionalTokenAllocationIx({ - launch, - baseMint, - additionalTokensRecipient, - payer = this.provider.publicKey, - }: { - launch: PublicKey; - baseMint: PublicKey; - additionalTokensRecipient: PublicKey; - payer?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - return this.launchpad.methods.claimAdditionalTokenAllocation().accounts({ - launch, - payer, - launchSigner, - launchBaseVault: getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ), - baseMint, - additionalTokensRecipient, - additionalTokensRecipientTokenAccount: getAssociatedTokenAddressSync( - baseMint, - additionalTokensRecipient, - true, - ), - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - initializePerformancePackageIx({ - launch, - baseMint, - payer = this.provider.publicKey, - }: { - launch: PublicKey; - baseMint: PublicKey; - payer?: PublicKey; - }) { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - const [dao] = getDaoAddr({ - nonce: new BN(0), - daoCreator: launchSigner, - }); - - const [multisigPda] = multisig.getMultisigPda({ createKey: dao }); - const [multisigVault] = multisig.getVaultPda({ - multisigPda, - index: 0, - }); - - const launchBaseVault = getAssociatedTokenAddressSync( - baseMint, - launchSigner, - true, - ); - - const performancePackage = this.getLaunchPerformancePackageAddress({ - launch, - }); - - const performancePackageTokenAccount = getAssociatedTokenAddressSync( - baseMint, - performancePackage, - true, - ); - - return this.launchpad.methods.initializePerformancePackage().accounts({ - launch, - performancePackage, - performancePackageTokenAccount, - dao, - squadsMultisig: multisigPda, - squadsMultisigVault: multisigVault, - launchBaseVault, - baseMint, - payer, - launchSigner, - squadsProgram: SQUADS_PROGRAM_ID, - priceBasedPerformancePackageEventAuthority: - this.priceBasedUnlock.getEventAuthorityAddress(), - priceBasedPerformancePackageProgram: this.priceBasedUnlock.programId, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }); - } - - extendLaunchIx({ - launch, - durationSeconds, - admin = METADAO_MULTISIG_VAULT, - }: { - launch: PublicKey; - durationSeconds: number; - admin?: PublicKey; - }) { - return this.launchpad.methods.extendLaunch({ durationSeconds }).accounts({ - launch, - admin, - }); - } - - getLaunchAddress({ baseMint }: { baseMint: PublicKey }): PublicKey { - return getLaunchAddr(this.launchpad.programId, baseMint)[0]; - } - - getLaunchSignerAddress({ launch }: { launch: PublicKey }): PublicKey { - return getLaunchSignerAddr(this.launchpad.programId, launch)[0]; - } - - getLaunchPerformancePackageAddress({ - launch, - }: { - launch: PublicKey; - }): PublicKey { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - return getPerformancePackageAddr({ createKey: launchSigner })[0]; - } - - getLaunchDaoAddress({ launch }: { launch: PublicKey }): PublicKey { - const launchSigner = this.getLaunchSignerAddress({ launch }); - - return getDaoAddr({ nonce: new BN(0), daoCreator: launchSigner })[0]; - } - - getFundingRecordAddress({ - launch, - funder, - }: { - launch: PublicKey; - funder: PublicKey; - }): PublicKey { - return getFundingRecordAddr(this.launchpad.programId, launch, funder)[0]; - } -} diff --git a/sdk/src/v0.7/LiquidationClient.ts b/sdk/src/v0.7/LiquidationClient.ts deleted file mode 100644 index 1c0724330..000000000 --- a/sdk/src/v0.7/LiquidationClient.ts +++ /dev/null @@ -1,338 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import BN from "bn.js"; -import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - getAssociatedTokenAddressSync, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { LIQUIDATION_PROGRAM_ID } from "../v0.7/constants.js"; -import { - LiquidationProgram, - LiquidationIDL, - LiquidationAccount, - RefundRecordAccount, -} from "../v0.7/types/index.js"; -import { - getLiquidationAddr, - getRefundRecordAddr, - getEventAuthorityAddr, -} from "../v0.7/utils/pda.js"; - -export type CreateLiquidationClientParams = { - provider: AnchorProvider; - liquidationProgramId?: PublicKey; -}; - -export class LiquidationClient { - public readonly provider: AnchorProvider; - public readonly liquidationProgram: Program; - public readonly programId: PublicKey; - - constructor(provider: AnchorProvider, liquidationProgramId: PublicKey) { - this.provider = provider; - this.programId = liquidationProgramId; - this.liquidationProgram = new Program( - LiquidationIDL, - liquidationProgramId, - provider, - ); - } - - public static createClient( - createLiquidationClientParams: CreateLiquidationClientParams, - ): LiquidationClient { - let { provider, liquidationProgramId } = createLiquidationClientParams; - - return new LiquidationClient( - provider, - liquidationProgramId || LIQUIDATION_PROGRAM_ID, - ); - } - - public getProgramId(): PublicKey { - return this.programId; - } - - async fetchLiquidation( - liquidation: PublicKey, - ): Promise { - return this.liquidationProgram.account.liquidation.fetchNullable( - liquidation, - ); - } - - async deserializeLiquidation( - accountInfo: AccountInfo, - ): Promise { - return this.liquidationProgram.coder.accounts.decode( - "liquidation", - accountInfo.data, - ); - } - - async fetchRefundRecord( - refundRecord: PublicKey, - ): Promise { - return this.liquidationProgram.account.refundRecord.fetchNullable( - refundRecord, - ); - } - - async deserializeRefundRecord( - accountInfo: AccountInfo, - ): Promise { - return this.liquidationProgram.coder.accounts.decode( - "refundRecord", - accountInfo.data, - ); - } - - async getLiquidation({ - baseMint, - quoteMint, - createKey, - }: { - baseMint: PublicKey; - quoteMint: PublicKey; - createKey: PublicKey; - }): Promise { - const liquidation = this.getLiquidationAddress({ - baseMint, - quoteMint, - createKey, - }); - return this.fetchLiquidation(liquidation); - } - - initializeLiquidationIx({ - durationSeconds, - createKey, - recordAuthority, - liquidationAuthority, - baseMint, - quoteMint, - payer = this.provider.publicKey, - }: { - durationSeconds: number; - createKey: PublicKey; - recordAuthority: PublicKey; - liquidationAuthority: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - payer?: PublicKey; - }) { - const liquidation = this.getLiquidationAddress({ - baseMint, - quoteMint, - createKey, - }); - - const liquidationQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - liquidation, - true, - ); - - return this.liquidationProgram.methods - .initializeLiquidation({ durationSeconds }) - .accounts({ - payer, - createKey, - recordAuthority, - liquidationAuthority, - baseMint, - quoteMint, - liquidation, - liquidationQuoteVault, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - setRefundRecordIx({ - baseAssigned, - quoteRefundable, - recordAuthority, - liquidation, - recipient, - payer = this.provider.publicKey, - }: { - baseAssigned: BN; - quoteRefundable: BN; - recordAuthority: PublicKey; - liquidation: PublicKey; - recipient: PublicKey; - payer?: PublicKey; - }) { - const refundRecord = this.getRefundRecordAddress({ - liquidation, - recipient, - }); - - return this.liquidationProgram.methods - .setRefundRecord({ baseAssigned, quoteRefundable }) - .accounts({ - payer, - recordAuthority, - liquidation, - recipient, - refundRecord, - systemProgram: SystemProgram.programId, - }); - } - - activateLiquidationIx({ - liquidationAuthority, - liquidation, - liquidationAuthorityQuoteAccount, - quoteMint, - }: { - liquidationAuthority: PublicKey; - liquidation: PublicKey; - liquidationAuthorityQuoteAccount?: PublicKey; - quoteMint: PublicKey; - }) { - const liquidationQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - liquidation, - true, - ); - - const resolvedLiquidationAuthorityQuoteAccount = - liquidationAuthorityQuoteAccount ?? - getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true); - - return this.liquidationProgram.methods.activateLiquidation().accounts({ - liquidationAuthority, - liquidation, - liquidationAuthorityQuoteAccount: - resolvedLiquidationAuthorityQuoteAccount, - liquidationQuoteVault, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - }); - } - - refundIx({ - recipient, - liquidation, - baseMint, - recipientBaseAccount, - quoteMint, - }: { - recipient: PublicKey; - liquidation: PublicKey; - baseMint: PublicKey; - recipientBaseAccount?: PublicKey; - quoteMint: PublicKey; - }) { - const refundRecord = this.getRefundRecordAddress({ - liquidation, - recipient, - }); - - const resolvedRecipientBaseAccount = - recipientBaseAccount ?? - getAssociatedTokenAddressSync(baseMint, recipient, true); - - const liquidationQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - liquidation, - true, - ); - - const recipientQuoteAccount = getAssociatedTokenAddressSync( - quoteMint, - recipient, - true, - ); - - return this.liquidationProgram.methods.refund().accounts({ - recipient, - liquidation, - refundRecord, - baseMint, - recipientBaseAccount: resolvedRecipientBaseAccount, - liquidationQuoteVault, - recipientQuoteAccount, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - }); - } - - withdrawRemainingQuoteIx({ - liquidationAuthority, - liquidation, - liquidationAuthorityQuoteAccount, - quoteMint, - }: { - liquidationAuthority: PublicKey; - liquidation: PublicKey; - liquidationAuthorityQuoteAccount?: PublicKey; - quoteMint: PublicKey; - }) { - const liquidationQuoteVault = getAssociatedTokenAddressSync( - quoteMint, - liquidation, - true, - ); - - const resolvedLiquidationAuthorityQuoteAccount = - liquidationAuthorityQuoteAccount ?? - getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true); - - return this.liquidationProgram.methods.withdrawRemainingQuote().accounts({ - liquidationAuthority, - liquidation, - liquidationQuoteVault, - liquidationAuthorityQuoteAccount: - resolvedLiquidationAuthorityQuoteAccount, - quoteMint, - tokenProgram: TOKEN_PROGRAM_ID, - }); - } - - async getRefundRecord({ - liquidation, - recipient, - }: { - liquidation: PublicKey; - recipient: PublicKey; - }): Promise { - const refundRecord = this.getRefundRecordAddress({ - liquidation, - recipient, - }); - return this.fetchRefundRecord(refundRecord); - } - - public getLiquidationAddress({ - baseMint, - quoteMint, - createKey, - }: { - baseMint: PublicKey; - quoteMint: PublicKey; - createKey: PublicKey; - }): PublicKey { - return getLiquidationAddr({ baseMint, quoteMint, createKey })[0]; - } - - public getRefundRecordAddress({ - liquidation, - recipient, - }: { - liquidation: PublicKey; - recipient: PublicKey; - }): PublicKey { - return getRefundRecordAddr({ liquidation, recipient })[0]; - } - - public getEventAuthorityAddress(): PublicKey { - return getEventAuthorityAddr(this.programId)[0]; - } -} diff --git a/sdk/src/v0.7/MintGovernorClient.ts b/sdk/src/v0.7/MintGovernorClient.ts deleted file mode 100644 index b23689866..000000000 --- a/sdk/src/v0.7/MintGovernorClient.ts +++ /dev/null @@ -1,251 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { AccountInfo, PublicKey } from "@solana/web3.js"; -import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; -import { MINT_GOVERNOR_PROGRAM_ID } from "./constants.js"; -import { getMintGovernorAddr, getMintAuthorityAddr } from "./utils/pda.js"; -import BN from "bn.js"; -import { - MintGovernor as MintGovernorProgram, - IDL as MintGovernorIDL, -} from "./types/mint_governor.js"; -import type { - MintGovernorAccount, - MintAuthorityAccount, -} from "./types/index.js"; - -export type CreateMintGovernorClientParams = { - provider: AnchorProvider; - programId?: PublicKey; -}; - -export class MintGovernorClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly programId: PublicKey; - - constructor(provider: AnchorProvider, programId: PublicKey) { - this.provider = provider; - this.programId = programId; - this.program = new Program( - MintGovernorIDL, - programId, - provider, - ); - } - - public static createClient( - params: CreateMintGovernorClientParams, - ): MintGovernorClient { - const { provider, programId } = params; - return new MintGovernorClient( - provider, - programId || MINT_GOVERNOR_PROGRAM_ID, - ); - } - - async fetchMintGovernor( - mintGovernor: PublicKey, - ): Promise { - return this.program.account.mintGovernor.fetchNullable(mintGovernor); - } - - async deserializeMintGovernor( - accountInfo: AccountInfo, - ): Promise { - return this.program.coder.accounts.decode("mintGovernor", accountInfo.data); - } - - async fetchMintAuthority( - mintAuthority: PublicKey, - ): Promise { - return this.program.account.mintAuthority.fetchNullable(mintAuthority); - } - - async deserializeMintAuthority( - accountInfo: AccountInfo, - ): Promise { - return this.program.coder.accounts.decode( - "mintAuthority", - accountInfo.data, - ); - } - - initializeMintGovernorIx({ - mint, - createKey, - admin, - payer = this.provider.publicKey, - }: { - mint: PublicKey; - createKey: PublicKey; - admin: PublicKey; - payer?: PublicKey; - }) { - const [mintGovernor] = getMintGovernorAddr({ - programId: this.programId, - mint, - createKey, - }); - - return this.program.methods.initializeMintGovernor().accounts({ - mint, - mintGovernor, - createKey, - admin, - payer, - }); - } - - transferAuthorityToGovernorIx({ - mintGovernor, - mint, - currentAuthority, - tokenProgram = TOKEN_PROGRAM_ID, - }: { - mintGovernor: PublicKey; - mint: PublicKey; - currentAuthority: PublicKey; - tokenProgram?: PublicKey; - }) { - return this.program.methods.transferAuthorityToGovernor().accounts({ - mintGovernor, - mint, - currentAuthority, - tokenProgram, - }); - } - - addMintAuthorityIx({ - mintGovernor, - admin, - authorizedMinter, - payer = this.provider.publicKey, - maxTotal, - }: { - mintGovernor: PublicKey; - admin: PublicKey; - authorizedMinter: PublicKey; - payer?: PublicKey; - maxTotal: BN | null; - }) { - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.programId, - mintGovernor, - authorizedMinter, - }); - - return this.program.methods.addMintAuthority({ maxTotal }).accounts({ - mintGovernor, - mintAuthority, - admin, - authorizedMinter, - payer, - }); - } - - updateMintAuthorityIx({ - mintGovernor, - mintAuthority, - admin, - maxTotal, - }: { - mintGovernor: PublicKey; - mintAuthority: PublicKey; - admin: PublicKey; - maxTotal: BN | null; - }) { - return this.program.methods.updateMintAuthority({ maxTotal }).accounts({ - mintGovernor, - mintAuthority, - admin, - }); - } - - removeMintAuthorityIx({ - mintGovernor, - mintAuthority, - admin, - rentDestination, - }: { - mintGovernor: PublicKey; - mintAuthority: PublicKey; - admin: PublicKey; - rentDestination: PublicKey; - }) { - return this.program.methods.removeMintAuthority().accounts({ - mintGovernor, - mintAuthority, - admin, - rentDestination, - }); - } - - mintTokensIx({ - mintGovernor, - mint, - destinationAta, - authorizedMinter, - tokenProgram = TOKEN_PROGRAM_ID, - amount, - }: { - mintGovernor: PublicKey; - mint: PublicKey; - destinationAta: PublicKey; - authorizedMinter: PublicKey; - tokenProgram?: PublicKey; - amount: BN; - }) { - const [mintAuthority] = getMintAuthorityAddr({ - programId: this.programId, - mintGovernor, - authorizedMinter, - }); - - return this.program.methods.mintTokens({ amount }).accounts({ - mintGovernor, - mintAuthority, - mint, - destinationAta, - authorizedMinter, - tokenProgram, - }); - } - - updateMintGovernorAdminIx({ - mintGovernor, - admin, - newAdmin, - }: { - mintGovernor: PublicKey; - admin: PublicKey; - newAdmin: PublicKey; - }) { - return this.program.methods.updateMintGovernorAdmin().accounts({ - mintGovernor, - admin, - newAdmin, - }); - } - - reclaimAuthorityIx({ - mintGovernor, - mint, - admin, - newAuthority, - tokenProgram = TOKEN_PROGRAM_ID, - }: { - mintGovernor: PublicKey; - mint: PublicKey; - admin: PublicKey; - newAuthority: PublicKey; - tokenProgram?: PublicKey; - }) { - return this.program.methods.reclaimAuthority().accounts({ - mintGovernor, - mint, - admin, - newAuthority, - tokenProgram, - }); - } -} diff --git a/sdk/src/v0.7/PerformancePackageV2Client.ts b/sdk/src/v0.7/PerformancePackageV2Client.ts deleted file mode 100644 index 597b38eb5..000000000 --- a/sdk/src/v0.7/PerformancePackageV2Client.ts +++ /dev/null @@ -1,310 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { AccountInfo, PublicKey, SystemProgram } from "@solana/web3.js"; -import { - TOKEN_PROGRAM_ID, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - MINT_GOVERNOR_PROGRAM_ID, -} from "./constants.js"; -import { - getPerformancePackageV2Addr, - getChangeRequestV2Addr, - getEventAuthorityAddr, -} from "./utils/pda.js"; -import { - PerformancePackageV2 as PerformancePackageV2Program, - IDL as PerformancePackageV2IDL, -} from "./types/performance_package_v2.js"; -import type { - PerformancePackageV2Account, - PerformancePackageV2ChangeRequestAccount, - PerformancePackageV2OracleReader, - PerformancePackageV2RewardFunction, -} from "./types/index.js"; - -export type CreatePerformancePackageV2ClientParams = { - provider: AnchorProvider; - programId?: PublicKey; -}; - -export class PerformancePackageV2Client { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly programId: PublicKey; - - constructor(provider: AnchorProvider, programId: PublicKey) { - this.provider = provider; - this.programId = programId; - this.program = new Program( - PerformancePackageV2IDL, - programId, - provider, - ); - } - - public static createClient( - params: CreatePerformancePackageV2ClientParams, - ): PerformancePackageV2Client { - const { provider, programId } = params; - return new PerformancePackageV2Client( - provider, - programId || PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - ); - } - - getPerformancePackageAddr(createKey: PublicKey): [PublicKey, number] { - return getPerformancePackageV2Addr({ - programId: this.programId, - createKey, - }); - } - - getChangeRequestAddr( - performancePackage: PublicKey, - proposer: PublicKey, - pdaNonce: number, - ): [PublicKey, number] { - return getChangeRequestV2Addr({ - programId: this.programId, - performancePackage, - proposer, - pdaNonce, - }); - } - - async fetchPerformancePackage( - performancePackage: PublicKey, - ): Promise { - return this.program.account.performancePackage.fetchNullable( - performancePackage, - ); - } - - async deserializePerformancePackage( - accountInfo: AccountInfo, - ): Promise { - return this.program.coder.accounts.decode( - "performancePackage", - accountInfo.data, - ); - } - - async fetchChangeRequest( - changeRequest: PublicKey, - ): Promise { - return this.program.account.changeRequest.fetchNullable(changeRequest); - } - - async deserializeChangeRequest( - accountInfo: AccountInfo, - ): Promise { - return this.program.coder.accounts.decode( - "changeRequest", - accountInfo.data, - ); - } - - initializePerformancePackageIx({ - createKey, - mint, - mintGovernor, - mintAuthority, - authority, - recipient, - payer = this.provider.publicKey, - oracleReader, - rewardFunction, - minUnlockTimestamp, - }: { - createKey: PublicKey; - mint: PublicKey; - mintGovernor: PublicKey; - mintAuthority: PublicKey; - authority: PublicKey; - recipient: PublicKey; - payer?: PublicKey; - oracleReader: PerformancePackageV2OracleReader; - rewardFunction: PerformancePackageV2RewardFunction; - minUnlockTimestamp: BN; - }) { - const [performancePackage] = this.getPerformancePackageAddr(createKey); - - return this.program.methods - .initializePerformancePackage({ - oracleReader, - rewardFunction, - minUnlockTimestamp, - }) - .accounts({ - performancePackage, - mint, - mintGovernor, - mintAuthority, - createKey, - authority, - recipient, - payer, - systemProgram: SystemProgram.programId, - }); - } - - startUnlockIx({ - performancePackage, - signer = this.provider.publicKey, - dao, - }: { - performancePackage: PublicKey; - signer?: PublicKey; - dao?: PublicKey; - }) { - const builder = this.program.methods.startUnlock().accounts({ - performancePackage, - signer, - }); - - if (dao) { - return builder.remainingAccounts([ - { pubkey: dao, isSigner: false, isWritable: false }, - ]); - } - - return builder; - } - - completeUnlockIx({ - performancePackage, - mintGovernor, - mintAuthority, - mint, - recipient, - signer = this.provider.publicKey, - dao, - }: { - performancePackage: PublicKey; - mintGovernor: PublicKey; - mintAuthority: PublicKey; - mint: PublicKey; - recipient: PublicKey; - signer?: PublicKey; - dao?: PublicKey; - }) { - const recipientAta = getAssociatedTokenAddressSync(mint, recipient, true); - - const [mintGovernorEventAuthority] = getEventAuthorityAddr( - MINT_GOVERNOR_PROGRAM_ID, - ); - - const builder = this.program.methods.completeUnlock().accounts({ - performancePackage, - mintGovernor, - mintAuthority, - mint, - recipientAta, - signer, - tokenProgram: TOKEN_PROGRAM_ID, - mintGovernorProgram: MINT_GOVERNOR_PROGRAM_ID, - mintGovernorEventAuthority, - }); - - if (dao) { - return builder.remainingAccounts([ - { pubkey: dao, isSigner: false, isWritable: false }, - ]); - } - - return builder; - } - - changeAuthorityIx({ - performancePackage, - authority = this.provider.publicKey, - newAuthority, - }: { - performancePackage: PublicKey; - authority?: PublicKey; - newAuthority: PublicKey; - }) { - return this.program.methods.changeAuthority().accounts({ - performancePackage, - authority, - newAuthority, - }); - } - - proposeChangeIx({ - performancePackage, - proposer = this.provider.publicKey, - payer = this.provider.publicKey, - pdaNonce, - newRecipient = null, - newOracleReader = null, - newRewardFunction = null, - }: { - performancePackage: PublicKey; - proposer?: PublicKey; - payer?: PublicKey; - pdaNonce: number; - newRecipient?: PublicKey | null; - newOracleReader?: PerformancePackageV2OracleReader | null; - newRewardFunction?: PerformancePackageV2RewardFunction | null; - }) { - const [changeRequest] = this.getChangeRequestAddr( - performancePackage, - proposer, - pdaNonce, - ); - - return this.program.methods - .proposeChange({ - pdaNonce, - newRecipient, - newOracleReader, - newRewardFunction, - }) - .accounts({ - performancePackage, - changeRequest, - proposer, - payer, - systemProgram: SystemProgram.programId, - }); - } - - executeChangeIx({ - performancePackage, - changeRequest, - executor = this.provider.publicKey, - rentDestination = this.provider.publicKey, - }: { - performancePackage: PublicKey; - changeRequest: PublicKey; - executor?: PublicKey; - rentDestination?: PublicKey; - }) { - return this.program.methods.executeChange().accounts({ - performancePackage, - changeRequest, - executor, - rentDestination, - }); - } - - closePerformancePackageIx({ - performancePackage, - admin = this.provider.publicKey, - rentDestination = this.provider.publicKey, - }: { - performancePackage: PublicKey; - admin?: PublicKey; - rentDestination?: PublicKey; - }) { - return this.program.methods.closePerformancePackage().accounts({ - performancePackage, - admin, - rentDestination, - }); - } -} diff --git a/sdk/src/v0.7/PriceBasedPerformancePackageClient.ts b/sdk/src/v0.7/PriceBasedPerformancePackageClient.ts deleted file mode 100644 index 116319323..000000000 --- a/sdk/src/v0.7/PriceBasedPerformancePackageClient.ts +++ /dev/null @@ -1,228 +0,0 @@ -import { AnchorProvider, Program } from "@coral-xyz/anchor"; -import { - PublicKey, - Transaction, - TransactionInstruction, - SystemProgram, -} from "@solana/web3.js"; -import { - TOKEN_PROGRAM_ID, - ASSOCIATED_TOKEN_PROGRAM_ID, - getAssociatedTokenAddressSync, -} from "@solana/spl-token"; -import { - PriceBasedPerformancePackage, - IDL as PriceBasedPerformancePackageIDL, -} from "./types/price_based_performance_package.js"; -import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID } from "./constants.js"; -import BN from "bn.js"; -// import { OracleConfig } from "./types/index.js"; -import { - getChangeRequestAddr, - getEventAuthorityAddr, - getPerformancePackageAddr, -} from "./utils/pda.js"; -import { InitializePerformancePackageParams } from "./types/index.js"; - -export type CreatePriceBasedPerformancePackageClientParams = { - provider: AnchorProvider; - priceBasedTokenLockProgramId?: PublicKey; -}; - -export class PriceBasedPerformancePackageClient { - public readonly provider: AnchorProvider; - public readonly program: Program; - public readonly programId: PublicKey; - - constructor( - provider: AnchorProvider, - priceBasedTokenLockProgramId: PublicKey, - ) { - this.provider = provider; - this.programId = priceBasedTokenLockProgramId; - this.program = new Program( - PriceBasedPerformancePackageIDL, - priceBasedTokenLockProgramId, - provider, - ); - } - - public static createClient( - createClientParams: CreatePriceBasedPerformancePackageClientParams, - ): PriceBasedPerformancePackageClient { - let { provider, priceBasedTokenLockProgramId } = createClientParams; - - if (!priceBasedTokenLockProgramId) { - priceBasedTokenLockProgramId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID; - } - - return new PriceBasedPerformancePackageClient( - provider, - priceBasedTokenLockProgramId, - ); - } - - public initializePerformancePackageIx(params: { - params: InitializePerformancePackageParams; - createKey: PublicKey; - tokenMint: PublicKey; - grantor: PublicKey; - grantorTokenAccount?: PublicKey; - }) { - const performancePackage = getPerformancePackageAddr({ - createKey: params.createKey, - })[0]; - - const grantorTokenAccount = - params.grantorTokenAccount ?? - getAssociatedTokenAddressSync(params.tokenMint, params.grantor, true); - - return this.program.methods - .initializePerformancePackage(params.params) - .accounts({ - performancePackage, - createKey: params.createKey, - tokenMint: params.tokenMint, - grantorTokenAccount, - performancePackageTokenVault: getAssociatedTokenAddressSync( - params.tokenMint, - performancePackage, - true, - ), - grantor: params.grantor, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - public startUnlockIx(params: { - performancePackage: PublicKey; - oracleAccount: PublicKey; - recipient: PublicKey; - }) { - return this.program.methods.startUnlock().accounts({ - performancePackage: params.performancePackage, - oracleAccount: params.oracleAccount, - recipient: params.recipient, - }); - } - - public completeUnlockIx(params: { - performancePackage: PublicKey; - oracleAccount: PublicKey; - tokenMint: PublicKey; - tokenRecipient: PublicKey; - }) { - return this.program.methods.completeUnlock().accounts({ - performancePackage: params.performancePackage, - oracleAccount: params.oracleAccount, - performancePackageTokenVault: getAssociatedTokenAddressSync( - params.tokenMint, - params.performancePackage, - true, - ), - tokenMint: params.tokenMint, - recipientTokenAccount: getAssociatedTokenAddressSync( - params.tokenMint, - params.tokenRecipient, - true, - ), - tokenRecipient: params.tokenRecipient, - systemProgram: SystemProgram.programId, - tokenProgram: TOKEN_PROGRAM_ID, - associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, - }); - } - - public proposeChangeIx(params: { - params: { - changeType: any; - pdaNonce: number; - }; - performancePackage: PublicKey; - proposer: PublicKey; - }) { - const changeRequestAddress = this.getChangeRequestAddress( - params.performancePackage, - params.proposer, - params.params.pdaNonce, - ); - - return this.program.methods.proposeChange(params.params).accounts({ - changeRequest: changeRequestAddress, - performancePackage: params.performancePackage, - proposer: params.proposer, - systemProgram: SystemProgram.programId, - }); - } - - public executeChangeIx(params: { - performancePackage: PublicKey; - changeRequest: PublicKey; - executor: PublicKey; - }) { - return this.program.methods.executeChange().accounts({ - changeRequest: params.changeRequest, - performancePackage: params.performancePackage, - executor: params.executor, - }); - } - - public changePerformancePackageAuthorityIx(params: { - performancePackage: PublicKey; - currentAuthority: PublicKey; - newPerformancePackageAuthority: PublicKey; - }) { - return this.program.methods - .changePerformancePackageAuthority({ - newPerformancePackageAuthority: params.newPerformancePackageAuthority, - }) - .accounts({ - performancePackage: params.performancePackage, - currentAuthority: params.currentAuthority, - }); - } - - public async getPerformancePackage(performancePackageAddress: PublicKey) { - return await this.program.account.performancePackage.fetch( - performancePackageAddress, - ); - } - - public async getChangeRequest(changeRequestAddress: PublicKey) { - return await this.program.account.changeRequest.fetch(changeRequestAddress); - } - - public getChangeRequestAddress( - performancePackage: PublicKey, - proposer: PublicKey, - pdaNonce: number, - ): PublicKey { - const [changeRequestAddress] = getChangeRequestAddr({ - programId: this.programId, - performancePackage, - proposer, - pdaNonce, - }); - return changeRequestAddress; - } - - public getPerformancePackageTokenAccountAddress( - performancePackage: PublicKey, - ): PublicKey { - const [performancePackageTokenAccountAddress] = - PublicKey.findProgramAddressSync( - [ - Buffer.from("performance_package_token_account"), - performancePackage.toBuffer(), - ], - this.programId, - ); - return performancePackageTokenAccountAddress; - } - - public getEventAuthorityAddress(): PublicKey { - return getEventAuthorityAddr(this.programId)[0]; - } -} diff --git a/sdk/src/v0.7/constants.ts b/sdk/src/v0.7/constants.ts deleted file mode 100644 index bf3e2322d..000000000 --- a/sdk/src/v0.7/constants.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { Keypair, PublicKey } from "@solana/web3.js"; -import * as anchor from "@coral-xyz/anchor"; -import { BN } from "bn.js"; - -export const FUTARCHY_PROGRAM_ID = new PublicKey( - "FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq", -); -export const AMM_PROGRAM_ID = new PublicKey( - "AMMJdEiCCa8mdugg6JPF7gFirmmxisTfDJoSNSUi5zDJ", -); -export const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( - "VLTX1ishMBbcX3rdBWGssxawAo1Q2X2qxYFYqiGodVg", -); -export const LAUNCHPAD_PROGRAM_ID = new PublicKey( - "moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM", -); -export const SHARED_LIQUIDITY_MANAGER_PROGRAM_ID = new PublicKey( - "EoJc1PYxZbnCjszampLcwJGYcB5Md47jM4oSQacRtD4d", -); -export const PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID = new PublicKey( - "pbPPQH7jyKoSLu8QYs3rSY3YkDRXEBojKbTgnUg7NDS", -); -export const BID_WALL_PROGRAM_ID = new PublicKey( - "WALL8ucBuUyL46QYxwYJjidaFYhdvxUFrgvBxPshERx", -); -export const MINT_GOVERNOR_PROGRAM_ID = new PublicKey( - "gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH", -); -export const PERFORMANCE_PACKAGE_V2_PROGRAM_ID = new PublicKey( - "pPV2pfrxnmstSb9j7kEeCLny5BGj6SNwCWGd6xbGGzz", -); -export const LIQUIDATION_PROGRAM_ID = new PublicKey( - "LiQnowFbFQdYyZhF4pUbpsrZCjxRTQ1upKJxZ2VXjde", -); - -export const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey( - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", -); - -export const RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", -); - -export const DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID = new PublicKey( - "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", -); - -export const META_MINT = new PublicKey( - "3gN1WVEJwSHNWjo7hr87DgZp6zkf8kWgAJD29DmfE2Gr", -); -export const MAINNET_USDC = new PublicKey( - "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", -); - -export const DEVNET_USDC = new PublicKey( - "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", -); -export const DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", -); - -export const USDC_DECIMALS = 6; - -export const AUTOCRAT_LUTS: PublicKey[] = []; - -export const RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DEVNET_RAYDIUM_AUTHORITY = PublicKey.findProgramAddressSync( - [anchor.utils.bytes.utf8.encode("vault_and_lp_mint_auth_seed")], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const DAMM_V2_PROGRAM_ID = new PublicKey( - "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG", -); - -export const DAMM_V2_POOL_AUTHORITY = new PublicKey( - "HLnpSz9h2S4hiLQ43rnSD9XkcUThA7B8hQMKmDaiTLcC", -); - -export const LOW_FEE_RAYDIUM_CONFIG = new PublicKey( - "D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2", -); - -export const DEVNET_LOW_FEE_RAYDIUM_CONFIG = PublicKey.findProgramAddressSync( - [ - anchor.utils.bytes.utf8.encode("amm_config"), - new BN(0).toArrayLike(Buffer, "be", 2), - ], - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, -)[0]; - -export const RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8", -); - -export const DEVNET_RAYDIUM_CREATE_POOL_FEE_RECEIVE = new PublicKey( - "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2", -); - -export const SQUADS_PROGRAM_CONFIG = new PublicKey( - "BSTq9w3kZwNwpBXJEvTZz2G9ZTNyKBvoSeXMvwb4cNZr", -); - -export const SQUADS_PROGRAM_ID = new PublicKey( - "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", -); - -export const SQUADS_PROGRAM_CONFIG_TREASURY = new PublicKey( - "5DH2e3cJmFpyi6mk65EGFediunm4ui6BiKNUNrhWtD1b", -); - -export const SQUADS_PROGRAM_CONFIG_TREASURY_DEVNET = new PublicKey( - "HM5y4mz3Bt9JY9mr1hkyhnvqxSH4H2u2451j7Hc2dtvK", -); - -export const MAINNET_METEORA_CONFIG = new PublicKey( - "FaA6RM9enPh1tU9Y8LiGCq715JubLc49WGcYTdNvDfsc", -); - -export const METADAO_MULTISIG_VAULT = new PublicKey( - "6awyHMshBGVjJ3ozdSJdyyDE1CTAXUwrpNMaRGMsb4sf", -); - -export const PERMISSIONLESS_ACCOUNT = Keypair.fromSecretKey( - Uint8Array.from([ - 249, 158, 188, 171, 243, 143, 1, 48, 87, 243, 209, 153, 144, 106, 23, 88, - 161, 209, 65, 217, 199, 121, 0, 250, 3, 203, 133, 138, 141, 112, 243, 38, - 198, 205, 120, 222, 160, 224, 151, 190, 84, 254, 127, 178, 224, 195, 130, - 243, 145, 73, 20, 91, 9, 69, 222, 184, 23, 1, 2, 196, 202, 206, 153, 192, - ]), -); diff --git a/sdk/src/v0.7/index.ts b/sdk/src/v0.7/index.ts deleted file mode 100644 index b705e0721..000000000 --- a/sdk/src/v0.7/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from "./types/index.js"; -export * from "./utils/index.js"; -export * from "./constants.js"; -export * from "./BidWallClient.js"; -export * from "./FutarchyClient.js"; -export * from "./ConditionalVaultClient.js"; -export * from "./LaunchpadClient.js"; -export * from "./PriceBasedPerformancePackageClient.js"; -export * from "./MintGovernorClient.js"; -export * from "./PerformancePackageV2Client.js"; -export * from "./LiquidationClient.js"; diff --git a/sdk/src/v0.7/types/amm.ts b/sdk/src/v0.7/types/amm.ts deleted file mode 100644 index 6d36be8d8..000000000 --- a/sdk/src/v0.7/types/amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type Amm = { - version: "0.5.0"; - name: "amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: Amm = { - version: "0.5.0", - name: "amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk/src/v0.7/types/autocrat.ts b/sdk/src/v0.7/types/autocrat.ts deleted file mode 100644 index a2afb15ee..000000000 --- a/sdk/src/v0.7/types/autocrat.ts +++ /dev/null @@ -1,2377 +0,0 @@ -export type Autocrat = { - version: "0.5.0"; - name: "autocrat"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - { - name: "executeSpendingLimitChange"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultTransaction"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "upgradeMultisigDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rentPayer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "kollan"; - isMut: false; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "fixOmnipairSpendingLimit"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rentPayer"; - isMut: true; - isSigner: true; - }, - { - name: "kollan"; - isMut: false; - isSigner: true; - }, - { - name: "omnipairSpendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ]; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "slotEnqueued"; - type: "u64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "passAmm"; - type: "publicKey"; - }, - { - name: "failAmm"; - type: "publicKey"; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSlots"; - type: "u64"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "InitializeProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "passLpTokensToLock"; - type: "u64"; - }, - { - name: "failLpTokensToLock"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "passAmm"; - type: "publicKey"; - index: false; - }, - { - name: "failAmm"; - type: "publicKey"; - index: false; - }, - { - name: "passLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "failLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSlots"; - type: "u64"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "ExecuteProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLpTokenBalance"; - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; - }, - { - code: 6011; - name: "InsufficientLpTokenLock"; - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; - }, - { - code: 6012; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer than TWAP start delay"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Draft status"; - }, - { - code: 6015; - name: "InvalidTransaction"; - msg: "This Squads transaction should only contain calls to update spending limits"; - }, - ]; -}; - -export const IDL: Autocrat = { - version: "0.5.0", - name: "autocrat", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalParams", - }, - }, - ], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - { - name: "executeSpendingLimitChange", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultTransaction", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "upgradeMultisigDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "rentPayer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "kollan", - isMut: false, - isSigner: true, - }, - ], - args: [], - }, - { - name: "fixOmnipairSpendingLimit", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "rentPayer", - isMut: true, - isSigner: true, - }, - { - name: "kollan", - isMut: false, - isSigner: true, - }, - { - name: "omnipairSpendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ], - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "descriptionUrl", - type: "string", - }, - { - name: "slotEnqueued", - type: "u64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "passAmm", - type: "publicKey", - }, - { - name: "failAmm", - type: "publicKey", - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "passLpTokensLocked", - type: "u64", - }, - { - name: "failLpTokensLocked", - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSlots", - type: "u64", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "InitializeProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "descriptionUrl", - type: "string", - }, - { - name: "passLpTokensToLock", - type: "u64", - }, - { - name: "failLpTokensToLock", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - ], - }, - }, - ], - events: [ - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "passAmm", - type: "publicKey", - index: false, - }, - { - name: "failAmm", - type: "publicKey", - index: false, - }, - { - name: "passLpMint", - type: "publicKey", - index: false, - }, - { - name: "failLpMint", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "passLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "failLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSlots", - type: "u64", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "ExecuteProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLpTokenBalance", - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", - }, - { - code: 6011, - name: "InsufficientLpTokenLock", - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", - }, - { - code: 6012, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer than TWAP start delay", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Draft status", - }, - { - code: 6015, - name: "InvalidTransaction", - msg: "This Squads transaction should only contain calls to update spending limits", - }, - ], -}; diff --git a/sdk/src/v0.7/types/autocrat_migrator.ts b/sdk/src/v0.7/types/autocrat_migrator.ts deleted file mode 100644 index 676d2df3d..000000000 --- a/sdk/src/v0.7/types/autocrat_migrator.ts +++ /dev/null @@ -1,237 +0,0 @@ -export type AutocratMigrator = { - version: "0.1.0"; - name: "autocrat_migrator"; - instructions: [ - { - name: "multiTransfer2"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "multiTransfer4"; - accounts: [ - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: true; - }, - { - name: "from0"; - isMut: true; - isSigner: false; - }, - { - name: "to0"; - isMut: true; - isSigner: false; - }, - { - name: "from1"; - isMut: true; - isSigner: false; - }, - { - name: "to1"; - isMut: true; - isSigner: false; - }, - { - name: "from2"; - isMut: true; - isSigner: false; - }, - { - name: "to2"; - isMut: true; - isSigner: false; - }, - { - name: "from3"; - isMut: true; - isSigner: false; - }, - { - name: "to3"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "lamportReceiver"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; -}; - -export const IDL: AutocratMigrator = { - version: "0.1.0", - name: "autocrat_migrator", - instructions: [ - { - name: "multiTransfer2", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "multiTransfer4", - accounts: [ - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: true, - }, - { - name: "from0", - isMut: true, - isSigner: false, - }, - { - name: "to0", - isMut: true, - isSigner: false, - }, - { - name: "from1", - isMut: true, - isSigner: false, - }, - { - name: "to1", - isMut: true, - isSigner: false, - }, - { - name: "from2", - isMut: true, - isSigner: false, - }, - { - name: "to2", - isMut: true, - isSigner: false, - }, - { - name: "from3", - isMut: true, - isSigner: false, - }, - { - name: "to3", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "lamportReceiver", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], -}; diff --git a/sdk/src/v0.7/types/damm_v2_cpi.ts b/sdk/src/v0.7/types/damm_v2_cpi.ts deleted file mode 100644 index 448829271..000000000 --- a/sdk/src/v0.7/types/damm_v2_cpi.ts +++ /dev/null @@ -1,747 +0,0 @@ -export type DammV2Cpi = { - version: "0.1.0"; - name: "damm_v2_cpi"; - instructions: [ - { - name: "initializePoolWithDynamicConfig"; - accounts: [ - { - name: "creator"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: true; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Address paying to create the pool. Can be anyone"]; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "payerTokenA"; - isMut: true; - isSigner: false; - }, - { - name: "payerTokenB"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeCustomizablePoolParameters"; - }; - }, - ]; - }, - { - name: "claimPositionFee"; - accounts: [ - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: false; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAAccount"; - isMut: true; - isSigner: false; - docs: ["The user token a account"]; - }, - { - name: "tokenBAccount"; - isMut: true; - isSigner: false; - docs: ["The user token b account"]; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - docs: ["The vault token account for input token"]; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - docs: ["The vault token account for output token"]; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - docs: ["The mint of token a"]; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - docs: ["The mint of token b"]; - }, - { - name: "positionNftAccount"; - isMut: false; - isSigner: false; - docs: ["The token account for nft"]; - }, - { - name: "owner"; - isMut: false; - isSigner: true; - docs: ["owner of position"]; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - docs: ["Token a program"]; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - docs: ["Token b program"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - types: [ - { - name: "PoolFeeParameters"; - docs: ["Information regarding fee charges"]; - type: { - kind: "struct"; - fields: [ - { - name: "baseFee"; - docs: ["Base fee"]; - type: { - defined: "BaseFeeParameters"; - }; - }, - { - name: "padding"; - docs: ["padding"]; - type: { - array: ["u8", 3]; - }; - }, - { - name: "dynamicFee"; - docs: ["dynamic fee"]; - type: { - option: { - defined: "DynamicFeeParameters"; - }; - }; - }, - ]; - }; - }, - { - name: "BaseFeeParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "cliffFeeNumerator"; - type: "u64"; - }, - { - name: "numberOfPeriod"; - type: "u16"; - }, - { - name: "periodFrequency"; - type: "u64"; - }, - { - name: "reductionFactor"; - type: "u64"; - }, - { - name: "feeSchedulerMode"; - type: "u8"; - }, - ]; - }; - }, - { - name: "DynamicFeeParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "binStep"; - type: "u16"; - }, - { - name: "binStepU128"; - type: "u128"; - }, - { - name: "filterPeriod"; - type: "u16"; - }, - { - name: "decayPeriod"; - type: "u16"; - }, - { - name: "reductionFactor"; - type: "u16"; - }, - { - name: "maxVolatilityAccumulator"; - type: "u32"; - }, - { - name: "variableFeeControl"; - type: "u32"; - }, - ]; - }; - }, - { - name: "InitializeCustomizablePoolParameters"; - type: { - kind: "struct"; - fields: [ - { - name: "poolFees"; - docs: ["pool fees"]; - type: { - defined: "PoolFeeParameters"; - }; - }, - { - name: "sqrtMinPrice"; - docs: ["sqrt min price"]; - type: "u128"; - }, - { - name: "sqrtMaxPrice"; - docs: ["sqrt max price"]; - type: "u128"; - }, - { - name: "hasAlphaVault"; - docs: ["has alpha vault"]; - type: "bool"; - }, - { - name: "liquidity"; - docs: ["initialize liquidity"]; - type: "u128"; - }, - { - name: "sqrtPrice"; - docs: [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value", - ]; - type: "u128"; - }, - { - name: "activationType"; - docs: ["activation type"]; - type: "u8"; - }, - { - name: "collectFeeMode"; - docs: ["collect fee mode"]; - type: "u8"; - }, - { - name: "activationPoint"; - docs: ["activation point"]; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - ]; -}; - -export const IDL: DammV2Cpi = { - version: "0.1.0", - name: "damm_v2_cpi", - instructions: [ - { - name: "initializePoolWithDynamicConfig", - accounts: [ - { - name: "creator", - isMut: false, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: true, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Address paying to create the pool. Can be anyone"], - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: true, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "payerTokenA", - isMut: true, - isSigner: false, - }, - { - name: "payerTokenB", - isMut: true, - isSigner: false, - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeCustomizablePoolParameters", - }, - }, - ], - }, - { - name: "claimPositionFee", - accounts: [ - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: false, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAAccount", - isMut: true, - isSigner: false, - docs: ["The user token a account"], - }, - { - name: "tokenBAccount", - isMut: true, - isSigner: false, - docs: ["The user token b account"], - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - docs: ["The vault token account for input token"], - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - docs: ["The vault token account for output token"], - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - docs: ["The mint of token a"], - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - docs: ["The mint of token b"], - }, - { - name: "positionNftAccount", - isMut: false, - isSigner: false, - docs: ["The token account for nft"], - }, - { - name: "owner", - isMut: false, - isSigner: true, - docs: ["owner of position"], - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - docs: ["Token a program"], - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - docs: ["Token b program"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - types: [ - { - name: "PoolFeeParameters", - docs: ["Information regarding fee charges"], - type: { - kind: "struct", - fields: [ - { - name: "baseFee", - docs: ["Base fee"], - type: { - defined: "BaseFeeParameters", - }, - }, - { - name: "padding", - docs: ["padding"], - type: { - array: ["u8", 3], - }, - }, - { - name: "dynamicFee", - docs: ["dynamic fee"], - type: { - option: { - defined: "DynamicFeeParameters", - }, - }, - }, - ], - }, - }, - { - name: "BaseFeeParameters", - type: { - kind: "struct", - fields: [ - { - name: "cliffFeeNumerator", - type: "u64", - }, - { - name: "numberOfPeriod", - type: "u16", - }, - { - name: "periodFrequency", - type: "u64", - }, - { - name: "reductionFactor", - type: "u64", - }, - { - name: "feeSchedulerMode", - type: "u8", - }, - ], - }, - }, - { - name: "DynamicFeeParameters", - type: { - kind: "struct", - fields: [ - { - name: "binStep", - type: "u16", - }, - { - name: "binStepU128", - type: "u128", - }, - { - name: "filterPeriod", - type: "u16", - }, - { - name: "decayPeriod", - type: "u16", - }, - { - name: "reductionFactor", - type: "u16", - }, - { - name: "maxVolatilityAccumulator", - type: "u32", - }, - { - name: "variableFeeControl", - type: "u32", - }, - ], - }, - }, - { - name: "InitializeCustomizablePoolParameters", - type: { - kind: "struct", - fields: [ - { - name: "poolFees", - docs: ["pool fees"], - type: { - defined: "PoolFeeParameters", - }, - }, - { - name: "sqrtMinPrice", - docs: ["sqrt min price"], - type: "u128", - }, - { - name: "sqrtMaxPrice", - docs: ["sqrt max price"], - type: "u128", - }, - { - name: "hasAlphaVault", - docs: ["has alpha vault"], - type: "bool", - }, - { - name: "liquidity", - docs: ["initialize liquidity"], - type: "u128", - }, - { - name: "sqrtPrice", - docs: [ - "The init price of the pool as a sqrt(token_b/token_a) Q64.64 value", - ], - type: "u128", - }, - { - name: "activationType", - docs: ["activation type"], - type: "u8", - }, - { - name: "collectFeeMode", - docs: ["collect fee mode"], - type: "u8", - }, - { - name: "activationPoint", - docs: ["activation point"], - type: { - option: "u64", - }, - }, - ], - }, - }, - ], -}; diff --git a/sdk/src/v0.7/types/futarchy_amm.ts b/sdk/src/v0.7/types/futarchy_amm.ts deleted file mode 100644 index c1aef0d19..000000000 --- a/sdk/src/v0.7/types/futarchy_amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type FutarchyAmm = { - version: "0.4.1"; - name: "futarchy_amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: FutarchyAmm = { - version: "0.4.1", - name: "futarchy_amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk/src/v0.7/types/index.ts b/sdk/src/v0.7/types/index.ts deleted file mode 100644 index 101f76110..000000000 --- a/sdk/src/v0.7/types/index.ts +++ /dev/null @@ -1,273 +0,0 @@ -import { Amm as AmmProgram, IDL as AmmIDL } from "./amm.js"; -export { AmmProgram, AmmIDL }; - -import { - LaunchpadV7 as LaunchpadProgram, - IDL as LaunchpadIDL, -} from "./launchpad_v7.js"; -export { LaunchpadProgram, LaunchpadIDL }; - -import { - ConditionalVault as ConditionalVaultProgram, - IDL as ConditionalVaultIDL, -} from "./conditional_vault.js"; -export { ConditionalVaultProgram, ConditionalVaultIDL }; - -import { Futarchy as FutarchyProgram, IDL as FutarchyIDL } from "./futarchy.js"; -export { FutarchyProgram, FutarchyIDL }; - -import { - PriceBasedPerformancePackage as PriceBasedPerformancePackageProgram, - IDL as PriceBasedPerformancePackageIDL, -} from "./price_based_performance_package.js"; -export { PriceBasedPerformancePackageProgram, PriceBasedPerformancePackageIDL }; - -import { BidWall as BidWallProgram, IDL as BidWallIDL } from "./bid_wall.js"; -export { BidWallProgram, BidWallIDL }; - -import { - MintGovernor as MintGovernorProgram, - IDL as MintGovernorIDL, -} from "./mint_governor.js"; -export { MintGovernorProgram, MintGovernorIDL }; - -import { - PerformancePackageV2 as PerformancePackageV2Program, - IDL as PerformancePackageV2IDL, -} from "./performance_package_v2.js"; -export { PerformancePackageV2Program, PerformancePackageV2IDL }; - -import { - Liquidation as LiquidationProgram, - IDL as LiquidationIDL, -} from "./liquidation.js"; -export { LiquidationProgram, LiquidationIDL }; - -export { LowercaseKeys } from "./utils.js"; - -import type { IdlAccounts, IdlTypes, IdlEvents } from "@coral-xyz/anchor"; - -export type Question = IdlAccounts["question"]; -export type ConditionalVault = - IdlAccounts["conditionalVault"]; - -export type InitializeDaoParams = - IdlTypes["InitializeDaoParams"]; -export type UpdateDaoParams = IdlTypes["UpdateDaoParams"]; -export type InitializePerformancePackageParams = - IdlTypes["InitializePerformancePackageParams"]; - -export type Dao = IdlAccounts["dao"]; -export type Proposal = IdlAccounts["proposal"]; -export type Amm = IdlAccounts["amm"]; -export type Launch = IdlAccounts["launch"]; -export type FundingRecord = IdlAccounts["fundingRecord"]; -export type PerformancePackage = - IdlAccounts["performancePackage"]; - -export type OracleConfig = - IdlTypes["OracleConfig"]; -export type Tranche = IdlTypes["Tranche"]; - -// export type OracleConfig = IdlTypes["OracleConfig"]; -// export type SharedLiquidityPool = -// IdlAccounts["sharedLiquidityPool"]; -// export type SharedLiquidityPoolPosition = -// IdlAccounts["liquidityPosition"]; - -export type BidWall = IdlAccounts["bidWall"]; - -export type MintGovernorAccount = - IdlAccounts["mintGovernor"]; -export type MintAuthorityAccount = - IdlAccounts["mintAuthority"]; - -export type PerformancePackageV2Account = - IdlAccounts["performancePackage"]; -export type PerformancePackageV2ChangeRequestAccount = - IdlAccounts["changeRequest"]; -export type PerformancePackageV2OracleReader = - IdlTypes["OracleReader"]; -export type PerformancePackageV2RewardFunction = - IdlTypes["RewardFunction"]; -export type PerformancePackageV2PackageStatus = - IdlTypes["PackageStatus"]; -export type PerformancePackageV2ThresholdTranche = - IdlTypes["ThresholdTranche"]; - -export type LiquidationAccount = IdlAccounts["liquidation"]; -export type RefundRecordAccount = - IdlAccounts["refundRecord"]; - -export type BidWallInitializedEvent = - IdlEvents["BidWallInitializedEvent"]; -export type BidWallTokensSoldEvent = - IdlEvents["BidWallTokensSoldEvent"]; -export type BidWallFeesCollectedEvent = - IdlEvents["BidWallFeesCollectedEvent"]; -export type BidWallClosedEvent = - IdlEvents["BidWallClosedEvent"]; -export type BidWallCanceledEvent = - IdlEvents["BidWallCanceledEvent"]; -export type BidWallEvent = - | BidWallInitializedEvent - | BidWallTokensSoldEvent - | BidWallFeesCollectedEvent - | BidWallClosedEvent - | BidWallCanceledEvent; - -export type SwapEvent = IdlEvents["SwapEvent"]; -export type AddLiquidityEvent = IdlEvents["AddLiquidityEvent"]; -export type RemoveLiquidityEvent = - IdlEvents["RemoveLiquidityEvent"]; -export type CreateAmmEvent = IdlEvents["CreateAmmEvent"]; -export type CrankThatTwapEvent = IdlEvents["CrankThatTwapEvent"]; -export type AmmEvent = - | SwapEvent - | AddLiquidityEvent - | RemoveLiquidityEvent - | CreateAmmEvent - | CrankThatTwapEvent; - -export type AddMetadataToConditionalTokensEvent = - IdlEvents["AddMetadataToConditionalTokensEvent"]; -export type InitializeConditionalVaultEvent = - IdlEvents["InitializeConditionalVaultEvent"]; -export type InitializeQuestionEvent = - IdlEvents["InitializeQuestionEvent"]; -export type MergeTokensEvent = - IdlEvents["MergeTokensEvent"]; -export type RedeemTokensEvent = - IdlEvents["RedeemTokensEvent"]; -export type ResolveQuestionEvent = - IdlEvents["ResolveQuestionEvent"]; -export type SplitTokensEvent = - IdlEvents["SplitTokensEvent"]; -export type ConditionalVaultEvent = - | AddMetadataToConditionalTokensEvent - | InitializeConditionalVaultEvent - | InitializeQuestionEvent - | MergeTokensEvent - | RedeemTokensEvent - | ResolveQuestionEvent - | SplitTokensEvent; - -export type LaunchClaimEvent = IdlEvents["LaunchClaimEvent"]; -export type LaunchCompletedEvent = - IdlEvents["LaunchCompletedEvent"]; -export type LaunchFundedEvent = - IdlEvents["LaunchFundedEvent"]; -export type LaunchInitializedEvent = - IdlEvents["LaunchInitializedEvent"]; -export type LaunchRefundedEvent = - IdlEvents["LaunchRefundedEvent"]; -export type LaunchStartedEvent = - IdlEvents["LaunchStartedEvent"]; -export type LaunchCloseEvent = IdlEvents["LaunchCloseEvent"]; -export type FundingRecordApprovalSetEvent = - IdlEvents["FundingRecordApprovalSetEvent"]; -export type LaunchClaimAdditionalTokenAllocationEvent = - IdlEvents["LaunchClaimAdditionalTokenAllocationEvent"]; -export type LaunchPerformancePackageInitializedEvent = - IdlEvents["LaunchPerformancePackageInitializedEvent"]; -export type LaunchpadEvent = - | LaunchClaimEvent - | LaunchCompletedEvent - | LaunchFundedEvent - | LaunchInitializedEvent - | LaunchRefundedEvent - | LaunchStartedEvent - | LaunchCloseEvent - | FundingRecordApprovalSetEvent - | LaunchClaimAdditionalTokenAllocationEvent - | LaunchPerformancePackageInitializedEvent; - -export type CollectFeesEvent = IdlEvents["CollectFeesEvent"]; -export type InitializeDaoEvent = - IdlEvents["InitializeDaoEvent"]; -export type UpdateDaoEvent = IdlEvents["UpdateDaoEvent"]; -export type InitializeProposalEvent = - IdlEvents["InitializeProposalEvent"]; -export type StakeToProposalEvent = - IdlEvents["StakeToProposalEvent"]; -export type UnstakeFromProposalEvent = - IdlEvents["UnstakeFromProposalEvent"]; -export type LaunchProposalEvent = - IdlEvents["LaunchProposalEvent"]; -export type FinalizeProposalEvent = - IdlEvents["FinalizeProposalEvent"]; -export type SpotSwapEvent = IdlEvents["SpotSwapEvent"]; -export type ConditionalSwapEvent = - IdlEvents["ConditionalSwapEvent"]; -export type ProvideLiquidityEvent = - IdlEvents["ProvideLiquidityEvent"]; -export type WithdrawLiquidityEvent = - IdlEvents["WithdrawLiquidityEvent"]; -export type SponsorProposalEvent = - IdlEvents["SponsorProposalEvent"]; -export type InitiateVaultSpendOptimisticProposalEvent = - IdlEvents["InitiateVaultSpendOptimisticProposalEvent"]; -export type FinalizeOptimisticProposalEvent = - IdlEvents["FinalizeOptimisticProposalEvent"]; -export type FutarchyEvent = - | CollectFeesEvent - | InitializeDaoEvent - | UpdateDaoEvent - | InitializeProposalEvent - | StakeToProposalEvent - | UnstakeFromProposalEvent - | LaunchProposalEvent - | FinalizeProposalEvent - | SpotSwapEvent - | ConditionalSwapEvent - | ProvideLiquidityEvent - | WithdrawLiquidityEvent - | SponsorProposalEvent - | InitiateVaultSpendOptimisticProposalEvent - | FinalizeOptimisticProposalEvent; - -export type PerformancePackageInitializedEvent = - IdlEvents["PerformancePackageInitialized"]; -export type UnlockStartedEvent = - IdlEvents["UnlockStarted"]; -export type UnlockCompletedEvent = - IdlEvents["UnlockCompleted"]; -export type ChangeProposedEvent = - IdlEvents["ChangeProposed"]; -export type ChangeExecutedEvent = - IdlEvents["ChangeExecuted"]; -export type PerformancePackageAuthorityChangedEvent = - IdlEvents["PerformancePackageAuthorityChanged"]; -export type PriceBasedPerformancePackageEvent = - | PerformancePackageInitializedEvent - | UnlockStartedEvent - | UnlockCompletedEvent - | ChangeProposedEvent - | ChangeExecutedEvent - | PerformancePackageAuthorityChangedEvent; - -export type MintGovernorInitializedEvent = - IdlEvents["MintGovernorInitializedEvent"]; -export type MintAuthorityTransferredEvent = - IdlEvents["MintAuthorityTransferredEvent"]; -export type MintAuthorityAddedEvent = - IdlEvents["MintAuthorityAddedEvent"]; -export type TokensMintedEvent = - IdlEvents["TokensMintedEvent"]; -export type MintAuthorityUpdatedEvent = - IdlEvents["MintAuthorityUpdatedEvent"]; -export type MintAuthorityRemovedEvent = - IdlEvents["MintAuthorityRemovedEvent"]; -export type MintGovernorAdminUpdatedEvent = - IdlEvents["MintGovernorAdminUpdatedEvent"]; -export type MintAuthorityReclaimedEvent = - IdlEvents["MintAuthorityReclaimedEvent"]; -export type MintGovernorEvent = - | MintGovernorInitializedEvent - | MintAuthorityTransferredEvent - | MintAuthorityAddedEvent - | TokensMintedEvent - | MintAuthorityUpdatedEvent - | MintAuthorityRemovedEvent - | MintGovernorAdminUpdatedEvent - | MintAuthorityReclaimedEvent; diff --git a/sdk/src/v0.7/types/optimistic_timelock.ts b/sdk/src/v0.7/types/optimistic_timelock.ts deleted file mode 100644 index fa1f43135..000000000 --- a/sdk/src/v0.7/types/optimistic_timelock.ts +++ /dev/null @@ -1,1023 +0,0 @@ -export type OptimisticTimelock = { - version: "0.3.0"; - name: "optimistic_timelock"; - instructions: [ - { - name: "createTimelock"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: true; - isSigner: true; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "enqueuers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "enqueuerCooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setDelayInSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "delayInSlots"; - type: "u64"; - }, - ]; - }, - { - name: "setAuthority"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "authority"; - type: "publicKey"; - }, - ]; - }, - { - name: "setOptimisticProposerCooldownSlots"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "cooldownSlots"; - type: "u64"; - }, - ]; - }, - { - name: "addOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "enqueuer"; - type: "publicKey"; - }, - ]; - }, - { - name: "removeOptimisticProposer"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "optimisticProposer"; - type: "publicKey"; - }, - ]; - }, - { - name: "createTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: true; - }, - ]; - args: []; - }, - { - name: "addTransaction"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }, - { - name: "sealTransactionBatch"; - accounts: [ - { - name: "transactionBatchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "enqueueTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelTransactionBatch"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "timelock"; - isMut: true; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeTransactionBatch"; - accounts: [ - { - name: "timelockSigner"; - isMut: false; - isSigner: false; - }, - { - name: "timelock"; - isMut: false; - isSigner: false; - }, - { - name: "transactionBatch"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "timelock"; - type: { - kind: "struct"; - fields: [ - { - name: "authority"; - type: "publicKey"; - }, - { - name: "signerBump"; - type: "u8"; - }, - { - name: "delayInSlots"; - type: "u64"; - }, - { - name: "optimisticProposers"; - type: { - vec: { - defined: "OptimisticProposer"; - }; - }; - }, - { - name: "optimisticProposerCooldownSlots"; - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "transactionBatch"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "TransactionBatchStatus"; - }; - }, - { - name: "transactions"; - type: { - vec: { - defined: "Transaction"; - }; - }; - }, - { - name: "timelock"; - type: "publicKey"; - }, - { - name: "enqueuedSlot"; - type: "u64"; - }, - { - name: "transactionBatchAuthority"; - type: "publicKey"; - }, - { - name: "enqueuerType"; - type: { - defined: "AuthorityType"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "OptimisticProposer"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "lastSlotEnqueued"; - type: "u64"; - }, - ]; - }; - }, - { - name: "Transaction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "TransactionAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - { - name: "didExecute"; - type: "bool"; - }, - ]; - }; - }, - { - name: "TransactionAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "AuthorityType"; - type: { - kind: "enum"; - variants: [ - { - name: "OptimisticProposer"; - }, - { - name: "TimelockAuthority"; - }, - ]; - }; - }, - { - name: "TransactionBatchStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Created"; - }, - { - name: "Sealed"; - }, - { - name: "Enqueued"; - }, - { - name: "Cancelled"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NotReady"; - msg: "This transaction is not yet ready to be executed"; - }, - { - code: 6001; - name: "CannotAddTransactions"; - msg: "Can only add instructions when transaction batch status is `Created`"; - }, - { - code: 6002; - name: "CannotSealTransactionBatch"; - msg: "Can only seal the transaction batch when status is `Created`"; - }, - { - code: 6003; - name: "CannotEnqueueTransactionBatch"; - msg: "Can only enqueue the timelock running once the status is `Sealed`"; - }, - { - code: 6004; - name: "CannotCancelTimelock"; - msg: "Can only cancel the transactions if the status `Enqueued`"; - }, - { - code: 6005; - name: "CanOnlyCancelDuringTimelockPeriod"; - msg: "Can only cancel the transactions during the timelock period"; - }, - { - code: 6006; - name: "CannotExecuteTransactions"; - msg: "Can only execute the transactions if the status is `Enqueued`"; - }, - { - code: 6007; - name: "NoAuthority"; - msg: "The signer is neither the timelock authority nor an optimistic proposer"; - }, - { - code: 6008; - name: "InsufficientPermissions"; - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority"; - }, - { - code: 6009; - name: "OptimisticProposerCooldown"; - msg: "This optimistic proposer is still in its cooldown period"; - }, - ]; -}; - -export const IDL: OptimisticTimelock = { - version: "0.3.0", - name: "optimistic_timelock", - instructions: [ - { - name: "createTimelock", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: true, - isSigner: true, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "enqueuers", - type: { - vec: "publicKey", - }, - }, - { - name: "enqueuerCooldownSlots", - type: "u64", - }, - ], - }, - { - name: "setDelayInSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "delayInSlots", - type: "u64", - }, - ], - }, - { - name: "setAuthority", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "authority", - type: "publicKey", - }, - ], - }, - { - name: "setOptimisticProposerCooldownSlots", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "cooldownSlots", - type: "u64", - }, - ], - }, - { - name: "addOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "enqueuer", - type: "publicKey", - }, - ], - }, - { - name: "removeOptimisticProposer", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "optimisticProposer", - type: "publicKey", - }, - ], - }, - { - name: "createTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: true, - }, - ], - args: [], - }, - { - name: "addTransaction", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - { - name: "sealTransactionBatch", - accounts: [ - { - name: "transactionBatchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "enqueueTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelTransactionBatch", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "timelock", - isMut: true, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeTransactionBatch", - accounts: [ - { - name: "timelockSigner", - isMut: false, - isSigner: false, - }, - { - name: "timelock", - isMut: false, - isSigner: false, - }, - { - name: "transactionBatch", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "timelock", - type: { - kind: "struct", - fields: [ - { - name: "authority", - type: "publicKey", - }, - { - name: "signerBump", - type: "u8", - }, - { - name: "delayInSlots", - type: "u64", - }, - { - name: "optimisticProposers", - type: { - vec: { - defined: "OptimisticProposer", - }, - }, - }, - { - name: "optimisticProposerCooldownSlots", - docs: [ - "The cooldown period for enqueuers to prevent spamming the timelock.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "transactionBatch", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "TransactionBatchStatus", - }, - }, - { - name: "transactions", - type: { - vec: { - defined: "Transaction", - }, - }, - }, - { - name: "timelock", - type: "publicKey", - }, - { - name: "enqueuedSlot", - type: "u64", - }, - { - name: "transactionBatchAuthority", - type: "publicKey", - }, - { - name: "enqueuerType", - type: { - defined: "AuthorityType", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "OptimisticProposer", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "lastSlotEnqueued", - type: "u64", - }, - ], - }, - }, - { - name: "Transaction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "TransactionAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - { - name: "didExecute", - type: "bool", - }, - ], - }, - }, - { - name: "TransactionAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "AuthorityType", - type: { - kind: "enum", - variants: [ - { - name: "OptimisticProposer", - }, - { - name: "TimelockAuthority", - }, - ], - }, - }, - { - name: "TransactionBatchStatus", - type: { - kind: "enum", - variants: [ - { - name: "Created", - }, - { - name: "Sealed", - }, - { - name: "Enqueued", - }, - { - name: "Cancelled", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NotReady", - msg: "This transaction is not yet ready to be executed", - }, - { - code: 6001, - name: "CannotAddTransactions", - msg: "Can only add instructions when transaction batch status is `Created`", - }, - { - code: 6002, - name: "CannotSealTransactionBatch", - msg: "Can only seal the transaction batch when status is `Created`", - }, - { - code: 6003, - name: "CannotEnqueueTransactionBatch", - msg: "Can only enqueue the timelock running once the status is `Sealed`", - }, - { - code: 6004, - name: "CannotCancelTimelock", - msg: "Can only cancel the transactions if the status `Enqueued`", - }, - { - code: 6005, - name: "CanOnlyCancelDuringTimelockPeriod", - msg: "Can only cancel the transactions during the timelock period", - }, - { - code: 6006, - name: "CannotExecuteTransactions", - msg: "Can only execute the transactions if the status is `Enqueued`", - }, - { - code: 6007, - name: "NoAuthority", - msg: "The signer is neither the timelock authority nor an optimistic proposer", - }, - { - code: 6008, - name: "InsufficientPermissions", - msg: "Optimistic proposers can't cancel transaction batches enqueued by the timelock authority", - }, - { - code: 6009, - name: "OptimisticProposerCooldown", - msg: "This optimistic proposer is still in its cooldown period", - }, - ], -}; diff --git a/sdk/src/v0.7/types/price_based_token_lock.ts b/sdk/src/v0.7/types/price_based_token_lock.ts deleted file mode 100644 index 3ac0813bb..000000000 --- a/sdk/src/v0.7/types/price_based_token_lock.ts +++ /dev/null @@ -1,887 +0,0 @@ -export type PriceBasedTokenLock = { - version: "0.1.0"; - name: "price_based_token_lock"; - constants: [ - { - name: "SEED"; - type: "string"; - value: '"anchor"'; - }, - ]; - instructions: [ - { - name: "initializeLocker"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "fromTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "tokenAuthority"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "recipientTokenAccount"; - isMut: false; - isSigner: false; - docs: [ - "The recipient's token account where tokens will be sent when unlocked", - ]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeLockerParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The recipient's token account where tokens will be sent"]; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "locker"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: [ - "The price threshold that must be met for tokens to be unlocked", - ]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens locked"]; - type: "u64"; - }, - { - name: "unlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: ["Length of time in seconds for TWAP calculation"]; - type: "u64"; - }, - { - name: "tokenRecipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "InitializeLockerParams"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "unlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u64"; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "LockerState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - { - name: "Unlocked"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LockerInitialized"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "unlockTimestamp"; - type: "i64"; - index: false; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - index: false; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "InvalidLockerState"; - msg: "Locker is not in the expected state"; - }, - { - code: 6002; - name: "TwapCalculationFailed"; - msg: "TWAP calculation failed"; - }, - { - code: 6003; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6004; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - ]; -}; - -export const IDL: PriceBasedTokenLock = { - version: "0.1.0", - name: "price_based_token_lock", - constants: [ - { - name: "SEED", - type: "string", - value: '"anchor"', - }, - ], - instructions: [ - { - name: "initializeLocker", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "fromTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "tokenAuthority", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "recipientTokenAccount", - isMut: false, - isSigner: false, - docs: [ - "The recipient's token account where tokens will be sent when unlocked", - ], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeLockerParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: ["The recipient's token account where tokens will be sent"], - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "locker", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: [ - "The price threshold that must be met for tokens to be unlocked", - ], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens locked"], - type: "u64", - }, - { - name: "unlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: ["Length of time in seconds for TWAP calculation"], - type: "u64", - }, - { - name: "tokenRecipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "LockerState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "InitializeLockerParams", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "unlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u64", - }, - { - name: "tokenRecipient", - type: "publicKey", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "LockerState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - { - name: "Unlocked", - }, - ], - }, - }, - ], - events: [ - { - name: "LockerInitialized", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "unlockTimestamp", - type: "i64", - index: false, - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - index: false, - }, - { - name: "tokenRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "InvalidLockerState", - msg: "Locker is not in the expected state", - }, - { - code: 6002, - name: "TwapCalculationFailed", - msg: "TWAP calculation failed", - }, - { - code: 6003, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6004, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - ], -}; diff --git a/sdk/src/v0.7/types/price_based_unlock.ts b/sdk/src/v0.7/types/price_based_unlock.ts deleted file mode 100644 index bd6db4a3f..000000000 --- a/sdk/src/v0.7/types/price_based_unlock.ts +++ /dev/null @@ -1,1717 +0,0 @@ -export type PriceBasedUnlock = { - version: "0.1.0"; - name: "price_based_unlock"; - constants: [ - { - name: "SEED"; - type: "string"; - value: '"anchor"'; - }, - ]; - instructions: [ - { - name: "initializeLocker"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "fromTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "tokenAuthority"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeLockerParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: true; - docs: ["Only the token recipient can start unlock"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "lockerTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The token mint - validated via has_one constraint on locker"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ]; - }, - { - name: "tokenRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Payer for creating the ATA if needed"]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "proposeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProposeChangeParams"; - }; - }, - ]; - }, - { - name: "executeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "executor"; - isMut: true; - isSigner: true; - docs: [ - "The party executing the change (must be opposite of proposer)", - ]; - }, - ]; - args: []; - }, - { - name: "changeLockerAuthority"; - accounts: [ - { - name: "locker"; - isMut: true; - isSigner: false; - }, - { - name: "currentAuthority"; - isMut: false; - isSigner: true; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ChangeLockerAuthorityParams"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "locker"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: ["The price threshold for 100% unlocking (max price target)"]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens locked"]; - type: "u64"; - }, - { - name: "tokensAlreadyUnlocked"; - docs: ["The amount of tokens already unlocked"]; - type: "u64"; - }, - { - name: "unlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: ["Length of time in seconds for TWAP calculation"]; - type: "u64"; - }, - { - name: "tokenRecipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - { - name: "lockerAuthority"; - docs: ["The authorized locker authority that can execute changes"]; - type: "publicKey"; - }, - { - name: "tokenMint"; - docs: ["The mint of the locked tokens"]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "changeRequest"; - type: { - kind: "struct"; - fields: [ - { - name: "locker"; - docs: ["The locker this change applies to"]; - type: "publicKey"; - }, - { - name: "changeType"; - docs: ["What is being changed"]; - type: { - defined: "ChangeType"; - }; - }, - { - name: "proposedAt"; - docs: ["When the change was proposed"]; - type: "i64"; - }, - { - name: "previousState"; - docs: ["The locker state before the change was proposed"]; - type: { - defined: "LockerState"; - }; - }, - { - name: "proposer"; - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ]; - type: "publicKey"; - }, - { - name: "pdaNonce"; - docs: ["Used to derive the PDA along with the proposer"]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "lockerSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ChangeLockerAuthorityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "newLockerAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitializeLockerParams"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "unlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u64"; - }, - { - name: "beneficiary"; - type: "publicKey"; - }, - { - name: "lockerAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ProposeChangeParams"; - type: { - kind: "struct"; - fields: [ - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - }, - { - name: "pdaNonce"; - type: "u32"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "LockerState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - { - name: "Unlocked"; - }, - ]; - }; - }, - { - name: "ChangeType"; - type: { - kind: "enum"; - variants: [ - { - name: "Oracle"; - fields: [ - { - name: "newOracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - ]; - }, - { - name: "Recipient"; - fields: [ - { - name: "newRecipient"; - type: "publicKey"; - }, - ]; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LockerInitialized"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "unlockTimestamp"; - type: "i64"; - index: false; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - index: false; - }, - { - name: "tokenRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - { - name: "priceThreshold"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "TokensClaimed"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "tokensAlreadyUnlocked"; - type: "u64"; - index: false; - }, - { - name: "totalTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "currentPrice"; - type: "u128"; - index: false; - }, - { - name: "unlockPercentage"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "ChangeProposed"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - { - name: "proposedAt"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "ChangeExecuted"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "executor"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - { - name: "executedAt"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "LockerAuthorityChanged"; - fields: [ - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "changedAt"; - type: "i64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "UnlockTimestampInThePast"; - msg: "Unlock timestamp must be in the future"; - }, - { - code: 6002; - name: "InvalidLockerState"; - msg: "Locker is not in the expected state"; - }, - { - code: 6003; - name: "TwapCalculationFailed"; - msg: "TWAP calculation failed"; - }, - { - code: 6004; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6005; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - { - code: 6006; - name: "UnauthorizedChangeRequest"; - msg: "Unauthorized to create or execute change request"; - }, - { - code: 6007; - name: "InvalidChangeRequest"; - msg: "Change request does not match locker"; - }, - { - code: 6008; - name: "UnauthorizedLockerAuthority"; - msg: "Unauthorized locker authority"; - }, - { - code: 6009; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - ]; -}; - -export const IDL: PriceBasedUnlock = { - version: "0.1.0", - name: "price_based_unlock", - constants: [ - { - name: "SEED", - type: "string", - value: '"anchor"', - }, - ], - instructions: [ - { - name: "initializeLocker", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "fromTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "tokenAuthority", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeLockerParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: true, - docs: ["Only the token recipient can start unlock"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "lockerTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The token mint - validated via has_one constraint on locker"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ], - }, - { - name: "tokenRecipient", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Payer for creating the ATA if needed"], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "proposeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProposeChangeParams", - }, - }, - ], - }, - { - name: "executeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "executor", - isMut: true, - isSigner: true, - docs: [ - "The party executing the change (must be opposite of proposer)", - ], - }, - ], - args: [], - }, - { - name: "changeLockerAuthority", - accounts: [ - { - name: "locker", - isMut: true, - isSigner: false, - }, - { - name: "currentAuthority", - isMut: false, - isSigner: true, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ChangeLockerAuthorityParams", - }, - }, - ], - }, - ], - accounts: [ - { - name: "locker", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: ["The price threshold for 100% unlocking (max price target)"], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens locked"], - type: "u64", - }, - { - name: "tokensAlreadyUnlocked", - docs: ["The amount of tokens already unlocked"], - type: "u64", - }, - { - name: "unlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: ["Length of time in seconds for TWAP calculation"], - type: "u64", - }, - { - name: "tokenRecipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "LockerState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - { - name: "lockerAuthority", - docs: ["The authorized locker authority that can execute changes"], - type: "publicKey", - }, - { - name: "tokenMint", - docs: ["The mint of the locked tokens"], - type: "publicKey", - }, - ], - }, - }, - { - name: "changeRequest", - type: { - kind: "struct", - fields: [ - { - name: "locker", - docs: ["The locker this change applies to"], - type: "publicKey", - }, - { - name: "changeType", - docs: ["What is being changed"], - type: { - defined: "ChangeType", - }, - }, - { - name: "proposedAt", - docs: ["When the change was proposed"], - type: "i64", - }, - { - name: "previousState", - docs: ["The locker state before the change was proposed"], - type: { - defined: "LockerState", - }, - }, - { - name: "proposer", - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ], - type: "publicKey", - }, - { - name: "pdaNonce", - docs: ["Used to derive the PDA along with the proposer"], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "lockerSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ChangeLockerAuthorityParams", - type: { - kind: "struct", - fields: [ - { - name: "newLockerAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitializeLockerParams", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "unlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u64", - }, - { - name: "beneficiary", - type: "publicKey", - }, - { - name: "lockerAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "ProposeChangeParams", - type: { - kind: "struct", - fields: [ - { - name: "changeType", - type: { - defined: "ChangeType", - }, - }, - { - name: "pdaNonce", - type: "u32", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "LockerState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - { - name: "Unlocked", - }, - ], - }, - }, - { - name: "ChangeType", - type: { - kind: "enum", - variants: [ - { - name: "Oracle", - fields: [ - { - name: "newOracleConfig", - type: { - defined: "OracleConfig", - }, - }, - ], - }, - { - name: "Recipient", - fields: [ - { - name: "newRecipient", - type: "publicKey", - }, - ], - }, - ], - }, - }, - ], - events: [ - { - name: "LockerInitialized", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "unlockTimestamp", - type: "i64", - index: false, - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - index: false, - }, - { - name: "tokenRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - { - name: "priceThreshold", - type: "u128", - index: false, - }, - ], - }, - { - name: "TokensClaimed", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "tokensAlreadyUnlocked", - type: "u64", - index: false, - }, - { - name: "totalTokenAmount", - type: "u64", - index: false, - }, - { - name: "currentPrice", - type: "u128", - index: false, - }, - { - name: "unlockPercentage", - type: "u128", - index: false, - }, - ], - }, - { - name: "ChangeProposed", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - { - name: "proposedAt", - type: "i64", - index: false, - }, - ], - }, - { - name: "ChangeExecuted", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "executor", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - { - name: "executedAt", - type: "i64", - index: false, - }, - ], - }, - { - name: "LockerAuthorityChanged", - fields: [ - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - { - name: "changedAt", - type: "i64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "UnlockTimestampInThePast", - msg: "Unlock timestamp must be in the future", - }, - { - code: 6002, - name: "InvalidLockerState", - msg: "Locker is not in the expected state", - }, - { - code: 6003, - name: "TwapCalculationFailed", - msg: "TWAP calculation failed", - }, - { - code: 6004, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6005, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - { - code: 6006, - name: "UnauthorizedChangeRequest", - msg: "Unauthorized to create or execute change request", - }, - { - code: 6007, - name: "InvalidChangeRequest", - msg: "Change request does not match locker", - }, - { - code: 6008, - name: "UnauthorizedLockerAuthority", - msg: "Unauthorized locker authority", - }, - { - code: 6009, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - ], -}; diff --git a/sdk/src/v0.7/types/shared_liquidity_manager.ts b/sdk/src/v0.7/types/shared_liquidity_manager.ts deleted file mode 100644 index 124942da9..000000000 --- a/sdk/src/v0.7/types/shared_liquidity_manager.ts +++ /dev/null @@ -1,177 +0,0 @@ -export type SharedLiquidityManager = { - version: "0.1.0"; - name: "shared_liquidity_manager"; - docs: ["TODO:", "- add unstake", "- add unit tests"]; - instructions: []; - errors: [ - { - code: 6000; - name: "InsufficientStake"; - msg: "Insufficient stake amount"; - }, - { - code: 6001; - name: "ProposalNotFinalized"; - msg: "Proposal is not finalized"; - }, - { - code: 6002; - name: "NoLpTokensToRemove"; - msg: "No LP tokens to remove from AMM"; - }, - { - code: 6003; - name: "NoTokensFromAmm"; - msg: "No tokens received from AMM removal"; - }, - { - code: 6004; - name: "InsufficientReservesReturned"; - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)"; - }, - { - code: 6005; - name: "PoolInUse"; - msg: "Pool is currently being used by an active proposal"; - }, - { - code: 6006; - name: "InsufficientLpShares"; - msg: "User does not have enough LP shares to withdraw"; - }, - { - code: 6007; - name: "SlippageExceeded"; - msg: "Slippage exceeded minimum token amounts"; - }, - { - code: 6008; - name: "NoLpTokensInPool"; - msg: "No LP tokens in pool's LP token account"; - }, - { - code: 6009; - name: "NotEnoughLpTokens"; - msg: "Not enough LP tokens to provide liquidity to proposal"; - }, - { - code: 6010; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6011; - name: "NoActiveProposal"; - msg: "No active proposal"; - }, - { - code: 6012; - name: "ProposalNotInDraftStatus"; - msg: "Proposal is not in draft status"; - }, - { - code: 6013; - name: "ProposalAlreadyActive"; - msg: "Proposal already active"; - }, - { - code: 6014; - name: "AmmAlreadyHasLiquidity"; - msg: "AMM already has liquidity"; - }, - { - code: 6015; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - ]; -}; - -export const IDL: SharedLiquidityManager = { - version: "0.1.0", - name: "shared_liquidity_manager", - docs: ["TODO:", "- add unstake", "- add unit tests"], - instructions: [], - errors: [ - { - code: 6000, - name: "InsufficientStake", - msg: "Insufficient stake amount", - }, - { - code: 6001, - name: "ProposalNotFinalized", - msg: "Proposal is not finalized", - }, - { - code: 6002, - name: "NoLpTokensToRemove", - msg: "No LP tokens to remove from AMM", - }, - { - code: 6003, - name: "NoTokensFromAmm", - msg: "No tokens received from AMM removal", - }, - { - code: 6004, - name: "InsufficientReservesReturned", - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)", - }, - { - code: 6005, - name: "PoolInUse", - msg: "Pool is currently being used by an active proposal", - }, - { - code: 6006, - name: "InsufficientLpShares", - msg: "User does not have enough LP shares to withdraw", - }, - { - code: 6007, - name: "SlippageExceeded", - msg: "Slippage exceeded minimum token amounts", - }, - { - code: 6008, - name: "NoLpTokensInPool", - msg: "No LP tokens in pool's LP token account", - }, - { - code: 6009, - name: "NotEnoughLpTokens", - msg: "Not enough LP tokens to provide liquidity to proposal", - }, - { - code: 6010, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6011, - name: "NoActiveProposal", - msg: "No active proposal", - }, - { - code: 6012, - name: "ProposalNotInDraftStatus", - msg: "Proposal is not in draft status", - }, - { - code: 6013, - name: "ProposalAlreadyActive", - msg: "Proposal already active", - }, - { - code: 6014, - name: "AmmAlreadyHasLiquidity", - msg: "AMM already has liquidity", - }, - { - code: 6015, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - ], -}; diff --git a/sdk/src/v0.7/types/utils.ts b/sdk/src/v0.7/types/utils.ts deleted file mode 100644 index c878debe7..000000000 --- a/sdk/src/v0.7/types/utils.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type LowercaseKeys = { - [K in keyof T as Lowercase]: T[K]; -}; diff --git a/sdk/src/v0.7/utils/cu.ts b/sdk/src/v0.7/utils/cu.ts deleted file mode 100644 index b55cbac95..000000000 --- a/sdk/src/v0.7/utils/cu.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const MaxCUs = { - initializeDao: 40_000, - createIdempotent: 25_000, - initializeConditionalVault: 45_000, - mintConditionalTokens: 35_000, - initializeAmm: 120_000, - addLiquidity: 120_000, - initializeProposal: 60_000, -}; - -export const DEFAULT_CU_PRICE = 1; diff --git a/sdk/src/v0.7/utils/filters.ts b/sdk/src/v0.7/utils/filters.ts deleted file mode 100644 index aee93f618..000000000 --- a/sdk/src/v0.7/utils/filters.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { GetProgramAccountsFilter, PublicKey } from "@solana/web3.js"; - -export const filterPositionsByUser = ( - userAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: 8, // discriminator - bytes: userAddr.toBase58(), - }, -}); - -export const filterPositionsByAmm = ( - ammAddr: PublicKey, -): GetProgramAccountsFilter => ({ - memcmp: { - offset: - 8 + // discriminator - 32, // user address - bytes: ammAddr.toBase58(), - }, -}); diff --git a/sdk/src/v0.7/utils/index.ts b/sdk/src/v0.7/utils/index.ts deleted file mode 100644 index ee7438b0a..000000000 --- a/sdk/src/v0.7/utils/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -export * from "./filters.js"; -export * from "./pda.js"; -export * from "./priceMath.js"; -export * from "./metadata.js"; -export * from "./cu.js"; -export * from "./instruction.js"; - -import { AccountMeta, ComputeBudgetProgram, PublicKey } from "@solana/web3.js"; - -export enum PriorityFeeTier { - NORMAL = 35, - HIGH = 3571, - TURBO = 357142, -} - -export const addComputeUnits = (num_units: number = 1_400_000) => - ComputeBudgetProgram.setComputeUnitLimit({ - units: num_units, - }); - -export const addPriorityFee = (pf: number) => - ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: pf, - }); - -export const pubkeyToAccountInfo = ( - pubkey: PublicKey, - isWritable: boolean, - isSigner = false, -): AccountMeta => { - return { - pubkey: pubkey, - isSigner: isSigner, - isWritable: isWritable, - }; -}; - -export async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/sdk/src/v0.7/utils/instruction.ts b/sdk/src/v0.7/utils/instruction.ts deleted file mode 100644 index f18e48834..000000000 --- a/sdk/src/v0.7/utils/instruction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from "@coral-xyz/anchor"; -import { TransactionInstruction } from "@solana/web3.js"; - -export class InstructionUtils { - public static async getInstructions( - ...methodBuilders: any[] - ): Promise { - let instructions: TransactionInstruction[] = []; - - for (const methodBuilder of methodBuilders) { - instructions.push(...(await methodBuilder.transaction()).instructions); - } - - return instructions; - } -} diff --git a/sdk/src/v0.7/utils/metadata.ts b/sdk/src/v0.7/utils/metadata.ts deleted file mode 100644 index ef17bbdb8..000000000 --- a/sdk/src/v0.7/utils/metadata.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BN from "bn.js"; -import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"; -import { Connection } from "@solana/web3.js"; -import { bundlrUploader } from "@metaplex-foundation/umi-uploader-bundlr"; -import { UmiPlugin } from "@metaplex-foundation/umi"; - -export const assetImageMap: Record = { - fMETA: "https://arweave.net/tGxvOjMZw7B0qHsdCcIMO57oH5g5OaItOZdXo3BXKz8", - fUSDC: "https://arweave.net/DpvxeAyVbaoivhIVCLjdf566k2SwVn0YVBL0sTOezWk", - pMETA: "https://arweave.net/iuqi7PRRESdDxj1oRyk2WzR90_zdFcmZsuWicv3XGfs", - pUSDC: "https://arweave.net/e4IO7F59F_RKCiuB--_ABPot7Qh1yFsGkWzVhcXuKDU", -}; - -// Upload some JSON, returning its URL -export const uploadConditionalTokenMetadataJson = async ( - connection: Connection, - identityPlugin: UmiPlugin, - proposalNumber: number, - symbol: string, - // proposal: BN, - // conditionalToken: string, - // image: string -): Promise => { - // use bundlr, targeting arweave - const umi = createUmi(connection); - umi.use(bundlrUploader()); - umi.use(identityPlugin); - - return umi.uploader.uploadJson({ - name: `Proposal ${proposalNumber}: ${symbol}`, - image: assetImageMap[symbol], - symbol, - description: "A conditional token for use in futarchy.", - }); -}; diff --git a/sdk/src/v0.7/utils/pda.ts b/sdk/src/v0.7/utils/pda.ts deleted file mode 100644 index 24f746632..000000000 --- a/sdk/src/v0.7/utils/pda.ts +++ /dev/null @@ -1,375 +0,0 @@ -import { AccountMeta, PublicKey } from "@solana/web3.js"; -import { utils } from "@coral-xyz/anchor"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import BN from "bn.js"; -import { - fromWeb3JsPublicKey, - toWeb3JsPublicKey, -} from "@metaplex-foundation/umi-web3js-adapters"; -import { - DEVNET_RAYDIUM_CP_SWAP_PROGRAM_ID, - MPL_TOKEN_METADATA_PROGRAM_ID, - PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - RAYDIUM_CP_SWAP_PROGRAM_ID, - SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - LAUNCHPAD_PROGRAM_ID, - FUTARCHY_PROGRAM_ID, - BID_WALL_PROGRAM_ID, - MINT_GOVERNOR_PROGRAM_ID, - LIQUIDATION_PROGRAM_ID, -} from "../constants.js"; - -export const getEventAuthorityAddr = (programId: PublicKey) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("__event_authority")], - programId, - ); -}; - -export const getQuestionAddr = ( - programId: PublicKey, - questionId: Uint8Array, - oracle: PublicKey, - numOutcomes: number, -) => { - if (questionId.length != 32) { - throw new Error("questionId must be 32 bytes"); - } - - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("question"), - Buffer.from(questionId), - oracle.toBuffer(), - new BN(numOutcomes).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getVaultAddr = ( - programId: PublicKey, - question: PublicKey, - underlyingTokenMint: PublicKey, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_vault"), - question.toBuffer(), - underlyingTokenMint.toBuffer(), - ], - programId, - ); -}; - -export const getConditionalTokenMintAddr = ( - programId: PublicKey, - vault: PublicKey, - index: number, -) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("conditional_token"), - vault.toBuffer(), - new BN(index).toArrayLike(Buffer, "le", 1), - ], - programId, - ); -}; - -export const getDownAndUpMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { down: PublicKey; up: PublicKey } => { - return { - down: getConditionalTokenMintAddr(programId, vault, 0)[0], - up: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getFailAndPassMintAddrs = ( - programId: PublicKey, - vault: PublicKey, -): { fail: PublicKey; pass: PublicKey } => { - return { - fail: getConditionalTokenMintAddr(programId, vault, 0)[0], - pass: getConditionalTokenMintAddr(programId, vault, 1)[0], - }; -}; - -export const getMetadataAddr = (mint: PublicKey) => { - return PublicKey.findProgramAddressSync( - [ - utils.bytes.utf8.encode("metadata"), - MPL_TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - MPL_TOKEN_METADATA_PROGRAM_ID, - ); -}; - -export const getDaoAddr = ({ - nonce, - daoCreator, - programId = FUTARCHY_PROGRAM_ID, -}: { - nonce: BN; - daoCreator: PublicKey; - programId?: PublicKey; -}): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("dao"), - daoCreator.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -/** - * @deprecated Use getAutocratProposalAddr instead - */ -export const getProposalAddr = ( - programId: PublicKey, - squadsProposal: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [utils.bytes.utf8.encode("proposal"), squadsProposal.toBuffer()], - programId, - ); -}; - -export const getProposalAddrV2 = ({ - programId = FUTARCHY_PROGRAM_ID, - squadsProposal, -}: { - programId?: PublicKey; - squadsProposal: PublicKey; -}): [PublicKey, number] => { - return getProposalAddr(programId, squadsProposal); -}; - -export function getLaunchAddr( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - tokenMint: PublicKey, -): [PublicKey, number] { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch"), tokenMint.toBuffer()], - programId, - ); -} - -export const getLaunchSignerAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("launch_signer"), launch.toBuffer()], - programId, - ); -}; - -export const getFundingRecordAddr = ( - programId: PublicKey = LAUNCHPAD_PROGRAM_ID, - launch: PublicKey, - funder: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("funding_record"), launch.toBuffer(), funder.toBuffer()], - programId, - ); -}; - -export const getStakeRecordAddr = ( - programId: PublicKey = SHARED_LIQUIDITY_MANAGER_PROGRAM_ID, - draftProposal: PublicKey, - staker: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("stake_record"), draftProposal.toBuffer(), staker.toBuffer()], - programId, - ); -}; - -export const getStakeAddr = ( - programId: PublicKey = FUTARCHY_PROGRAM_ID, - draftProposal: PublicKey, - staker: PublicKey, -): [PublicKey, number] => { - return PublicKey.findProgramAddressSync( - [Buffer.from("stake"), draftProposal.toBuffer(), staker.toBuffer()], - programId, - ); -}; - -export const getPerformancePackageAddr = ({ - programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - createKey, -}: { - programId?: PublicKey; - createKey: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("performance_package"), createKey.toBuffer()], - programId, - ); -}; - -export const getChangeRequestAddr = ({ - programId = PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, - performancePackage, - proposer, - pdaNonce, -}: { - programId?: PublicKey; - performancePackage: PublicKey; - proposer: PublicKey; - pdaNonce: number; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("change_request"), - performancePackage.toBuffer(), - proposer.toBuffer(), - Buffer.from(new Uint8Array(new Uint32Array([pdaNonce]).buffer)), - ], - programId, - ); -}; - -export const getBidWallAddr = ({ - programId = BID_WALL_PROGRAM_ID, - baseMint, - creator, - nonce, -}: { - programId?: PublicKey; - baseMint: PublicKey; - creator: PublicKey; - nonce: BN; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("bid_wall"), - baseMint.toBuffer(), - creator.toBuffer(), - nonce.toArrayLike(Buffer, "le", 8), - ], - programId, - ); -}; - -export const getMintGovernorAddr = ({ - programId = MINT_GOVERNOR_PROGRAM_ID, - mint, - createKey, -}: { - programId?: PublicKey; - mint: PublicKey; - createKey: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("mint_governor"), mint.toBuffer(), createKey.toBuffer()], - programId, - ); -}; - -export const getMintAuthorityAddr = ({ - programId = MINT_GOVERNOR_PROGRAM_ID, - mintGovernor, - authorizedMinter, -}: { - programId?: PublicKey; - mintGovernor: PublicKey; - authorizedMinter: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("mint_authority"), - mintGovernor.toBuffer(), - authorizedMinter.toBuffer(), - ], - programId, - ); -}; - -export const getPerformancePackageV2Addr = ({ - programId = PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - createKey, -}: { - programId?: PublicKey; - createKey: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [Buffer.from("performance_package"), createKey.toBuffer()], - programId, - ); -}; - -export const getChangeRequestV2Addr = ({ - programId = PERFORMANCE_PACKAGE_V2_PROGRAM_ID, - performancePackage, - proposer, - pdaNonce, -}: { - programId?: PublicKey; - performancePackage: PublicKey; - proposer: PublicKey; - pdaNonce: number; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("change_request"), - performancePackage.toBuffer(), - proposer.toBuffer(), - Buffer.from(new Uint8Array(new Uint32Array([pdaNonce]).buffer)), - ], - programId, - ); -}; - -export const getLiquidationAddr = ({ - programId = LIQUIDATION_PROGRAM_ID, - baseMint, - quoteMint, - createKey, -}: { - programId?: PublicKey; - baseMint: PublicKey; - quoteMint: PublicKey; - createKey: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("liquidation"), - baseMint.toBuffer(), - quoteMint.toBuffer(), - createKey.toBuffer(), - ], - programId, - ); -}; - -export const getRefundRecordAddr = ({ - programId = LIQUIDATION_PROGRAM_ID, - liquidation, - recipient, -}: { - programId?: PublicKey; - liquidation: PublicKey; - recipient: PublicKey; -}) => { - return PublicKey.findProgramAddressSync( - [ - Buffer.from("refund_record"), - liquidation.toBuffer(), - recipient.toBuffer(), - ], - programId, - ); -}; diff --git a/sdk/src/v0.7/utils/priceMath.ts b/sdk/src/v0.7/utils/priceMath.ts deleted file mode 100644 index 4e7addb3c..000000000 --- a/sdk/src/v0.7/utils/priceMath.ts +++ /dev/null @@ -1,197 +0,0 @@ -import BN from "bn.js"; -import { Amm } from "../types/index.js"; -import { AmmMath as V3AmmMath } from "../../v0.3/utils/ammMath.js"; - -const BN_TEN = new BN(10); -const PRICE_SCALE = BN_TEN.pow(new BN(12)); -const PRICE_SCALE_NUMBER = 1e12; - -export type AddLiquiditySimulation = { - baseAmount: BN; - quoteAmount: BN; - expectedLpTokens: BN; - minLpTokens?: BN; - maxBaseAmount?: BN; -}; - -export type SwapSimulation = { - expectedOut: BN; - newBaseReserves: BN; - newQuoteReserves: BN; - minExpectedOut?: BN; -}; - -export type RemoveLiquiditySimulation = { - expectedBaseOut: BN; - expectedQuoteOut: BN; - minBaseOut?: BN; - minQuoteOut?: BN; -}; - -export class AmmMath { - // Re-export common methods from v0.3 - public static getHumanPriceFromReserves = V3AmmMath.getHumanPriceFromReserves; - public static getAmmPriceFromReserves = V3AmmMath.getAmmPriceFromReserves; - public static getChainAmount = V3AmmMath.getChainAmount; - public static getHumanAmount = V3AmmMath.getHumanAmount; - public static getAmmPrice = V3AmmMath.getAmmPrice; - public static getAmmPrices = V3AmmMath.getAmmPrices; - public static scale = V3AmmMath.scale; - public static addSlippage = V3AmmMath.addSlippage; - public static subtractSlippage = V3AmmMath.subtractSlippage; - public static simulateAddLiquidity = V3AmmMath.simulateAddLiquidity; - public static simulateRemoveLiquidity = V3AmmMath.simulateRemoveLiquidity; - - public static getHumanPrice( - ammPrice: BN, - baseDecimals: number, - quoteDecimals: number, - ): number { - const decimalScalar = BN_TEN.pow( - new BN(quoteDecimals - baseDecimals).abs(), - ); - const price1e12 = - quoteDecimals > baseDecimals - ? ammPrice.div(decimalScalar) - : ammPrice.mul(decimalScalar); - - // in case the BN is too large to cast to number, we try - try { - return price1e12.toNumber() / 1e12; - } catch (e) { - // BN tried to cast into number larger than 53 bits so we we do division via BN methods first, then cast to number(so it is smaller before the cast) - return price1e12.div(new BN(1e12)).toNumber(); - } - } - - public static getTwap(amm: Amm): BN { - return amm.oracle.aggregator.div( - amm.oracle.lastUpdatedSlot.sub(amm.createdAtSlot), - ); - } - - public static simulateSwapInner( - inputAmount: BN, - inputReserves: BN, - outputReserves: BN, - ): BN { - if (inputReserves.eqn(0) || outputReserves.eqn(0)) { - throw new Error("reserves must be non-zero"); - } - - let inputAmountWithFee: BN = inputAmount.muln(990); - - let numerator: BN = inputAmountWithFee.mul(outputReserves); - let denominator: BN = inputReserves.muln(1000).add(inputAmountWithFee); - - return numerator.div(denominator); - } - - // public static simulateSwap( - // inputAmount: BN, - // swapType: SwapType, - // baseReserves: BN, - // quoteReserves: BN, - // slippageBps?: BN - // ): SwapSimulation { - // let inputReserves: BN, outputReserves: BN; - // if (swapType.buy) { - // inputReserves = quoteReserves; - // outputReserves = baseReserves; - // } else { - // inputReserves = baseReserves; - // outputReserves = quoteReserves; - // } - - // let expectedOut = this.simulateSwapInner( - // inputAmount, - // inputReserves, - // outputReserves - // ); - - // let minExpectedOut; - // if (slippageBps) { - // minExpectedOut = AmmMath.subtractSlippage(expectedOut, slippageBps); - // } - - // let newBaseReserves: BN, newQuoteReserves: BN; - // if (swapType.buy) { - // newBaseReserves = baseReserves.sub(expectedOut); - // newQuoteReserves = quoteReserves.add(inputAmount); - // } else { - // newBaseReserves = baseReserves.add(inputAmount); - // newQuoteReserves = quoteReserves.sub(expectedOut); - // } - - // return { - // expectedOut, - // newBaseReserves, - // newQuoteReserves, - // minExpectedOut, - // }; - // } - - // /** - // * Calculates the optimal swap amount and mergeable tokens without using square roots. - // * @param userBalanceIn BN – Tokens that a user wants to dispose of. - // * @param ammReserveIn BN – Amount of tokens in the AMM of the token that the user wants to dispose of. - // * @param ammReserveOut BN – Amount of tokens in the AMM of the token that the user wants to receive. - // * @returns An object containing the optimal swap amount, expected quote received, and expected mergeable tokens. - // */ - - // public static calculateOptimalSwapForMerge( - // userBalanceIn: BN, - // ammReserveIn: BN, - // ammReserveOut: BN, - // slippageBps: BN - // ): { - // optimalSwapAmount: BN; - // userInAfterSwap: BN; - // expectedOut: BN; - // minimumExpectedOut: BN; - // } { - // // essentially, we want to calculate the swap amount so that the remaining user balance = received token amount - - // // solve this system of equations for swapAmount, outputAmount (we only care about swap amount tho) - // // (baseReserve + swapAmount) * (quoteReserve - outputAmount) = baseReserve * quoteReserve - // // baseAmount - swapAmount = outputAmount - - // //solve equation - // // (baseReserve + .99*swapAmount) * (quoteReserve - (userTokens - swapAmount)) = baseReserve * quoteReserve - // // multiplying out the left hand side and subtracting baseReserve * quoteReserve from both sides yields the following: - // // baseReserve*quoteReserve - baseReserve*userTokens + baseReserve*swapAmount + .99*swapAmount*quoteReserve - .99*swapAmount*userTokens + .99*swapAmount^2 = baseReserve*quoteReserve - // // .99*swapAmount^2 + baseReserve*swapAmount + .99*swapAmount*quoteReserve - baseReserve*userTokens - .99*swapAmount*userTokens = 0 - // // in the quadratic equation, a = .99, b = (baseReserve + .99*quoteReserve - .99*userTokens), c = -baseReserve*userTokens - // // x = (-b + sqrt(b^2 - 4ac)) / 2a - - // let a = 0.99; - // let b = - // Number(ammReserveIn) + - // 0.99 * Number(ammReserveOut) - - // 0.99 * Number(userBalanceIn); - // let c = -Number(ammReserveIn) * Number(userBalanceIn); - - // let x = (-b + Math.sqrt(b ** 2 - 4 * a * c)) / (2 * a); - // //this should mathematically return a positive number assuming userBalanceIn, ammReserveIn, and ammReserveOut are all positive (which they should be) - // // -b + Math.sqrt(b ** 2 - 4 * a * c) > 0 because -4*a*c > 0 and sqrt(b**2 + positive number) > b - - // const swapAmount = x; - - // let expectedOut = this.simulateSwapInner( - // new BN(swapAmount), - // ammReserveIn, - // ammReserveOut - // ); - // let minimumExpectedOut = - // Number(expectedOut) - (Number(expectedOut) * Number(slippageBps)) / 10000; - // return { - // optimalSwapAmount: new BN(swapAmount), - // userInAfterSwap: new BN(Number(userBalanceIn) - swapAmount), - // expectedOut: expectedOut, - // minimumExpectedOut: new BN(minimumExpectedOut), - // }; - // } -} - -// Add backwards compatibility alias -export { AmmMath as PriceMath }; diff --git a/sdk2/sync-types.sh b/sdk/sync-types.sh similarity index 100% rename from sdk2/sync-types.sh rename to sdk/sync-types.sh diff --git a/sdk/tsconfig.json b/sdk/tsconfig.json index c32ec9659..bba6b521f 100644 --- a/sdk/tsconfig.json +++ b/sdk/tsconfig.json @@ -1,22 +1,8 @@ { "compilerOptions": { - "types": [ - "mocha", - "chai" - ], - "paths": { - "@metadaoproject/futarchy/v0.3": ["./dist/v0.3/types/index.d.ts"], - "@metadaoproject/futarchy/v0.4": ["./dist/v0.4/types/index.d.ts"], - "@metadaoproject/futarchy/v0.5": ["./dist/v0.5/types/index.d.ts"], - "@metadaoproject/futarchy/v0.6": ["./dist/v0.6/types/index.d.ts"], - "@metadaoproject/futarchy/v0.7": ["./dist/v0.6/types/index.d.ts"] - }, - "typeRoots": [ - "./node_modules/@types" - ], - "lib": [ - "esnext" - ], + "types": ["mocha", "chai"], + "typeRoots": ["./node_modules/@types"], + "lib": ["esnext"], "module": "NodeNext", "target": "esnext", "esModuleInterop": true, @@ -25,20 +11,8 @@ "sourceMap": true, "outDir": "dist", "strict": true, - "declaration": true + "declaration": true, }, - "include": [ - "src/*", - "src/v0.3/*", - "src/v0.4/*", - "src/v0.5/*", - "src/v0.6/*", - "src/v0.7/*" - ], - "exclude": [ - "node_modules", - "target", - "tests", - "migrations" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "target", "tests", "migrations"] } diff --git a/sdk/yarn.lock b/sdk/yarn.lock index ced234393..bf1c0f358 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -3160,7 +3160,7 @@ typed-array-buffer@^1.0.3: es-errors "^1.3.0" is-typed-array "^1.1.14" -typescript@^5.5.5: +typescript@5.9.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== diff --git a/sdk2/.gitignore b/sdk2/.gitignore deleted file mode 100644 index 7bd11f8a3..000000000 --- a/sdk2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -tsconfig.tsbuildinfo diff --git a/sdk2/package.json b/sdk2/package.json deleted file mode 100644 index 137a8b4de..000000000 --- a/sdk2/package.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "name": "@metadaoproject/futarchy", - "version": "0.8.0-alpha.0", - "type": "module", - "main": "dist/index.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "exports": { - ".": "./dist/index.js", - "./amm": "./dist/amm/index.js", - "./autocrat": "./dist/autocrat/index.js", - "./bid_wall": "./dist/bid_wall/index.js", - "./conditional_vault": "./dist/conditional_vault/index.js", - "./futarchy": "./dist/futarchy/index.js", - "./launchpad": "./dist/launchpad/index.js", - "./liquidation": "./dist/liquidation/index.js", - "./mint_governor": "./dist/mint_governor/index.js", - "./performance_package_v2": "./dist/performance_package_v2/index.js", - "./price_based_performance_package": "./dist/price_based_performance_package/index.js", - "./shared_liquidity_manager": "./dist/shared_liquidity_manager/index.js", - "./amm/*": "./dist/amm/*/index.js", - "./autocrat/*": "./dist/autocrat/*/index.js", - "./bid_wall/*": "./dist/bid_wall/*/index.js", - "./conditional_vault/*": "./dist/conditional_vault/*/index.js", - "./futarchy/*": "./dist/futarchy/*/index.js", - "./launchpad/*": "./dist/launchpad/*/index.js", - "./liquidation/*": "./dist/liquidation/*/index.js", - "./mint_governor/*": "./dist/mint_governor/*/index.js", - "./performance_package_v2/*": "./dist/performance_package_v2/*/index.js", - "./price_based_performance_package/*": "./dist/price_based_performance_package/*/index.js", - "./shared_liquidity_manager/*": "./dist/shared_liquidity_manager/*/index.js" - }, - "license": "BSL-1.0", - "files": [ - "/dist" - ], - "scripts": { - "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", - "build": "tsc", - "build-local": "rm -rf ./dist && ./sync-types.sh && yarn tsc", - "prepublishOnly": "yarn lint:fix && yarn build" - }, - "dependencies": { - "@coral-xyz/anchor": "^0.29.0", - "@metaplex-foundation/umi": "^0.9.2", - "@metaplex-foundation/umi-bundle-defaults": "^0.9.2", - "@metaplex-foundation/umi-uploader-bundlr": "^0.9.2", - "@noble/hashes": "^1.4.0", - "@solana/spl-token": "^0.3.7", - "@solana/web3.js": "^1.76.0", - "@sqds/multisig": "^2.1.4", - "bn.js": "^5.2.1", - "decimal.js": "^10.4.3", - "esbuild": "^0.17.15" - }, - "devDependencies": { - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "3.6.2", - "solana-bankrun": "^0.2.0", - "spl-token-bankrun": "0.2.3", - "ts-mocha": "^10.0.0", - "typescript": "5.9.3" - }, - "resolutions": { - "error-ex": "=1.3.2", - "strip-ansi": "=6.0.1", - "wrap-ansi": "=7.0.0", - "ansi-styles": "=4.3.0", - "color-string": "=2.1.0", - "is-arrayish": "=0.3.2", - "chalk": "=4.1.2", - "supports-color": "=7.2.0", - "slice-ansi": "=5.0.0", - "ansi-regex": "=5.0.1", - "color-name": "=2.0.0", - "chalk-template": "=0.4.0", - "supports-hyperlinks": "=2.3.0", - "has-ansi": "=4.0.1", - "color-convert": "=2.0.1", - "backslash": "=0.2.0", - "simple-swizzle": "=0.2.2", - "debug": "=4.4.1", - "color": "=4.2.3" - } -} diff --git a/sdk2/src/amm/v0.3/types/amm.ts b/sdk2/src/amm/v0.3/types/amm.ts deleted file mode 100644 index 6e5bcf53a..000000000 --- a/sdk2/src/amm/v0.3/types/amm.ts +++ /dev/null @@ -1,1083 +0,0 @@ -export type Amm = { - version: "0.3.0"; - name: "amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at t2 being smaller than an aggregator at t1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6001; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6002; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6003; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6004; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6005; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6006; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6007; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6008; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6009; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6010; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6011; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6012; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6013; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6014; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6015; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6016; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: Amm = { - version: "0.3.0", - name: "amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at t2 being smaller than an aggregator at t1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6001, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6002, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6003, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6004, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6005, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6006, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6007, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6008, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6009, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6010, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6011, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6012, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6013, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6014, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6015, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6016, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk2/src/amm/v0.4/types/amm.ts b/sdk2/src/amm/v0.4/types/amm.ts deleted file mode 100644 index 72fc00cc8..000000000 --- a/sdk2/src/amm/v0.4/types/amm.ts +++ /dev/null @@ -1,1647 +0,0 @@ -export type Amm = { - version: "0.4.1"; - name: "amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: Amm = { - version: "0.4.1", - name: "amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk2/src/amm/v0.5/types/amm.ts b/sdk2/src/amm/v0.5/types/amm.ts deleted file mode 100644 index 6d36be8d8..000000000 --- a/sdk2/src/amm/v0.5/types/amm.ts +++ /dev/null @@ -1,1663 +0,0 @@ -export type Amm = { - version: "0.5.0"; - name: "amm"; - instructions: [ - { - name: "createAmm"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CreateAmmArgs"; - }; - }, - ]; - }, - { - name: "addLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddLiquidityArgs"; - }; - }, - ]; - }, - { - name: "removeLiquidity"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "userLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "RemoveLiquidityArgs"; - }; - }, - ]; - }, - { - name: "swap"; - accounts: [ - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaBase"; - isMut: true; - isSigner: false; - }, - { - name: "vaultAtaQuote"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SwapArgs"; - }; - }, - ]; - }, - { - name: "crankThatTwap"; - accounts: [ - { - name: "amm"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "amm"; - type: { - kind: "struct"; - fields: [ - { - name: "bump"; - type: "u8"; - }, - { - name: "createdAtSlot"; - type: "u64"; - }, - { - name: "lpMint"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "baseMintDecimals"; - type: "u8"; - }, - { - name: "quoteMintDecimals"; - type: "u8"; - }, - { - name: "baseAmount"; - type: "u64"; - }, - { - name: "quoteAmount"; - type: "u64"; - }, - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "user"; - type: "publicKey"; - }, - { - name: "amm"; - type: "publicKey"; - }, - { - name: "postBaseReserves"; - type: "u64"; - }, - { - name: "postQuoteReserves"; - type: "u64"; - }, - { - name: "oracleLastPrice"; - type: "u128"; - }, - { - name: "oracleLastObservation"; - type: "u128"; - }, - { - name: "oracleAggregator"; - type: "u128"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLpTokens"; - docs: ["The minimum LP token you will get back"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "CreateAmmArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - ]; - }; - }, - { - name: "RemoveLiquidityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "lpTokensToBurn"; - type: "u64"; - }, - { - name: "minQuoteAmount"; - type: "u64"; - }, - { - name: "minBaseAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "outputAmountMin"; - type: "u64"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "lastUpdatedSlot"; - type: "u64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySlots"; - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "SwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - ]; - }, - { - name: "AddLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "maxBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minLpTokens"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "lpTokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RemoveLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "lpTokensBurned"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "CreateAmmEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "lpMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaBase"; - type: "publicKey"; - index: false; - }, - { - name: "vaultAtaQuote"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "CrankThatTwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "NoSlotsPassed"; - msg: "Can't get a TWAP before some observations have been stored"; - }, - { - code: 6002; - name: "NoReserves"; - msg: "Can't swap through a pool without token reserves on either side"; - }, - { - code: 6003; - name: "InputAmountOverflow"; - msg: "Input token amount is too large for a swap, causes overflow"; - }, - { - code: 6004; - name: "AddLiquidityCalculationError"; - msg: "Add liquidity calculation error"; - }, - { - code: 6005; - name: "DecimalScaleError"; - msg: "Error in decimal scale conversion"; - }, - { - code: 6006; - name: "SameTokenMints"; - msg: "You can't create an AMM pool where the token mints are the same"; - }, - { - code: 6007; - name: "SwapSlippageExceeded"; - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting"; - }, - { - code: 6008; - name: "InsufficientBalance"; - msg: "The user had insufficient balance to do this"; - }, - { - code: 6009; - name: "ZeroLiquidityRemove"; - msg: "Must remove a non-zero amount of liquidity"; - }, - { - code: 6010; - name: "ZeroLiquidityToAdd"; - msg: "Cannot add liquidity with 0 tokens on either side"; - }, - { - code: 6011; - name: "ZeroMinLpTokens"; - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool"; - }, - { - code: 6012; - name: "AddLiquiditySlippageExceeded"; - msg: "LP wouldn't have gotten back `lp_token_min`"; - }, - { - code: 6013; - name: "AddLiquidityMaxBaseExceeded"; - msg: "LP would have spent more than `max_base_amount`"; - }, - { - code: 6014; - name: "InsufficientQuoteAmount"; - msg: "`quote_amount` must be greater than 100000000 when initializing a pool"; - }, - { - code: 6015; - name: "ZeroSwapAmount"; - msg: "Users must swap a non-zero amount"; - }, - { - code: 6016; - name: "ConstantProductInvariantFailed"; - msg: "K should always be increasing"; - }, - { - code: 6017; - name: "CastingOverflow"; - msg: "Casting has caused an overflow"; - }, - ]; -}; - -export const IDL: Amm = { - version: "0.5.0", - name: "amm", - instructions: [ - { - name: "createAmm", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CreateAmmArgs", - }, - }, - ], - }, - { - name: "addLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddLiquidityArgs", - }, - }, - ], - }, - { - name: "removeLiquidity", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "userLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "RemoveLiquidityArgs", - }, - }, - ], - }, - { - name: "swap", - accounts: [ - { - name: "user", - isMut: true, - isSigner: true, - }, - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaBase", - isMut: true, - isSigner: false, - }, - { - name: "vaultAtaQuote", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SwapArgs", - }, - }, - ], - }, - { - name: "crankThatTwap", - accounts: [ - { - name: "amm", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "amm", - type: { - kind: "struct", - fields: [ - { - name: "bump", - type: "u8", - }, - { - name: "createdAtSlot", - type: "u64", - }, - { - name: "lpMint", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "baseMintDecimals", - type: "u8", - }, - { - name: "quoteMintDecimals", - type: "u8", - }, - { - name: "baseAmount", - type: "u64", - }, - { - name: "quoteAmount", - type: "u64", - }, - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "vaultAtaBase", - type: "publicKey", - }, - { - name: "vaultAtaQuote", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "user", - type: "publicKey", - }, - { - name: "amm", - type: "publicKey", - }, - { - name: "postBaseReserves", - type: "u64", - }, - { - name: "postQuoteReserves", - type: "u64", - }, - { - name: "oracleLastPrice", - type: "u128", - }, - { - name: "oracleLastObservation", - type: "u128", - }, - { - name: "oracleAggregator", - type: "u128", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLpTokens", - docs: ["The minimum LP token you will get back"], - type: "u64", - }, - ], - }, - }, - { - name: "CreateAmmArgs", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - ], - }, - }, - { - name: "RemoveLiquidityArgs", - type: { - kind: "struct", - fields: [ - { - name: "lpTokensToBurn", - type: "u64", - }, - { - name: "minQuoteAmount", - type: "u64", - }, - { - name: "minBaseAmount", - type: "u64", - }, - ], - }, - }, - { - name: "SwapArgs", - type: { - kind: "struct", - fields: [ - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "outputAmountMin", - type: "u64", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "lastUpdatedSlot", - type: "u64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySlots", - docs: [ - "Number of slots after amm.created_at_slot to start recording TWAP", - ], - type: "u64", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - ], - events: [ - { - name: "SwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - ], - }, - { - name: "AddLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "maxBaseAmount", - type: "u64", - index: false, - }, - { - name: "minLpTokens", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "lpTokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "RemoveLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "lpTokensBurned", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "CreateAmmEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "lpMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaBase", - type: "publicKey", - index: false, - }, - { - name: "vaultAtaQuote", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "CrankThatTwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "NoSlotsPassed", - msg: "Can't get a TWAP before some observations have been stored", - }, - { - code: 6002, - name: "NoReserves", - msg: "Can't swap through a pool without token reserves on either side", - }, - { - code: 6003, - name: "InputAmountOverflow", - msg: "Input token amount is too large for a swap, causes overflow", - }, - { - code: 6004, - name: "AddLiquidityCalculationError", - msg: "Add liquidity calculation error", - }, - { - code: 6005, - name: "DecimalScaleError", - msg: "Error in decimal scale conversion", - }, - { - code: 6006, - name: "SameTokenMints", - msg: "You can't create an AMM pool where the token mints are the same", - }, - { - code: 6007, - name: "SwapSlippageExceeded", - msg: "A user wouldn't have gotten back their `output_amount_min`, reverting", - }, - { - code: 6008, - name: "InsufficientBalance", - msg: "The user had insufficient balance to do this", - }, - { - code: 6009, - name: "ZeroLiquidityRemove", - msg: "Must remove a non-zero amount of liquidity", - }, - { - code: 6010, - name: "ZeroLiquidityToAdd", - msg: "Cannot add liquidity with 0 tokens on either side", - }, - { - code: 6011, - name: "ZeroMinLpTokens", - msg: "Must specify a non-zero `min_lp_tokens` when adding to an existing pool", - }, - { - code: 6012, - name: "AddLiquiditySlippageExceeded", - msg: "LP wouldn't have gotten back `lp_token_min`", - }, - { - code: 6013, - name: "AddLiquidityMaxBaseExceeded", - msg: "LP would have spent more than `max_base_amount`", - }, - { - code: 6014, - name: "InsufficientQuoteAmount", - msg: "`quote_amount` must be greater than 100000000 when initializing a pool", - }, - { - code: 6015, - name: "ZeroSwapAmount", - msg: "Users must swap a non-zero amount", - }, - { - code: 6016, - name: "ConstantProductInvariantFailed", - msg: "K should always be increasing", - }, - { - code: 6017, - name: "CastingOverflow", - msg: "Casting has caused an overflow", - }, - ], -}; diff --git a/sdk2/src/autocrat/v0.3/cu.ts b/sdk2/src/autocrat/v0.3/cu.ts deleted file mode 100644 index 086df7c24..000000000 --- a/sdk2/src/autocrat/v0.3/cu.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const MaxCUs = { - initializeDao: 20_000, - createIdempotent: 25_000, - initializeConditionalVault: 45_000, - mintConditionalTokens: 35_000, - initializeAmm: 120_000, - addLiquidity: 120_000, - initializeProposal: 60_000, -}; - -export const DEFAULT_CU_PRICE = 1; diff --git a/sdk2/src/autocrat/v0.3/types/autocrat.ts b/sdk2/src/autocrat/v0.3/types/autocrat.ts deleted file mode 100644 index e39706bc1..000000000 --- a/sdk2/src/autocrat/v0.3/types/autocrat.ts +++ /dev/null @@ -1,1263 +0,0 @@ -export type Autocrat = { - version: "0.3.0"; - name: "autocrat"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "usdcMint"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasury"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "treasury"; - isMut: false; - isSigner: true; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "treasuryPdaBump"; - type: "u8"; - }, - { - name: "treasury"; - type: "publicKey"; - }, - { - name: "tokenMint"; - type: "publicKey"; - }, - { - name: "usdcMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "slotEnqueued"; - type: "u64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "passAmm"; - type: "publicKey"; - }, - { - name: "failAmm"; - type: "publicKey"; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - }, - { - name: "nonce"; - docs: [ - "We need to include a per-proposer nonce to prevent some weird proposal", - "front-running edge cases. Using a `u64` means that proposers are unlikely", - "to run into collisions, even if they generate nonces randomly - I've run", - "the math :D", - ]; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitializeProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "passLpTokensToLock"; - type: "u64"; - }, - { - name: "failLpTokensToLock"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "ProposalAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "ProposalInstruction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "ProposalAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6004; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6005; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6006; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6007; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6008; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6009; - name: "InsufficientLpTokenBalance"; - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; - }, - { - code: 6010; - name: "InsufficientLpTokenLock"; - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; - }, - ]; -}; - -export const IDL: Autocrat = { - version: "0.3.0", - name: "autocrat", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - }, - { - name: "usdcMint", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalParams", - }, - }, - ], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "treasury", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "treasury", - isMut: false, - isSigner: true, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - ], - accounts: [ - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "treasuryPdaBump", - type: "u8", - }, - { - name: "treasury", - type: "publicKey", - }, - { - name: "tokenMint", - type: "publicKey", - }, - { - name: "usdcMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "descriptionUrl", - type: "string", - }, - { - name: "slotEnqueued", - type: "u64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "passAmm", - type: "publicKey", - }, - { - name: "failAmm", - type: "publicKey", - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "passLpTokensLocked", - type: "u64", - }, - { - name: "failLpTokensLocked", - type: "u64", - }, - { - name: "nonce", - docs: [ - "We need to include a per-proposer nonce to prevent some weird proposal", - "front-running edge cases. Using a `u64` means that proposers are unlikely", - "to run into collisions, even if they generate nonces randomly - I've run", - "the math :D", - ], - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitializeProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "descriptionUrl", - type: "string", - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "passLpTokensToLock", - type: "u64", - }, - { - name: "failLpTokensToLock", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "ProposalAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "ProposalInstruction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "ProposalAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6004, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6005, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6006, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6007, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6008, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6009, - name: "InsufficientLpTokenBalance", - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", - }, - { - code: 6010, - name: "InsufficientLpTokenLock", - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", - }, - ], -}; diff --git a/sdk2/src/autocrat/v0.4/types/autocrat.ts b/sdk2/src/autocrat/v0.4/types/autocrat.ts deleted file mode 100644 index c1d8a3f89..000000000 --- a/sdk2/src/autocrat/v0.4/types/autocrat.ts +++ /dev/null @@ -1,2013 +0,0 @@ -export type Autocrat = { - version: "0.4.2"; - name: "autocrat"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "usdcMint"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "treasury"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "treasury"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "treasuryPdaBump"; - type: "u8"; - }, - { - name: "treasury"; - type: "publicKey"; - }, - { - name: "tokenMint"; - type: "publicKey"; - }, - { - name: "usdcMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ]; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "slotEnqueued"; - type: "u64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "passAmm"; - type: "publicKey"; - }, - { - name: "failAmm"; - type: "publicKey"; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - }, - { - name: "nonce"; - docs: [ - "We need to include a per-proposer nonce to prevent some weird proposal", - "front-running edge cases. Using a `u64` means that proposers are unlikely", - "to run into collisions, even if they generate nonces randomly - I've run", - "the math :D", - ]; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSlots"; - type: "u64"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitializeProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - }, - { - name: "passLpTokensToLock"; - type: "u64"; - }, - { - name: "failLpTokensToLock"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "ProposalAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "pubkey"; - type: "publicKey"; - }, - { - name: "isSigner"; - type: "bool"; - }, - { - name: "isWritable"; - type: "bool"; - }, - ]; - }; - }, - { - name: "ProposalInstruction"; - type: { - kind: "struct"; - fields: [ - { - name: "programId"; - type: "publicKey"; - }, - { - name: "accounts"; - type: { - vec: { - defined: "ProposalAccount"; - }; - }; - }, - { - name: "data"; - type: "bytes"; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - { - name: "Executed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "tokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "usdcMint"; - type: "publicKey"; - index: false; - }, - { - name: "treasury"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "passAmm"; - type: "publicKey"; - index: false; - }, - { - name: "failAmm"; - type: "publicKey"; - index: false; - }, - { - name: "passLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "failLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "nonce"; - type: "u64"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "instruction"; - type: { - defined: "ProposalInstruction"; - }; - index: false; - }, - { - name: "durationInSlots"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - ]; - }, - { - name: "ExecuteProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLpTokenBalance"; - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; - }, - { - code: 6011; - name: "InsufficientLpTokenLock"; - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; - }, - ]; -}; - -export const IDL: Autocrat = { - version: "0.4.2", - name: "autocrat", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - }, - { - name: "usdcMint", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalParams", - }, - }, - ], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "treasury", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "treasury", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - ], - accounts: [ - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "treasuryPdaBump", - type: "u8", - }, - { - name: "treasury", - type: "publicKey", - }, - { - name: "tokenMint", - type: "publicKey", - }, - { - name: "usdcMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ], - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "descriptionUrl", - type: "string", - }, - { - name: "slotEnqueued", - type: "u64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "passAmm", - type: "publicKey", - }, - { - name: "failAmm", - type: "publicKey", - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "passLpTokensLocked", - type: "u64", - }, - { - name: "failLpTokensLocked", - type: "u64", - }, - { - name: "nonce", - docs: [ - "We need to include a per-proposer nonce to prevent some weird proposal", - "front-running edge cases. Using a `u64` means that proposers are unlikely", - "to run into collisions, even if they generate nonces randomly - I've run", - "the math :D", - ], - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSlots", - type: "u64", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitializeProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "descriptionUrl", - type: "string", - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - }, - { - name: "passLpTokensToLock", - type: "u64", - }, - { - name: "failLpTokensToLock", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "ProposalAccount", - type: { - kind: "struct", - fields: [ - { - name: "pubkey", - type: "publicKey", - }, - { - name: "isSigner", - type: "bool", - }, - { - name: "isWritable", - type: "bool", - }, - ], - }, - }, - { - name: "ProposalInstruction", - type: { - kind: "struct", - fields: [ - { - name: "programId", - type: "publicKey", - }, - { - name: "accounts", - type: { - vec: { - defined: "ProposalAccount", - }, - }, - }, - { - name: "data", - type: "bytes", - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - { - name: "Executed", - }, - ], - }, - }, - ], - events: [ - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "tokenMint", - type: "publicKey", - index: false, - }, - { - name: "usdcMint", - type: "publicKey", - index: false, - }, - { - name: "treasury", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "passAmm", - type: "publicKey", - index: false, - }, - { - name: "failAmm", - type: "publicKey", - index: false, - }, - { - name: "passLpMint", - type: "publicKey", - index: false, - }, - { - name: "failLpMint", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "nonce", - type: "u64", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "passLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "failLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "instruction", - type: { - defined: "ProposalInstruction", - }, - index: false, - }, - { - name: "durationInSlots", - type: "u64", - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - ], - }, - { - name: "ExecuteProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLpTokenBalance", - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", - }, - { - code: 6011, - name: "InsufficientLpTokenLock", - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", - }, - ], -}; diff --git a/sdk2/src/autocrat/v0.5/types/autocrat.ts b/sdk2/src/autocrat/v0.5/types/autocrat.ts deleted file mode 100644 index 48334f703..000000000 --- a/sdk2/src/autocrat/v0.5/types/autocrat.ts +++ /dev/null @@ -1,2121 +0,0 @@ -export type Autocrat = { - version: "0.5.0"; - name: "autocrat"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failLpMint"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "passAmm"; - isMut: false; - isSigner: false; - }, - { - name: "failAmm"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "passLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpUserAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "failLpVaultAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ]; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "slotEnqueued"; - type: "u64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "passAmm"; - type: "publicKey"; - }, - { - name: "failAmm"; - type: "publicKey"; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSlots"; - type: "u64"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySlots"; - type: "u64"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "slotsPerProposal"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "InitializeProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "descriptionUrl"; - type: "string"; - }, - { - name: "passLpTokensToLock"; - type: "u64"; - }, - { - name: "failLpTokensToLock"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "slotsPerProposal"; - type: { - option: "u64"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "slotsPerProposal"; - type: "u64"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "passAmm"; - type: "publicKey"; - index: false; - }, - { - name: "failAmm"; - type: "publicKey"; - index: false; - }, - { - name: "passLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "failLpMint"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "passLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "failLpTokensLocked"; - type: "u64"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSlots"; - type: "u64"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "ExecuteProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLpTokenBalance"; - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock"; - }, - { - code: 6011; - name: "InsufficientLpTokenLock"; - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`"; - }, - { - code: 6012; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer than TWAP start delay"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Draft status"; - }, - ]; -}; - -export const IDL: Autocrat = { - version: "0.5.0", - name: "autocrat", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failLpMint", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeProposalParams", - }, - }, - ], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "passAmm", - isMut: false, - isSigner: false, - }, - { - name: "failAmm", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "passLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpUserAccount", - isMut: true, - isSigner: false, - }, - { - name: "passLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "failLpVaultAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - ], - accounts: [ - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - docs: [ - "Forces TWAP calculation to start after amm.created_at_slot + twap_start_delay_slots", - ], - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "descriptionUrl", - type: "string", - }, - { - name: "slotEnqueued", - type: "u64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "passAmm", - type: "publicKey", - }, - { - name: "failAmm", - type: "publicKey", - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "passLpTokensLocked", - type: "u64", - }, - { - name: "failLpTokensLocked", - type: "u64", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSlots", - type: "u64", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySlots", - type: "u64", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "slotsPerProposal", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "InitializeProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "descriptionUrl", - type: "string", - }, - { - name: "passLpTokensToLock", - type: "u64", - }, - { - name: "failLpTokensToLock", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "slotsPerProposal", - type: { - option: "u64", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - ], - }, - }, - ], - events: [ - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "slotsPerProposal", - type: "u64", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "passAmm", - type: "publicKey", - index: false, - }, - { - name: "failAmm", - type: "publicKey", - index: false, - }, - { - name: "passLpMint", - type: "publicKey", - index: false, - }, - { - name: "failLpMint", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "passLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "failLpTokensLocked", - type: "u64", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSlots", - type: "u64", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "ExecuteProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLpTokenBalance", - msg: "The proposer has fewer pass or fail LP tokens than they requested to lock", - }, - { - code: 6011, - name: "InsufficientLpTokenLock", - msg: "The LP tokens passed in have less liquidity than the DAO's `min_quote_futarchic_liquidity` or `min_base_futachic_liquidity`", - }, - { - code: 6012, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer than TWAP start delay", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Draft status", - }, - ], -}; diff --git a/sdk2/src/bid_wall/v0.7/types/bid_wall.ts b/sdk2/src/bid_wall/v0.7/types/bid_wall.ts deleted file mode 100644 index d54b464bd..000000000 --- a/sdk2/src/bid_wall/v0.7/types/bid_wall.ts +++ /dev/null @@ -1,1435 +0,0 @@ -export type BidWall = { - version: "0.7.0"; - name: "bid_wall"; - instructions: [ - { - name: "initializeBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "creator"; - isMut: false; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "creatorQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "daoTreasury"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeBidWallArgs"; - }; - }, - ]; - }, - { - name: "closeBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authorityQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "sellTokens"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: false; - isSigner: true; - }, - { - name: "userTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "daoTreasury"; - isMut: false; - isSigner: false; - }, - { - name: "daoTreasuryQuoteTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SellTokensArgs"; - }; - }, - ]; - }, - { - name: "collectFees"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "cranker"; - isMut: false; - isSigner: true; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "cancelBidWall"; - accounts: [ - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authorityQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipientQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "bidWall"; - type: { - kind: "struct"; - fields: [ - { - name: "nonce"; - docs: ["The nonce of the bid wall."]; - type: "u64"; - }, - { - name: "createdTimestamp"; - docs: ["When the bid wall was created."]; - type: "i64"; - }, - { - name: "initialAmmQuoteReserves"; - docs: ["The initial quote (USDC) reserves of the Futarchy AMM."]; - type: "u64"; - }, - { - name: "quoteAmount"; - docs: [ - "The current amount of quote tokens assigned to the bid wall.", - "This is different from the amount in the bid wall quote token account,", - "because anyone can transfer quote tokens to the bid wall, and we don't want that to affect the bid wall's NAV calculation.", - ]; - type: "u64"; - }, - { - name: "feesCollected"; - docs: ["The fees collected by the bid wall."]; - type: "u64"; - }, - { - name: "baseBoughtAmount"; - docs: ["The amount of base tokens bought up by the bid wall."]; - type: "u64"; - }, - { - name: "seqNum"; - docs: ["The event sequence number of the bid wall."]; - type: "u64"; - }, - { - name: "creator"; - docs: ["The authority of the bid wall."]; - type: "publicKey"; - }, - { - name: "authority"; - docs: ["The authority of the bid wall."]; - type: "publicKey"; - }, - { - name: "daoTreasury"; - docs: ["The DAO treasury address."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: ["The mint of the token being sold into the bid wall."]; - type: "publicKey"; - }, - { - name: "feeRecipient"; - docs: ["The recipient of the fees collected by the bid wall."]; - type: "publicKey"; - }, - { - name: "durationSeconds"; - docs: [ - "The minimum duration in seconds before the bid wall can be closed.", - ]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "bidWallSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeBidWallArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialAmmQuoteReserves"; - type: "u64"; - }, - { - name: "durationSeconds"; - type: "u32"; - }, - ]; - }; - }, - { - name: "SellTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amountIn"; - type: "u64"; - }, - { - name: "minAmountOut"; - type: "u64"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "BidWallInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "bidWall"; - type: "publicKey"; - index: false; - }, - { - name: "nonce"; - type: "u64"; - index: false; - }, - { - name: "initialAmmQuoteReserves"; - type: "u64"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "creator"; - type: "publicKey"; - index: false; - }, - { - name: "authority"; - type: "publicKey"; - index: false; - }, - { - name: "daoTreasury"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "feeRecipient"; - type: "publicKey"; - index: false; - }, - { - name: "durationSeconds"; - type: "u32"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - ]; - }, - { - name: "BidWallTokensSoldEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "bidWall"; - type: "publicKey"; - index: false; - }, - { - name: "amountIn"; - type: "u64"; - index: false; - }, - { - name: "amountOut"; - type: "u64"; - index: false; - }, - { - name: "fee"; - type: "u64"; - index: false; - }, - { - name: "postBidWallQuoteTokenAccountAmount"; - type: "u64"; - index: false; - }, - { - name: "postBidWallBaseBoughtAmount"; - type: "u64"; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "BidWallFeesCollectedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "bidWall"; - type: "publicKey"; - index: false; - }, - { - name: "feesCollected"; - type: "u64"; - index: false; - }, - { - name: "postBidWallQuoteTokenAccountAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "BidWallClosedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "bidWall"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "BidWallCanceledEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "bidWall"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "BidWallExpired"; - msg: "Bid wall expired"; - }, - { - code: 6001; - name: "BidWallNotExpired"; - msg: "Bid wall not expired"; - }, - { - code: 6002; - name: "FeeRecipientMismatch"; - msg: "Fee recipient mismatch"; - }, - { - code: 6003; - name: "InsufficientQuoteReserves"; - msg: "Insufficient quote reserves"; - }, - { - code: 6004; - name: "BidWallDepleted"; - msg: "Bid wall depleted"; - }, - { - code: 6005; - name: "InvalidInputAmount"; - msg: "Invalid input amount"; - }, - { - code: 6006; - name: "InvalidCrankAddress"; - msg: "Invalid crank address"; - }, - { - code: 6007; - name: "InsufficientOutputAmount"; - msg: "Insufficient output amount"; - }, - ]; -}; - -export const IDL: BidWall = { - version: "0.7.0", - name: "bid_wall", - instructions: [ - { - name: "initializeBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "creator", - isMut: false, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "creatorQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "daoTreasury", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeBidWallArgs", - }, - }, - ], - }, - { - name: "closeBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authorityQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "sellTokens", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: false, - isSigner: true, - }, - { - name: "userTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "daoTreasury", - isMut: false, - isSigner: false, - }, - { - name: "daoTreasuryQuoteTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SellTokensArgs", - }, - }, - ], - }, - { - name: "collectFees", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "cranker", - isMut: false, - isSigner: true, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "cancelBidWall", - accounts: [ - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authorityQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipientQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "bidWall", - type: { - kind: "struct", - fields: [ - { - name: "nonce", - docs: ["The nonce of the bid wall."], - type: "u64", - }, - { - name: "createdTimestamp", - docs: ["When the bid wall was created."], - type: "i64", - }, - { - name: "initialAmmQuoteReserves", - docs: ["The initial quote (USDC) reserves of the Futarchy AMM."], - type: "u64", - }, - { - name: "quoteAmount", - docs: [ - "The current amount of quote tokens assigned to the bid wall.", - "This is different from the amount in the bid wall quote token account,", - "because anyone can transfer quote tokens to the bid wall, and we don't want that to affect the bid wall's NAV calculation.", - ], - type: "u64", - }, - { - name: "feesCollected", - docs: ["The fees collected by the bid wall."], - type: "u64", - }, - { - name: "baseBoughtAmount", - docs: ["The amount of base tokens bought up by the bid wall."], - type: "u64", - }, - { - name: "seqNum", - docs: ["The event sequence number of the bid wall."], - type: "u64", - }, - { - name: "creator", - docs: ["The authority of the bid wall."], - type: "publicKey", - }, - { - name: "authority", - docs: ["The authority of the bid wall."], - type: "publicKey", - }, - { - name: "daoTreasury", - docs: ["The DAO treasury address."], - type: "publicKey", - }, - { - name: "baseMint", - docs: ["The mint of the token being sold into the bid wall."], - type: "publicKey", - }, - { - name: "feeRecipient", - docs: ["The recipient of the fees collected by the bid wall."], - type: "publicKey", - }, - { - name: "durationSeconds", - docs: [ - "The minimum duration in seconds before the bid wall can be closed.", - ], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "bidWallSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeBidWallArgs", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialAmmQuoteReserves", - type: "u64", - }, - { - name: "durationSeconds", - type: "u32", - }, - ], - }, - }, - { - name: "SellTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "amountIn", - type: "u64", - }, - { - name: "minAmountOut", - type: "u64", - }, - ], - }, - }, - ], - events: [ - { - name: "BidWallInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "bidWall", - type: "publicKey", - index: false, - }, - { - name: "nonce", - type: "u64", - index: false, - }, - { - name: "initialAmmQuoteReserves", - type: "u64", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "creator", - type: "publicKey", - index: false, - }, - { - name: "authority", - type: "publicKey", - index: false, - }, - { - name: "daoTreasury", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "feeRecipient", - type: "publicKey", - index: false, - }, - { - name: "durationSeconds", - type: "u32", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - ], - }, - { - name: "BidWallTokensSoldEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "bidWall", - type: "publicKey", - index: false, - }, - { - name: "amountIn", - type: "u64", - index: false, - }, - { - name: "amountOut", - type: "u64", - index: false, - }, - { - name: "fee", - type: "u64", - index: false, - }, - { - name: "postBidWallQuoteTokenAccountAmount", - type: "u64", - index: false, - }, - { - name: "postBidWallBaseBoughtAmount", - type: "u64", - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "BidWallFeesCollectedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "bidWall", - type: "publicKey", - index: false, - }, - { - name: "feesCollected", - type: "u64", - index: false, - }, - { - name: "postBidWallQuoteTokenAccountAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "BidWallClosedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "bidWall", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "BidWallCanceledEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "bidWall", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "BidWallExpired", - msg: "Bid wall expired", - }, - { - code: 6001, - name: "BidWallNotExpired", - msg: "Bid wall not expired", - }, - { - code: 6002, - name: "FeeRecipientMismatch", - msg: "Fee recipient mismatch", - }, - { - code: 6003, - name: "InsufficientQuoteReserves", - msg: "Insufficient quote reserves", - }, - { - code: 6004, - name: "BidWallDepleted", - msg: "Bid wall depleted", - }, - { - code: 6005, - name: "InvalidInputAmount", - msg: "Invalid input amount", - }, - { - code: 6006, - name: "InvalidCrankAddress", - msg: "Invalid crank address", - }, - { - code: 6007, - name: "InsufficientOutputAmount", - msg: "Insufficient output amount", - }, - ], -}; diff --git a/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts b/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts deleted file mode 100644 index 4f7d69b99..000000000 --- a/sdk2/src/conditional_vault/v0.3/types/conditional_vault.ts +++ /dev/null @@ -1,895 +0,0 @@ -export type ConditionalVault = { - version: "0.3.0"; - name: "conditional_vault"; - instructions: [ - { - name: "initializeConditionalVault"; - accounts: [ - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeConditionalVaultArgs"; - }; - }, - ]; - }, - { - name: "addMetadataToConditionalTokens"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "underlyingTokenMetadata"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMetadataToConditionalTokensArgs"; - }; - }, - ]; - }, - { - name: "settleConditionalVault"; - accounts: [ - { - name: "settlementAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - ]; - args: [ - { - name: "newStatus"; - type: { - defined: "VaultStatus"; - }; - }, - ]; - }, - { - name: "mergeConditionalTokensForUnderlyingTokens"; - accounts: [ - { - name: "vault"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userConditionalOnFinalizeTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userConditionalOnRevertTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "mintConditionalTokens"; - accounts: [ - { - name: "vault"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userConditionalOnFinalizeTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userConditionalOnRevertTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "redeemConditionalTokensForUnderlyingTokens"; - accounts: [ - { - name: "vault"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalOnFinalizeTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalOnRevertTokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userConditionalOnFinalizeTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userConditionalOnRevertTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "conditionalVault"; - type: { - kind: "struct"; - fields: [ - { - name: "status"; - type: { - defined: "VaultStatus"; - }; - }, - { - name: "settlementAuthority"; - docs: [ - "The account that can either finalize the vault to make conditional tokens", - "redeemable for underlying tokens or revert the vault to make deposit", - "slips redeemable for underlying tokens.", - ]; - type: "publicKey"; - }, - { - name: "underlyingTokenMint"; - docs: ["The mint of the tokens that are deposited into the vault."]; - type: "publicKey"; - }, - { - name: "underlyingTokenAccount"; - docs: ["The vault's storage account for deposited funds."]; - type: "publicKey"; - }, - { - name: "conditionalOnFinalizeTokenMint"; - type: "publicKey"; - }, - { - name: "conditionalOnRevertTokenMint"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "decimals"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "AddMetadataToConditionalTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "proposalNumber"; - type: "u64"; - }, - { - name: "onFinalizeUri"; - type: "string"; - }, - { - name: "onRevertUri"; - type: "string"; - }, - ]; - }; - }, - { - name: "InitializeConditionalVaultArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "settlementAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "VaultStatus"; - type: { - kind: "enum"; - variants: [ - { - name: "Active"; - }, - { - name: "Finalized"; - }, - { - name: "Reverted"; - }, - ]; - }; - }, - ]; - errors: [ - { - code: 6000; - name: "InsufficientUnderlyingTokens"; - msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; - }, - { - code: 6001; - name: "InvalidVaultUnderlyingTokenAccount"; - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; - }, - { - code: 6002; - name: "InvalidConditionalTokenMint"; - msg: "This conditional token mint is not this vault's conditional token mint"; - }, - { - code: 6003; - name: "CantRedeemConditionalTokens"; - msg: "Vault needs to be settled as finalized before users can redeem conditional tokens for underlying tokens"; - }, - { - code: 6004; - name: "VaultAlreadySettled"; - msg: "Once a vault has been settled, its status as either finalized or reverted cannot be changed"; - }, - ]; -}; - -export const IDL: ConditionalVault = { - version: "0.3.0", - name: "conditional_vault", - instructions: [ - { - name: "initializeConditionalVault", - accounts: [ - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeConditionalVaultArgs", - }, - }, - ], - }, - { - name: "addMetadataToConditionalTokens", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "underlyingTokenMetadata", - isMut: false, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMetadataToConditionalTokensArgs", - }, - }, - ], - }, - { - name: "settleConditionalVault", - accounts: [ - { - name: "settlementAuthority", - isMut: false, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - ], - args: [ - { - name: "newStatus", - type: { - defined: "VaultStatus", - }, - }, - ], - }, - { - name: "mergeConditionalTokensForUnderlyingTokens", - accounts: [ - { - name: "vault", - isMut: false, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userConditionalOnFinalizeTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userConditionalOnRevertTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "mintConditionalTokens", - accounts: [ - { - name: "vault", - isMut: false, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userConditionalOnFinalizeTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userConditionalOnRevertTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "redeemConditionalTokensForUnderlyingTokens", - accounts: [ - { - name: "vault", - isMut: false, - isSigner: false, - }, - { - name: "conditionalOnFinalizeTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalOnRevertTokenMint", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userConditionalOnFinalizeTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userConditionalOnRevertTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "conditionalVault", - type: { - kind: "struct", - fields: [ - { - name: "status", - type: { - defined: "VaultStatus", - }, - }, - { - name: "settlementAuthority", - docs: [ - "The account that can either finalize the vault to make conditional tokens", - "redeemable for underlying tokens or revert the vault to make deposit", - "slips redeemable for underlying tokens.", - ], - type: "publicKey", - }, - { - name: "underlyingTokenMint", - docs: ["The mint of the tokens that are deposited into the vault."], - type: "publicKey", - }, - { - name: "underlyingTokenAccount", - docs: ["The vault's storage account for deposited funds."], - type: "publicKey", - }, - { - name: "conditionalOnFinalizeTokenMint", - type: "publicKey", - }, - { - name: "conditionalOnRevertTokenMint", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "decimals", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "AddMetadataToConditionalTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "proposalNumber", - type: "u64", - }, - { - name: "onFinalizeUri", - type: "string", - }, - { - name: "onRevertUri", - type: "string", - }, - ], - }, - }, - { - name: "InitializeConditionalVaultArgs", - type: { - kind: "struct", - fields: [ - { - name: "settlementAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "VaultStatus", - type: { - kind: "enum", - variants: [ - { - name: "Active", - }, - { - name: "Finalized", - }, - { - name: "Reverted", - }, - ], - }, - }, - ], - errors: [ - { - code: 6000, - name: "InsufficientUnderlyingTokens", - msg: "Insufficient underlying token balance to mint this amount of conditional tokens", - }, - { - code: 6001, - name: "InvalidVaultUnderlyingTokenAccount", - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", - }, - { - code: 6002, - name: "InvalidConditionalTokenMint", - msg: "This conditional token mint is not this vault's conditional token mint", - }, - { - code: 6003, - name: "CantRedeemConditionalTokens", - msg: "Vault needs to be settled as finalized before users can redeem conditional tokens for underlying tokens", - }, - { - code: 6004, - name: "VaultAlreadySettled", - msg: "Once a vault has been settled, its status as either finalized or reverted cannot be changed", - }, - ], -}; diff --git a/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts b/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts deleted file mode 100644 index aae14616a..000000000 --- a/sdk2/src/conditional_vault/v0.4/types/conditional_vault.ts +++ /dev/null @@ -1,1835 +0,0 @@ -export type ConditionalVault = { - version: "0.4.0"; - name: "conditional_vault"; - instructions: [ - { - name: "initializeQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeQuestionArgs"; - }; - }, - ]; - }, - { - name: "resolveQuestion"; - accounts: [ - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "oracle"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ResolveQuestionArgs"; - }; - }, - ]; - }, - { - name: "initializeConditionalVault"; - accounts: [ - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "underlyingTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "splitTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "mergeTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "redeemTokens"; - accounts: [ - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - }, - { - name: "userUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "addMetadataToConditionalTokens"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "vault"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalTokenMint"; - isMut: false; - isSigner: false; - }, - { - name: "conditionalTokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMetadataToConditionalTokensArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "conditionalVault"; - type: { - kind: "struct"; - fields: [ - { - name: "question"; - type: "publicKey"; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - }, - { - name: "underlyingTokenAccount"; - type: "publicKey"; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "decimals"; - type: "u8"; - }, - { - name: "seqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "question"; - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - { - name: "payoutDenominator"; - type: "u32"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "AddMetadataToConditionalTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "name"; - type: "string"; - }, - { - name: "symbol"; - type: "string"; - }, - { - name: "uri"; - type: "string"; - }, - ]; - }; - }, - { - name: "InitializeQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - }, - { - name: "oracle"; - type: "publicKey"; - }, - { - name: "numOutcomes"; - type: "u8"; - }, - ]; - }; - }, - { - name: "ResolveQuestionArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - }, - ]; - }; - }, - ]; - events: [ - { - name: "AddMetadataToConditionalTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMetadata"; - type: "publicKey"; - index: false; - }, - { - name: "name"; - type: "string"; - index: false; - }, - { - name: "symbol"; - type: "string"; - index: false; - }, - { - name: "uri"; - type: "string"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeConditionalVaultEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "underlyingTokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "vaultUnderlyingTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "conditionalTokenMints"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "questionId"; - type: { - array: ["u8", 32]; - }; - index: false; - }, - { - name: "oracle"; - type: "publicKey"; - index: false; - }, - { - name: "numOutcomes"; - type: "u8"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MergeTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "RedeemTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "ResolveQuestionEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "payoutNumerators"; - type: { - vec: "u32"; - }; - index: false; - }, - ]; - }, - { - name: "SplitTokensEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "vault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postUserUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postVaultUnderlyingBalance"; - type: "u64"; - index: false; - }, - { - name: "postUserConditionalTokenBalances"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "postConditionalTokenSupplies"; - type: { - vec: "u64"; - }; - index: false; - }, - { - name: "seqNum"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AssertFailed"; - msg: "An assertion failed"; - }, - { - code: 6001; - name: "InsufficientUnderlyingTokens"; - msg: "Insufficient underlying token balance to mint this amount of conditional tokens"; - }, - { - code: 6002; - name: "InsufficientConditionalTokens"; - msg: "Insufficient conditional token balance to merge this `amount`"; - }, - { - code: 6003; - name: "InvalidVaultUnderlyingTokenAccount"; - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`"; - }, - { - code: 6004; - name: "InvalidConditionalTokenMint"; - msg: "This conditional token mint is not this vault's conditional token mint"; - }, - { - code: 6005; - name: "CantRedeemConditionalTokens"; - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens"; - }, - { - code: 6006; - name: "InsufficientNumConditions"; - msg: "Questions need 2 or more conditions"; - }, - { - code: 6007; - name: "InvalidNumPayoutNumerators"; - msg: "Invalid number of payout numerators"; - }, - { - code: 6008; - name: "InvalidConditionals"; - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens"; - }, - { - code: 6009; - name: "ConditionalMintMismatch"; - msg: "Conditional mint not in vault"; - }, - { - code: 6010; - name: "BadConditionalMint"; - msg: "Unable to deserialize a conditional token mint"; - }, - { - code: 6011; - name: "BadConditionalTokenAccount"; - msg: "Unable to deserialize a conditional token account"; - }, - { - code: 6012; - name: "ConditionalTokenMintMismatch"; - msg: "User conditional token account mint does not match conditional mint"; - }, - { - code: 6013; - name: "PayoutZero"; - msg: "Payouts must sum to 1 or more"; - }, - { - code: 6014; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - { - code: 6015; - name: "ConditionalTokenMetadataAlreadySet"; - msg: "Conditional token metadata already set"; - }, - { - code: 6016; - name: "UnauthorizedConditionalTokenAccount"; - msg: "Conditional token account is not owned by the authority"; - }, - { - code: 6017; - name: "InvalidPayoutNumerators"; - msg: "Payout numerators are too large, causing an overflow"; - }, - { - code: 6018; - name: "TooManyOutcomes"; - msg: "Questions can only have up to 10 outcomes"; - }, - ]; -}; - -export const IDL: ConditionalVault = { - version: "0.4.0", - name: "conditional_vault", - instructions: [ - { - name: "initializeQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeQuestionArgs", - }, - }, - ], - }, - { - name: "resolveQuestion", - accounts: [ - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "oracle", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ResolveQuestionArgs", - }, - }, - ], - }, - { - name: "initializeConditionalVault", - accounts: [ - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "underlyingTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "splitTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "mergeTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "redeemTokens", - accounts: [ - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "vaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - }, - { - name: "userUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "addMetadataToConditionalTokens", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "vault", - isMut: true, - isSigner: false, - }, - { - name: "conditionalTokenMint", - isMut: false, - isSigner: false, - }, - { - name: "conditionalTokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMetadataToConditionalTokensArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "conditionalVault", - type: { - kind: "struct", - fields: [ - { - name: "question", - type: "publicKey", - }, - { - name: "underlyingTokenMint", - type: "publicKey", - }, - { - name: "underlyingTokenAccount", - type: "publicKey", - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "decimals", - type: "u8", - }, - { - name: "seqNum", - type: "u64", - }, - ], - }, - }, - { - name: "question", - docs: [ - "Questions represent statements about future events.", - "", - "These statements include:", - '- "Will this proposal pass?"', - '- "Who, if anyone, will be hired?"', - '- "How effective will the grant committee deem this grant?"', - "", - 'Questions have 2 or more possible outcomes. For a question like "will this', - 'proposal pass," the outcomes are "yes" and "no." For a question like "who', - 'will be hired," the outcomes could be "Alice," "Bob," and "neither."', - "", - 'Outcomes resolve to a number between 0 and 1. Binary questions like "will', - 'this proposal pass" have outcomes that resolve to exactly 0 or 1. You can', - 'also have questions with scalar outcomes. For example, the question "how', - 'effective will the grant committee deem this grant" could have two outcomes:', - '"ineffective" and "effective." If the grant committee deems the grant 70%', - 'effective, the "effective" outcome would resolve to 0.7 and the "ineffective"', - "outcome would resolve to 0.3.", - "", - "Once resolved, the sum of all outcome resolutions is exactly 1.", - ], - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - { - name: "payoutDenominator", - type: "u32", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "AddMetadataToConditionalTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "name", - type: "string", - }, - { - name: "symbol", - type: "string", - }, - { - name: "uri", - type: "string", - }, - ], - }, - }, - { - name: "InitializeQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "questionId", - type: { - array: ["u8", 32], - }, - }, - { - name: "oracle", - type: "publicKey", - }, - { - name: "numOutcomes", - type: "u8", - }, - ], - }, - }, - { - name: "ResolveQuestionArgs", - type: { - kind: "struct", - fields: [ - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - }, - ], - }, - }, - ], - events: [ - { - name: "AddMetadataToConditionalTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMint", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMetadata", - type: "publicKey", - index: false, - }, - { - name: "name", - type: "string", - index: false, - }, - { - name: "symbol", - type: "string", - index: false, - }, - { - name: "uri", - type: "string", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeConditionalVaultEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "underlyingTokenMint", - type: "publicKey", - index: false, - }, - { - name: "vaultUnderlyingTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "conditionalTokenMints", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "questionId", - type: { - array: ["u8", 32], - }, - index: false, - }, - { - name: "oracle", - type: "publicKey", - index: false, - }, - { - name: "numOutcomes", - type: "u8", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MergeTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "RedeemTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "ResolveQuestionEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "payoutNumerators", - type: { - vec: "u32", - }, - index: false, - }, - ], - }, - { - name: "SplitTokensEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "vault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postUserUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postVaultUnderlyingBalance", - type: "u64", - index: false, - }, - { - name: "postUserConditionalTokenBalances", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "postConditionalTokenSupplies", - type: { - vec: "u64", - }, - index: false, - }, - { - name: "seqNum", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AssertFailed", - msg: "An assertion failed", - }, - { - code: 6001, - name: "InsufficientUnderlyingTokens", - msg: "Insufficient underlying token balance to mint this amount of conditional tokens", - }, - { - code: 6002, - name: "InsufficientConditionalTokens", - msg: "Insufficient conditional token balance to merge this `amount`", - }, - { - code: 6003, - name: "InvalidVaultUnderlyingTokenAccount", - msg: "This `vault_underlying_token_account` is not this vault's `underlying_token_account`", - }, - { - code: 6004, - name: "InvalidConditionalTokenMint", - msg: "This conditional token mint is not this vault's conditional token mint", - }, - { - code: 6005, - name: "CantRedeemConditionalTokens", - msg: "Question needs to be resolved before users can redeem conditional tokens for underlying tokens", - }, - { - code: 6006, - name: "InsufficientNumConditions", - msg: "Questions need 2 or more conditions", - }, - { - code: 6007, - name: "InvalidNumPayoutNumerators", - msg: "Invalid number of payout numerators", - }, - { - code: 6008, - name: "InvalidConditionals", - msg: "Client needs to pass in the list of conditional mints for a vault followed by the user's token accounts for those tokens", - }, - { - code: 6009, - name: "ConditionalMintMismatch", - msg: "Conditional mint not in vault", - }, - { - code: 6010, - name: "BadConditionalMint", - msg: "Unable to deserialize a conditional token mint", - }, - { - code: 6011, - name: "BadConditionalTokenAccount", - msg: "Unable to deserialize a conditional token account", - }, - { - code: 6012, - name: "ConditionalTokenMintMismatch", - msg: "User conditional token account mint does not match conditional mint", - }, - { - code: 6013, - name: "PayoutZero", - msg: "Payouts must sum to 1 or more", - }, - { - code: 6014, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - { - code: 6015, - name: "ConditionalTokenMetadataAlreadySet", - msg: "Conditional token metadata already set", - }, - { - code: 6016, - name: "UnauthorizedConditionalTokenAccount", - msg: "Conditional token account is not owned by the authority", - }, - { - code: 6017, - name: "InvalidPayoutNumerators", - msg: "Payout numerators are too large, causing an overflow", - }, - { - code: 6018, - name: "TooManyOutcomes", - msg: "Questions can only have up to 10 outcomes", - }, - ], -}; diff --git a/sdk2/src/futarchy/v0.6/types/futarchy.ts b/sdk2/src/futarchy/v0.6/types/futarchy.ts deleted file mode 100644 index a54c805af..000000000 --- a/sdk2/src/futarchy/v0.6/types/futarchy.ts +++ /dev/null @@ -1,7489 +0,0 @@ -export type Futarchy = { - version: "0.6.1"; - name: "futarchy"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "stakeToProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "StakeToProposalParams"; - }; - }, - ]; - }, - { - name: "unstakeFromProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "staker"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "UnstakeFromProposalParams"; - }; - }, - ]; - }, - { - name: "launchProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - { - name: "resizeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "spotSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "SpotSwapParams"; - }; - }, - ]; - }, - { - name: "conditionalSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "proposal"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "trader"; - isMut: false; - isSigner: true; - }, - { - name: "userInputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userOutputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalVaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ConditionalSwapParams"; - }; - }, - ]; - }, - { - name: "provideLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProvider"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProvideLiquidityParams"; - }; - }, - ]; - }, - { - name: "withdrawLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "positionAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "WithdrawLiquidityParams"; - }; - }, - ]; - }, - { - name: "collectFees"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "baseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeSpendingLimitChange"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultTransaction"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "sponsorProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "teamAddress"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "collectMeteoraDammFees"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigPermissionlessAccount"; - isMut: false; - isSigner: true; - }, - { - name: "meteoraClaimPositionFeesAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "pool"; - isMut: false; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAAccount"; - isMut: true; - isSigner: false; - docs: ["Token account of base tokens recipient"]; - }, - { - name: "tokenBAccount"; - isMut: true; - isSigner: false; - docs: ["Token account of quote tokens recipient"]; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenAMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBMint"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: false; - isSigner: false; - }, - { - name: "owner"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenBProgram"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "initiateVaultSpendOptimisticProposal"; - accounts: [ - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsSpendingLimit"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "squadsVaultTransaction"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoQuoteVaultAccount"; - isMut: false; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "recipientQuoteAccount"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitiateVaultSpendOptimisticProposalParams"; - }; - }, - ]; - }, - { - name: "finalizeOptimisticProposal"; - accounts: [ - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "adminApproveMultisigProposal"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AdminApproveMultisigProposalArgs"; - }; - }, - ]; - }, - { - name: "adminExecuteMultisigProposal"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVaultTransaction"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "adminCancelProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "adminRemoveProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "ammPosition"; - type: { - kind: "struct"; - fields: [ - { - name: "dao"; - type: "publicKey"; - }, - { - name: "positionAuthority"; - type: "publicKey"; - }, - { - name: "liquidity"; - type: "u128"; - }, - ]; - }; - }, - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "amm"; - docs: ["Embedded FutarchyAmm - 1:1 relationship"]; - type: { - defined: "FutarchyAmm"; - }; - }, - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ]; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ]; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ]; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - { - name: "optimisticProposal"; - type: { - option: { - defined: "OptimisticProposal"; - }; - }; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: "bool"; - }, - ]; - }; - }, - { - name: "oldDao"; - type: { - kind: "struct"; - fields: [ - { - name: "amm"; - docs: ["Embedded FutarchyAmm - 1:1 relationship"]; - type: { - defined: "FutarchyAmm"; - }; - }, - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ]; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ]; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ]; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "timestampEnqueued"; - type: "i64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSeconds"; - type: "u32"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - { - name: "passBaseMint"; - type: "publicKey"; - }, - { - name: "passQuoteMint"; - type: "publicKey"; - }, - { - name: "failBaseMint"; - type: "publicKey"; - }, - { - name: "failQuoteMint"; - type: "publicKey"; - }, - { - name: "isTeamSponsored"; - type: "bool"; - }, - ]; - }; - }, - { - name: "stakeAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "proposal"; - type: "publicKey"; - }, - { - name: "staker"; - type: "publicKey"; - }, - { - name: "amount"; - type: "u64"; - }, - { - name: "bump"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "daoSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AdminApproveMultisigProposalArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "transactionIndex"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ConditionalSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "market"; - type: { - defined: "Market"; - }; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitiateVaultSpendOptimisticProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ProvideLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLiquidity"; - docs: ["The minimum liquidity you will be assigned"]; - type: "u128"; - }, - { - name: "positionAuthority"; - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "SpotSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "StakeToProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UnstakeFromProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "secondsPerProposal"; - type: { - option: "u32"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "twapStartDelaySeconds"; - type: { - option: "u32"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "baseToStake"; - type: { - option: "u64"; - }; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: { - option: "i16"; - }; - }, - { - name: "teamAddress"; - type: { - option: "publicKey"; - }; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: { - option: "bool"; - }; - }, - ]; - }; - }, - { - name: "WithdrawLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "liquidityToWithdraw"; - docs: ["How much liquidity to withdraw"]; - type: "u128"; - }, - { - name: "minBaseAmount"; - docs: ["Minimum base tokens to receive"]; - type: "u64"; - }, - { - name: "minQuoteAmount"; - docs: ["Minimum quote tokens to receive"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "OptimisticProposal"; - type: { - kind: "struct"; - fields: [ - { - name: "squadsProposal"; - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ]; - type: "publicKey"; - }, - { - name: "enqueuedTimestamp"; - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ]; - type: "i64"; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "FutarchyAmm"; - type: { - kind: "struct"; - fields: [ - { - name: "state"; - type: { - defined: "PoolState"; - }; - }, - { - name: "totalLiquidity"; - type: "u128"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "aggregator"; - docs: [ - "Running sum of seconds_since_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million seconds worth of observations, which turns out to", - "be ~213 days.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store ~57 years worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "lastUpdatedTimestamp"; - type: "i64"; - }, - { - name: "createdAtTimestamp"; - type: "i64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySeconds"; - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ]; - type: "u32"; - }, - ]; - }; - }, - { - name: "Pool"; - type: { - kind: "struct"; - fields: [ - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "quoteReserves"; - type: "u64"; - }, - { - name: "baseReserves"; - type: "u64"; - }, - { - name: "quoteProtocolFeeBalance"; - type: "u64"; - }, - { - name: "baseProtocolFeeBalance"; - type: "u64"; - }, - ]; - }; - }, - { - name: "PoolState"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - { - name: "Futarchy"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - { - name: "pass"; - type: { - defined: "Pool"; - }; - }, - { - name: "fail"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - ]; - }; - }, - { - name: "Market"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - }, - { - name: "Pass"; - }, - { - name: "Fail"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - { - name: "Token"; - type: { - kind: "enum"; - variants: [ - { - name: "Base"; - }, - { - name: "Quote"; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Draft"; - fields: [ - { - name: "amountStaked"; - type: "u64"; - }, - ]; - }, - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - { - name: "Removed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "CollectFeesEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - index: false; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "baseFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - { - name: "teamSponsoredPassThresholdBps"; - type: "i16"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - { - name: "isOptimisticGovernanceEnabled"; - type: "bool"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSeconds"; - type: "u32"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "StakeToProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "UnstakeFromProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "timestampEnqueued"; - type: "i64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - { - name: "isTeamSponsored"; - type: "bool"; - index: false; - }, - ]; - }, - { - name: "SpotSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ConditionalSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "trader"; - type: "publicKey"; - index: false; - }, - { - name: "market"; - type: { - defined: "Market"; - }; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ProvideLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "positionAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "liquidityMinted"; - type: "u128"; - index: false; - }, - { - name: "minLiquidity"; - type: "u128"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "WithdrawLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityWithdrawn"; - type: "u128"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "SponsorProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "teamAddress"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "RemoveProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "admin"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "AdminCancelProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "admin"; - type: "publicKey"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "CollectMeteoraDammFeesEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "pool"; - type: "publicKey"; - index: false; - }, - { - name: "baseTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "baseFeesCollected"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "AdminFixPositionAuthorityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "admin"; - type: "publicKey"; - index: false; - }, - { - name: "ammPosition"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "InitiateVaultSpendOptimisticProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "daoQuoteVaultAccount"; - type: "publicKey"; - index: false; - }, - { - name: "recipientQuoteAccount"; - type: "publicKey"; - index: false; - }, - { - name: "enqueuedTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "FinalizeOptimisticProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLiquidity"; - msg: "More liquidity needs to be in the AMM to launch this proposal"; - }, - { - code: 6011; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay"; - }, - { - code: 6012; - name: "PassThresholdTooHigh"; - msg: "Pass threshold must be less than 10%"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Active status"; - }, - { - code: 6015; - name: "CastingOverflow"; - msg: "Casting overflow. If you're seeing this, please report this"; - }, - { - code: 6016; - name: "InsufficientBalance"; - msg: "Insufficient balance"; - }, - { - code: 6017; - name: "ZeroLiquidityRemove"; - msg: "Cannot remove zero liquidity"; - }, - { - code: 6018; - name: "SwapSlippageExceeded"; - msg: "Swap slippage exceeded"; - }, - { - code: 6019; - name: "AssertFailed"; - msg: "Assert failed"; - }, - { - code: 6020; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - { - code: 6021; - name: "ProposalNotInDraftState"; - msg: "Proposal is not in draft state"; - }, - { - code: 6022; - name: "InsufficientTokenBalance"; - msg: "Insufficient token balance"; - }, - { - code: 6023; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6024; - name: "InsufficientStakeToLaunch"; - msg: "Insufficient stake to launch proposal"; - }, - { - code: 6025; - name: "StakerNotFound"; - msg: "Staker not found in proposal"; - }, - { - code: 6026; - name: "PoolNotInSpotState"; - msg: "Pool must be in spot state"; - }, - { - code: 6027; - name: "InvalidDaoCreateLiquidity"; - msg: "If you're providing liquidity, you must provide both base and quote token accounts"; - }, - { - code: 6028; - name: "InvalidStakeAccount"; - msg: "Invalid stake account"; - }, - { - code: 6029; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6030; - name: "ProposalNotActive"; - msg: "Proposal needs to be active to perform a conditional swap"; - }, - { - code: 6031; - name: "InvalidTransaction"; - msg: "This Squads transaction should only contain calls to update spending limits"; - }, - { - code: 6032; - name: "ProposalAlreadySponsored"; - msg: "Proposal has already been sponsored"; - }, - { - code: 6033; - name: "InvalidTeamSponsoredPassThreshold"; - msg: "Team sponsored pass threshold must be between -10% and 10%"; - }, - { - code: 6034; - name: "InvalidTargetK"; - msg: "Target K must be greater than the current K"; - }, - { - code: 6035; - name: "InvalidTransactionMessage"; - msg: "Failed to compile transaction message for Squads vault transaction"; - }, - { - code: 6036; - name: "InvalidMint"; - msg: "Base mint and quote mint must be different"; - }, - { - code: 6037; - name: "ProposalNotReadyToUnstake"; - msg: "Proposal is not ready to be unstaked"; - }, - { - code: 6038; - name: "OptimisticGovernanceDisabled"; - msg: "Optimistic governance is disabled"; - }, - { - code: 6039; - name: "ActiveOptimisticProposalAlreadyEnqueued"; - msg: "An active optimistic proposal is already enqueued"; - }, - { - code: 6040; - name: "OptimisticProposalAlreadyPassed"; - msg: "Optimistic proposal has already passed"; - }, - { - code: 6041; - name: "InvalidSpendingLimitMint"; - msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint"; - }, - { - code: 6042; - name: "NoActiveOptimisticProposal"; - msg: "No active optimistic proposal"; - }, - ]; -}; - -export const IDL: Futarchy = { - version: "0.6.1", - name: "futarchy", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "stakeToProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "StakeToProposalParams", - }, - }, - ], - }, - { - name: "unstakeFromProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "staker", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "UnstakeFromProposalParams", - }, - }, - ], - }, - { - name: "launchProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - { - name: "resizeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "spotSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "SpotSwapParams", - }, - }, - ], - }, - { - name: "conditionalSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "proposal", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "trader", - isMut: false, - isSigner: true, - }, - { - name: "userInputAccount", - isMut: true, - isSigner: false, - }, - { - name: "userOutputAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalVaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ConditionalSwapParams", - }, - }, - ], - }, - { - name: "provideLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProvider", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProvideLiquidityParams", - }, - }, - ], - }, - { - name: "withdrawLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "positionAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "WithdrawLiquidityParams", - }, - }, - ], - }, - { - name: "collectFees", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "baseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeSpendingLimitChange", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultTransaction", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "sponsorProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "teamAddress", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "collectMeteoraDammFees", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigPermissionlessAccount", - isMut: false, - isSigner: true, - }, - { - name: "meteoraClaimPositionFeesAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "pool", - isMut: false, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "tokenAAccount", - isMut: true, - isSigner: false, - docs: ["Token account of base tokens recipient"], - }, - { - name: "tokenBAccount", - isMut: true, - isSigner: false, - docs: ["Token account of quote tokens recipient"], - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenAMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenBMint", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: false, - isSigner: false, - }, - { - name: "owner", - isMut: false, - isSigner: false, - }, - { - name: "tokenAProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenBProgram", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "initiateVaultSpendOptimisticProposal", - accounts: [ - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsSpendingLimit", - isMut: false, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "squadsVaultTransaction", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoQuoteVaultAccount", - isMut: false, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "recipientQuoteAccount", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitiateVaultSpendOptimisticProposalParams", - }, - }, - ], - }, - { - name: "finalizeOptimisticProposal", - accounts: [ - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "adminApproveMultisigProposal", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AdminApproveMultisigProposalArgs", - }, - }, - ], - }, - { - name: "adminExecuteMultisigProposal", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVaultTransaction", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "adminCancelProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "adminRemoveProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "ammPosition", - type: { - kind: "struct", - fields: [ - { - name: "dao", - type: "publicKey", - }, - { - name: "positionAuthority", - type: "publicKey", - }, - { - name: "liquidity", - type: "u128", - }, - ], - }, - }, - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "amm", - docs: ["Embedded FutarchyAmm - 1:1 relationship"], - type: { - defined: "FutarchyAmm", - }, - }, - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ], - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ], - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ], - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - { - name: "optimisticProposal", - type: { - option: { - defined: "OptimisticProposal", - }, - }, - }, - { - name: "isOptimisticGovernanceEnabled", - type: "bool", - }, - ], - }, - }, - { - name: "oldDao", - type: { - kind: "struct", - fields: [ - { - name: "amm", - docs: ["Embedded FutarchyAmm - 1:1 relationship"], - type: { - defined: "FutarchyAmm", - }, - }, - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ], - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ], - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - docs: [ - "The percentage, in basis points, the pass price needs to be above the", - "fail price in order for the proposal to pass for team-sponsored proposals.", - "", - "Can be negative to allow for team-sponsored proposals to pass by default.", - ], - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "timestampEnqueued", - type: "i64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSeconds", - type: "u32", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - { - name: "passBaseMint", - type: "publicKey", - }, - { - name: "passQuoteMint", - type: "publicKey", - }, - { - name: "failBaseMint", - type: "publicKey", - }, - { - name: "failQuoteMint", - type: "publicKey", - }, - { - name: "isTeamSponsored", - type: "bool", - }, - ], - }, - }, - { - name: "stakeAccount", - type: { - kind: "struct", - fields: [ - { - name: "proposal", - type: "publicKey", - }, - { - name: "staker", - type: "publicKey", - }, - { - name: "amount", - type: "u64", - }, - { - name: "bump", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "daoSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AdminApproveMultisigProposalArgs", - type: { - kind: "struct", - fields: [ - { - name: "transactionIndex", - type: "u64", - }, - ], - }, - }, - { - name: "ConditionalSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "market", - type: { - defined: "Market", - }, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitiateVaultSpendOptimisticProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "ProvideLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLiquidity", - docs: ["The minimum liquidity you will be assigned"], - type: "u128", - }, - { - name: "positionAuthority", - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ], - type: "publicKey", - }, - ], - }, - }, - { - name: "SpotSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "inputAmount", - type: "u64", - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "StakeToProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UnstakeFromProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "secondsPerProposal", - type: { - option: "u32", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "twapStartDelaySeconds", - type: { - option: "u32", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "baseToStake", - type: { - option: "u64", - }, - }, - { - name: "teamSponsoredPassThresholdBps", - type: { - option: "i16", - }, - }, - { - name: "teamAddress", - type: { - option: "publicKey", - }, - }, - { - name: "isOptimisticGovernanceEnabled", - type: { - option: "bool", - }, - }, - ], - }, - }, - { - name: "WithdrawLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "liquidityToWithdraw", - docs: ["How much liquidity to withdraw"], - type: "u128", - }, - { - name: "minBaseAmount", - docs: ["Minimum base tokens to receive"], - type: "u64", - }, - { - name: "minQuoteAmount", - docs: ["Minimum quote tokens to receive"], - type: "u64", - }, - ], - }, - }, - { - name: "OptimisticProposal", - type: { - kind: "struct", - fields: [ - { - name: "squadsProposal", - docs: [ - "The squads proposal currently enqueued for execution if not challenged by a new proposal.", - ], - type: "publicKey", - }, - { - name: "enqueuedTimestamp", - docs: [ - "The timestamp when the active optimistic squads proposal was enqueued.", - ], - type: "i64", - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "FutarchyAmm", - type: { - kind: "struct", - fields: [ - { - name: "state", - type: { - defined: "PoolState", - }, - }, - { - name: "totalLiquidity", - type: "u128", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "ammBaseVault", - type: "publicKey", - }, - { - name: "ammQuoteVault", - type: "publicKey", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "aggregator", - docs: [ - "Running sum of seconds_since_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million seconds worth of observations, which turns out to", - "be ~213 days.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store ~57 years worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "lastUpdatedTimestamp", - type: "i64", - }, - { - name: "createdAtTimestamp", - type: "i64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySeconds", - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ], - type: "u32", - }, - ], - }, - }, - { - name: "Pool", - type: { - kind: "struct", - fields: [ - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "quoteReserves", - type: "u64", - }, - { - name: "baseReserves", - type: "u64", - }, - { - name: "quoteProtocolFeeBalance", - type: "u64", - }, - { - name: "baseProtocolFeeBalance", - type: "u64", - }, - ], - }, - }, - { - name: "PoolState", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - ], - }, - { - name: "Futarchy", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - { - name: "pass", - type: { - defined: "Pool", - }, - }, - { - name: "fail", - type: { - defined: "Pool", - }, - }, - ], - }, - ], - }, - }, - { - name: "Market", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - }, - { - name: "Pass", - }, - { - name: "Fail", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - { - name: "Token", - type: { - kind: "enum", - variants: [ - { - name: "Base", - }, - { - name: "Quote", - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Draft", - fields: [ - { - name: "amountStaked", - type: "u64", - }, - ], - }, - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - { - name: "Removed", - }, - ], - }, - }, - ], - events: [ - { - name: "CollectFeesEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "ammBaseVault", - type: "publicKey", - index: false, - }, - { - name: "ammQuoteVault", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteFeesCollected", - type: "u64", - index: false, - }, - { - name: "baseFeesCollected", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "twapStartDelaySeconds", - type: "u32", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "twapStartDelaySeconds", - type: "u32", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - { - name: "teamSponsoredPassThresholdBps", - type: "i16", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - { - name: "isOptimisticGovernanceEnabled", - type: "bool", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSeconds", - type: "u32", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "StakeToProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "UnstakeFromProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "timestampEnqueued", - type: "i64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - { - name: "isTeamSponsored", - type: "bool", - index: false, - }, - ], - }, - { - name: "SpotSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ConditionalSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "trader", - type: "publicKey", - index: false, - }, - { - name: "market", - type: { - defined: "Market", - }, - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ProvideLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "positionAuthority", - type: "publicKey", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "liquidityMinted", - type: "u128", - index: false, - }, - { - name: "minLiquidity", - type: "u128", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "WithdrawLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "liquidityWithdrawn", - type: "u128", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "SponsorProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "teamAddress", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "RemoveProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "admin", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "AdminCancelProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "admin", - type: "publicKey", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "CollectMeteoraDammFeesEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "pool", - type: "publicKey", - index: false, - }, - { - name: "baseTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteFeesCollected", - type: "u64", - index: false, - }, - { - name: "baseFeesCollected", - type: "u64", - index: false, - }, - ], - }, - { - name: "AdminFixPositionAuthorityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "admin", - type: "publicKey", - index: false, - }, - { - name: "ammPosition", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "InitiateVaultSpendOptimisticProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "daoQuoteVaultAccount", - type: "publicKey", - index: false, - }, - { - name: "recipientQuoteAccount", - type: "publicKey", - index: false, - }, - { - name: "enqueuedTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "FinalizeOptimisticProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLiquidity", - msg: "More liquidity needs to be in the AMM to launch this proposal", - }, - { - code: 6011, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay", - }, - { - code: 6012, - name: "PassThresholdTooHigh", - msg: "Pass threshold must be less than 10%", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Active status", - }, - { - code: 6015, - name: "CastingOverflow", - msg: "Casting overflow. If you're seeing this, please report this", - }, - { - code: 6016, - name: "InsufficientBalance", - msg: "Insufficient balance", - }, - { - code: 6017, - name: "ZeroLiquidityRemove", - msg: "Cannot remove zero liquidity", - }, - { - code: 6018, - name: "SwapSlippageExceeded", - msg: "Swap slippage exceeded", - }, - { - code: 6019, - name: "AssertFailed", - msg: "Assert failed", - }, - { - code: 6020, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - { - code: 6021, - name: "ProposalNotInDraftState", - msg: "Proposal is not in draft state", - }, - { - code: 6022, - name: "InsufficientTokenBalance", - msg: "Insufficient token balance", - }, - { - code: 6023, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6024, - name: "InsufficientStakeToLaunch", - msg: "Insufficient stake to launch proposal", - }, - { - code: 6025, - name: "StakerNotFound", - msg: "Staker not found in proposal", - }, - { - code: 6026, - name: "PoolNotInSpotState", - msg: "Pool must be in spot state", - }, - { - code: 6027, - name: "InvalidDaoCreateLiquidity", - msg: "If you're providing liquidity, you must provide both base and quote token accounts", - }, - { - code: 6028, - name: "InvalidStakeAccount", - msg: "Invalid stake account", - }, - { - code: 6029, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6030, - name: "ProposalNotActive", - msg: "Proposal needs to be active to perform a conditional swap", - }, - { - code: 6031, - name: "InvalidTransaction", - msg: "This Squads transaction should only contain calls to update spending limits", - }, - { - code: 6032, - name: "ProposalAlreadySponsored", - msg: "Proposal has already been sponsored", - }, - { - code: 6033, - name: "InvalidTeamSponsoredPassThreshold", - msg: "Team sponsored pass threshold must be between -10% and 10%", - }, - { - code: 6034, - name: "InvalidTargetK", - msg: "Target K must be greater than the current K", - }, - { - code: 6035, - name: "InvalidTransactionMessage", - msg: "Failed to compile transaction message for Squads vault transaction", - }, - { - code: 6036, - name: "InvalidMint", - msg: "Base mint and quote mint must be different", - }, - { - code: 6037, - name: "ProposalNotReadyToUnstake", - msg: "Proposal is not ready to be unstaked", - }, - { - code: 6038, - name: "OptimisticGovernanceDisabled", - msg: "Optimistic governance is disabled", - }, - { - code: 6039, - name: "ActiveOptimisticProposalAlreadyEnqueued", - msg: "An active optimistic proposal is already enqueued", - }, - { - code: 6040, - name: "OptimisticProposalAlreadyPassed", - msg: "Optimistic proposal has already passed", - }, - { - code: 6041, - name: "InvalidSpendingLimitMint", - msg: "Invalid spending limit mint. Must be the same as the DAO's quote mint", - }, - { - code: 6042, - name: "NoActiveOptimisticProposal", - msg: "No active optimistic proposal", - }, - ], -}; diff --git a/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts b/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts deleted file mode 100644 index 210888785..000000000 --- a/sdk2/src/futarchy/v0.6/types/v0.6.0-futarchy.ts +++ /dev/null @@ -1,5133 +0,0 @@ -export type Futarchy = { - version: "0.6.0"; - name: "futarchy"; - instructions: [ - { - name: "initializeDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoCreator"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializeDaoParams"; - }; - }, - ]; - }, - { - name: "initializeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "stakeToProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "StakeToProposalParams"; - }; - }, - ]; - }, - { - name: "unstakeFromProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "stakerBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "proposalBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "stakeAccount"; - isMut: true; - isSigner: false; - }, - { - name: "staker"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "UnstakeFromProposalParams"; - }; - }, - ]; - }, - { - name: "launchProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: false; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: false; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "finalizeProposal"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "question"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "vaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateDao"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "daoParams"; - type: { - defined: "UpdateDaoParams"; - }; - }, - ]; - }, - { - name: "spotSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "userBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "user"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "SpotSwapParams"; - }; - }, - ]; - }, - { - name: "conditionalSwap"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "proposal"; - isMut: false; - isSigner: false; - }, - { - name: "ammPassBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPassQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammFailQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "trader"; - isMut: false; - isSigner: true; - }, - { - name: "userInputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "userOutputAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteVaultUnderlyingTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "passBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "failBaseMint"; - isMut: true; - isSigner: false; - }, - { - name: "passQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "failQuoteMint"; - isMut: true; - isSigner: false; - }, - { - name: "conditionalVaultProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "question"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ConditionalSwapParams"; - }; - }, - ]; - }, - { - name: "provideLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProvider"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProvideLiquidityParams"; - }; - }, - ]; - }, - { - name: "withdrawLiquidity"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "positionAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidityProviderBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidityProviderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammPosition"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "WithdrawLiquidityParams"; - }; - }, - ]; - }, - { - name: "collectFees"; - accounts: [ - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "baseTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "ammQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "executeSpendingLimitChange"; - accounts: [ - { - name: "proposal"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsProposal"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigProgram"; - isMut: false; - isSigner: false; - }, - { - name: "vaultTransaction"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "ammPosition"; - type: { - kind: "struct"; - fields: [ - { - name: "dao"; - type: "publicKey"; - }, - { - name: "positionAuthority"; - type: "publicKey"; - }, - { - name: "liquidity"; - type: "u128"; - }, - ]; - }; - }, - { - name: "dao"; - type: { - kind: "struct"; - fields: [ - { - name: "amm"; - docs: ["Embedded FutarchyAmm - 1:1 relationship"]; - type: { - defined: "FutarchyAmm"; - }; - }, - { - name: "nonce"; - docs: ["`nonce` + `dao_creator` are PDA seeds"]; - type: "u64"; - }, - { - name: "daoCreator"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "proposalCount"; - type: "u32"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "twapInitialObservation"; - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ]; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ]; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ]; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ]; - type: "u64"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "proposal"; - type: { - kind: "struct"; - fields: [ - { - name: "number"; - type: "u32"; - }, - { - name: "proposer"; - type: "publicKey"; - }, - { - name: "timestampEnqueued"; - type: "i64"; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - }, - { - name: "baseVault"; - type: "publicKey"; - }, - { - name: "quoteVault"; - type: "publicKey"; - }, - { - name: "dao"; - type: "publicKey"; - }, - { - name: "pdaBump"; - type: "u8"; - }, - { - name: "question"; - type: "publicKey"; - }, - { - name: "durationInSeconds"; - type: "u32"; - }, - { - name: "squadsProposal"; - type: "publicKey"; - }, - { - name: "passBaseMint"; - type: "publicKey"; - }, - { - name: "passQuoteMint"; - type: "publicKey"; - }, - { - name: "failBaseMint"; - type: "publicKey"; - }, - { - name: "failQuoteMint"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "stakeAccount"; - type: { - kind: "struct"; - fields: [ - { - name: "proposal"; - type: "publicKey"; - }, - { - name: "staker"; - type: "publicKey"; - }, - { - name: "amount"; - type: "u64"; - }, - { - name: "bump"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "daoSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ConditionalSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "market"; - type: { - defined: "Market"; - }; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "twapInitialObservation"; - type: "u128"; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - }, - { - name: "twapStartDelaySeconds"; - type: "u32"; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - }, - { - name: "baseToStake"; - type: "u64"; - }, - { - name: "passThresholdBps"; - type: "u16"; - }, - { - name: "secondsPerProposal"; - type: "u32"; - }, - { - name: "nonce"; - type: "u64"; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - }, - ]; - }; - }, - { - name: "ProvideLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "quoteAmount"; - docs: ["How much quote token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "maxBaseAmount"; - docs: ["The maximum base token you will deposit to the pool"]; - type: "u64"; - }, - { - name: "minLiquidity"; - docs: ["The minimum liquidity you will be assigned"]; - type: "u128"; - }, - { - name: "positionAuthority"; - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "SpotSwapParams"; - type: { - kind: "struct"; - fields: [ - { - name: "inputAmount"; - type: "u64"; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - }, - { - name: "minOutputAmount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "StakeToProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UnstakeFromProposalParams"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateDaoParams"; - type: { - kind: "struct"; - fields: [ - { - name: "passThresholdBps"; - type: { - option: "u16"; - }; - }, - { - name: "secondsPerProposal"; - type: { - option: "u32"; - }; - }, - { - name: "twapInitialObservation"; - type: { - option: "u128"; - }; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: { - option: "u128"; - }; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "minBaseFutarchicLiquidity"; - type: { - option: "u64"; - }; - }, - { - name: "baseToStake"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "WithdrawLiquidityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "liquidityToWithdraw"; - docs: ["How much liquidity to withdraw"]; - type: "u128"; - }, - { - name: "minBaseAmount"; - docs: ["Minimum base tokens to receive"]; - type: "u64"; - }, - { - name: "minQuoteAmount"; - docs: ["Minimum quote tokens to receive"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitialSpendingLimit"; - type: { - kind: "struct"; - fields: [ - { - name: "amountPerMonth"; - type: "u64"; - }, - { - name: "members"; - type: { - vec: "publicKey"; - }; - }, - ]; - }; - }, - { - name: "FutarchyAmm"; - type: { - kind: "struct"; - fields: [ - { - name: "state"; - type: { - defined: "PoolState"; - }; - }, - { - name: "totalLiquidity"; - type: "u128"; - }, - { - name: "baseMint"; - type: "publicKey"; - }, - { - name: "quoteMint"; - type: "publicKey"; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "TwapOracle"; - type: { - kind: "struct"; - fields: [ - { - name: "aggregator"; - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ]; - type: "u128"; - }, - { - name: "lastUpdatedTimestamp"; - type: "i64"; - }, - { - name: "createdAtTimestamp"; - type: "i64"; - }, - { - name: "lastPrice"; - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ]; - type: "u128"; - }, - { - name: "lastObservation"; - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ]; - type: "u128"; - }, - { - name: "maxObservationChangePerUpdate"; - docs: ["The most that an observation can change per update."]; - type: "u128"; - }, - { - name: "initialObservation"; - docs: ["What the initial `latest_observation` is set to."]; - type: "u128"; - }, - { - name: "startDelaySeconds"; - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ]; - type: "u32"; - }, - ]; - }; - }, - { - name: "Pool"; - type: { - kind: "struct"; - fields: [ - { - name: "oracle"; - type: { - defined: "TwapOracle"; - }; - }, - { - name: "quoteReserves"; - type: "u64"; - }, - { - name: "baseReserves"; - type: "u64"; - }, - { - name: "quoteProtocolFeeBalance"; - type: "u64"; - }, - { - name: "baseProtocolFeeBalance"; - type: "u64"; - }, - ]; - }; - }, - { - name: "PoolState"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - { - name: "Futarchy"; - fields: [ - { - name: "spot"; - type: { - defined: "Pool"; - }; - }, - { - name: "pass"; - type: { - defined: "Pool"; - }; - }, - { - name: "fail"; - type: { - defined: "Pool"; - }; - }, - ]; - }, - ]; - }; - }, - { - name: "Market"; - type: { - kind: "enum"; - variants: [ - { - name: "Spot"; - }, - { - name: "Pass"; - }, - { - name: "Fail"; - }, - ]; - }; - }, - { - name: "SwapType"; - type: { - kind: "enum"; - variants: [ - { - name: "Buy"; - }, - { - name: "Sell"; - }, - ]; - }; - }, - { - name: "Token"; - type: { - kind: "enum"; - variants: [ - { - name: "Base"; - }, - { - name: "Quote"; - }, - ]; - }; - }, - { - name: "ProposalState"; - type: { - kind: "enum"; - variants: [ - { - name: "Draft"; - fields: [ - { - name: "amountStaked"; - type: "u64"; - }, - ]; - }, - { - name: "Pending"; - }, - { - name: "Passed"; - }, - { - name: "Failed"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "CollectFeesEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "quoteTokenAccount"; - type: "publicKey"; - index: false; - }, - { - name: "ammBaseVault"; - type: "publicKey"; - index: false; - }, - { - name: "ammQuoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "baseFeesCollected"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "InitializeDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - { - name: "initialSpendingLimit"; - type: { - option: { - defined: "InitialSpendingLimit"; - }; - }; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UpdateDaoEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passThresholdBps"; - type: "u16"; - index: false; - }, - { - name: "secondsPerProposal"; - type: "u32"; - index: false; - }, - { - name: "twapInitialObservation"; - type: "u128"; - index: false; - }, - { - name: "twapMaxObservationChangePerUpdate"; - type: "u128"; - index: false; - }, - { - name: "minQuoteFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "minBaseFutarchicLiquidity"; - type: "u64"; - index: false; - }, - { - name: "baseToStake"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "InitializeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "question"; - type: "publicKey"; - index: false; - }, - { - name: "quoteVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseVault"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "number"; - type: "u32"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "durationInSeconds"; - type: "u32"; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisigVault"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "StakeToProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "UnstakeFromProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "staker"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "totalStaked"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "FinalizeProposalEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "passMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "failMarketTwap"; - type: "u128"; - index: false; - }, - { - name: "threshold"; - type: "u128"; - index: false; - }, - { - name: "state"; - type: { - defined: "ProposalState"; - }; - index: false; - }, - { - name: "squadsProposal"; - type: "publicKey"; - index: false; - }, - { - name: "squadsMultisig"; - type: "publicKey"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "SpotSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "user"; - type: "publicKey"; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ConditionalSwapEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "proposal"; - type: "publicKey"; - index: false; - }, - { - name: "trader"; - type: "publicKey"; - index: false; - }, - { - name: "market"; - type: { - defined: "Market"; - }; - index: false; - }, - { - name: "swapType"; - type: { - defined: "SwapType"; - }; - index: false; - }, - { - name: "inputAmount"; - type: "u64"; - index: false; - }, - { - name: "outputAmount"; - type: "u64"; - index: false; - }, - { - name: "minOutputAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "ProvideLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "positionAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "liquidityMinted"; - type: "u128"; - index: false; - }, - { - name: "minLiquidity"; - type: "u128"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - { - name: "WithdrawLiquidityEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "dao"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityProvider"; - type: "publicKey"; - index: false; - }, - { - name: "liquidityWithdrawn"; - type: "u128"; - index: false; - }, - { - name: "minBaseAmount"; - type: "u64"; - index: false; - }, - { - name: "minQuoteAmount"; - type: "u64"; - index: false; - }, - { - name: "baseAmount"; - type: "u64"; - index: false; - }, - { - name: "quoteAmount"; - type: "u64"; - index: false; - }, - { - name: "postAmmState"; - type: { - defined: "FutarchyAmm"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "AmmTooOld"; - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization"; - }, - { - code: 6001; - name: "InvalidInitialObservation"; - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config"; - }, - { - code: 6002; - name: "InvalidMaxObservationChange"; - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config"; - }, - { - code: 6003; - name: "InvalidStartDelaySlots"; - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config"; - }, - { - code: 6004; - name: "InvalidSettlementAuthority"; - msg: "One of the vaults has an invalid `settlement_authority`"; - }, - { - code: 6005; - name: "ProposalTooYoung"; - msg: "Proposal is too young to be executed or rejected"; - }, - { - code: 6006; - name: "MarketsTooYoung"; - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked"; - }, - { - code: 6007; - name: "ProposalAlreadyFinalized"; - msg: "This proposal has already been finalized"; - }, - { - code: 6008; - name: "InvalidVaultNonce"; - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number"; - }, - { - code: 6009; - name: "ProposalNotPassed"; - msg: "This proposal can't be executed because it isn't in the passed state"; - }, - { - code: 6010; - name: "InsufficientLiquidity"; - msg: "More liquidity needs to be in the AMM to launch this proposal"; - }, - { - code: 6011; - name: "ProposalDurationTooShort"; - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay"; - }, - { - code: 6012; - name: "PassThresholdTooHigh"; - msg: "Pass threshold must be less than 10%"; - }, - { - code: 6013; - name: "QuestionMustBeBinary"; - msg: "Question must have exactly 2 outcomes for binary futarchy"; - }, - { - code: 6014; - name: "InvalidSquadsProposalStatus"; - msg: "Squads proposal must be in Draft status"; - }, - { - code: 6015; - name: "CastingOverflow"; - msg: "Casting overflow. If you're seeing this, please report this"; - }, - { - code: 6016; - name: "InsufficientBalance"; - msg: "Insufficient balance"; - }, - { - code: 6017; - name: "ZeroLiquidityRemove"; - msg: "Cannot remove zero liquidity"; - }, - { - code: 6018; - name: "SwapSlippageExceeded"; - msg: "Swap slippage exceeded"; - }, - { - code: 6019; - name: "AssertFailed"; - msg: "Assert failed"; - }, - { - code: 6020; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - { - code: 6021; - name: "ProposalNotInDraftState"; - msg: "Proposal is not in draft state"; - }, - { - code: 6022; - name: "InsufficientTokenBalance"; - msg: "Insufficient token balance"; - }, - { - code: 6023; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6024; - name: "InsufficientStakeToLaunch"; - msg: "Insufficient stake to launch proposal"; - }, - { - code: 6025; - name: "StakerNotFound"; - msg: "Staker not found in proposal"; - }, - { - code: 6026; - name: "PoolNotInSpotState"; - msg: "Pool must be in spot state"; - }, - { - code: 6027; - name: "InvalidDaoCreateLiquidity"; - msg: "If you're providing liquidity, you must provide both base and quote token accounts"; - }, - { - code: 6028; - name: "InvalidStakeAccount"; - msg: "Invalid stake account"; - }, - { - code: 6029; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6030; - name: "ProposalNotActive"; - msg: "Proposal needs to be active to perform a conditional swap"; - }, - { - code: 6031; - name: "InvalidTransaction"; - msg: "This Squads transaction should only contain calls to update spending limits"; - }, - ]; -}; - -export const IDL: Futarchy = { - version: "0.6.0", - name: "futarchy", - instructions: [ - { - name: "initializeDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoCreator", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializeDaoParams", - }, - }, - ], - }, - { - name: "initializeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "stakeToProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "StakeToProposalParams", - }, - }, - ], - }, - { - name: "unstakeFromProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "stakerBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "proposalBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "stakeAccount", - isMut: true, - isSigner: false, - }, - { - name: "staker", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "UnstakeFromProposalParams", - }, - }, - ], - }, - { - name: "launchProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: false, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: false, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "finalizeProposal", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "question", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "vaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateDao", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "daoParams", - type: { - defined: "UpdateDaoParams", - }, - }, - ], - }, - { - name: "spotSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "userBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "userQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "user", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "SpotSwapParams", - }, - }, - ], - }, - { - name: "conditionalSwap", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "proposal", - isMut: false, - isSigner: false, - }, - { - name: "ammPassBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPassQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammFailQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "trader", - isMut: false, - isSigner: true, - }, - { - name: "userInputAccount", - isMut: true, - isSigner: false, - }, - { - name: "userOutputAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteVaultUnderlyingTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "passBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "failBaseMint", - isMut: true, - isSigner: false, - }, - { - name: "passQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "failQuoteMint", - isMut: true, - isSigner: false, - }, - { - name: "conditionalVaultProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "question", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ConditionalSwapParams", - }, - }, - ], - }, - { - name: "provideLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProvider", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProvideLiquidityParams", - }, - }, - ], - }, - { - name: "withdrawLiquidity", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "positionAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidityProviderBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidityProviderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "ammPosition", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "WithdrawLiquidityParams", - }, - }, - ], - }, - { - name: "collectFees", - accounts: [ - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "baseTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "ammQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "executeSpendingLimitChange", - accounts: [ - { - name: "proposal", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsProposal", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigProgram", - isMut: false, - isSigner: false, - }, - { - name: "vaultTransaction", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "ammPosition", - type: { - kind: "struct", - fields: [ - { - name: "dao", - type: "publicKey", - }, - { - name: "positionAuthority", - type: "publicKey", - }, - { - name: "liquidity", - type: "u128", - }, - ], - }, - }, - { - name: "dao", - type: { - kind: "struct", - fields: [ - { - name: "amm", - docs: ["Embedded FutarchyAmm - 1:1 relationship"], - type: { - defined: "FutarchyAmm", - }, - }, - { - name: "nonce", - docs: ["`nonce` + `dao_creator` are PDA seeds"], - type: "u64", - }, - { - name: "daoCreator", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "squadsMultisig", - type: "publicKey", - }, - { - name: "squadsMultisigVault", - type: "publicKey", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "proposalCount", - type: "u32", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "twapInitialObservation", - docs: [ - "For manipulation-resistance the TWAP is a time-weighted average observation,", - "where observation tries to approximate price but can only move by", - "`twap_max_observation_change_per_update` per update. Because it can only move", - "a little bit per update, you need to check that it has a good initial observation.", - "Otherwise, an attacker could create a very high initial observation in the pass", - "market and a very low one in the fail market to force the proposal to pass.", - "", - "We recommend setting an initial observation around the spot price of the token,", - "and max observation change per update around 2% the spot price of the token.", - "For example, if the spot price of META is $400, we'd recommend setting an initial", - "observation of 400 (converted into the AMM prices) and a max observation change per", - "update of 8 (also converted into the AMM prices). Observations can be updated once", - "a minute, so 2% allows the proposal market to reach double the spot price or 0", - "in 50 minutes.", - ], - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - docs: [ - "Forces TWAP calculation to start after `twap_start_delay_seconds` seconds", - ], - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - docs: [ - "As an anti-spam measure and to help liquidity, you need to lock up some liquidity", - "in both futarchic markets in order to create a proposal.", - "", - "For example, for META, we can use a `min_quote_futarchic_liquidity` of", - "5000 * 1_000_000 (5000 USDC) and a `min_base_futarchic_liquidity` of", - "10 * 1_000_000_000 (10 META).", - ], - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - docs: [ - "Minimum amount of base tokens that must be staked to launch a proposal", - ], - type: "u64", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "proposal", - type: { - kind: "struct", - fields: [ - { - name: "number", - type: "u32", - }, - { - name: "proposer", - type: "publicKey", - }, - { - name: "timestampEnqueued", - type: "i64", - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - }, - { - name: "baseVault", - type: "publicKey", - }, - { - name: "quoteVault", - type: "publicKey", - }, - { - name: "dao", - type: "publicKey", - }, - { - name: "pdaBump", - type: "u8", - }, - { - name: "question", - type: "publicKey", - }, - { - name: "durationInSeconds", - type: "u32", - }, - { - name: "squadsProposal", - type: "publicKey", - }, - { - name: "passBaseMint", - type: "publicKey", - }, - { - name: "passQuoteMint", - type: "publicKey", - }, - { - name: "failBaseMint", - type: "publicKey", - }, - { - name: "failQuoteMint", - type: "publicKey", - }, - ], - }, - }, - { - name: "stakeAccount", - type: { - kind: "struct", - fields: [ - { - name: "proposal", - type: "publicKey", - }, - { - name: "staker", - type: "publicKey", - }, - { - name: "amount", - type: "u64", - }, - { - name: "bump", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "daoSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ConditionalSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "market", - type: { - defined: "Market", - }, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "inputAmount", - type: "u64", - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "twapInitialObservation", - type: "u128", - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - }, - { - name: "twapStartDelaySeconds", - type: "u32", - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - }, - { - name: "baseToStake", - type: "u64", - }, - { - name: "passThresholdBps", - type: "u16", - }, - { - name: "secondsPerProposal", - type: "u32", - }, - { - name: "nonce", - type: "u64", - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - }, - ], - }, - }, - { - name: "ProvideLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "quoteAmount", - docs: ["How much quote token you will deposit to the pool"], - type: "u64", - }, - { - name: "maxBaseAmount", - docs: ["The maximum base token you will deposit to the pool"], - type: "u64", - }, - { - name: "minLiquidity", - docs: ["The minimum liquidity you will be assigned"], - type: "u128", - }, - { - name: "positionAuthority", - docs: [ - "The account that will own the LP position, usually the same as the", - "liquidity provider", - ], - type: "publicKey", - }, - ], - }, - }, - { - name: "SpotSwapParams", - type: { - kind: "struct", - fields: [ - { - name: "inputAmount", - type: "u64", - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - }, - { - name: "minOutputAmount", - type: "u64", - }, - ], - }, - }, - { - name: "StakeToProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UnstakeFromProposalParams", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateDaoParams", - type: { - kind: "struct", - fields: [ - { - name: "passThresholdBps", - type: { - option: "u16", - }, - }, - { - name: "secondsPerProposal", - type: { - option: "u32", - }, - }, - { - name: "twapInitialObservation", - type: { - option: "u128", - }, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: { - option: "u128", - }, - }, - { - name: "minQuoteFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "minBaseFutarchicLiquidity", - type: { - option: "u64", - }, - }, - { - name: "baseToStake", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "WithdrawLiquidityParams", - type: { - kind: "struct", - fields: [ - { - name: "liquidityToWithdraw", - docs: ["How much liquidity to withdraw"], - type: "u128", - }, - { - name: "minBaseAmount", - docs: ["Minimum base tokens to receive"], - type: "u64", - }, - { - name: "minQuoteAmount", - docs: ["Minimum quote tokens to receive"], - type: "u64", - }, - ], - }, - }, - { - name: "InitialSpendingLimit", - type: { - kind: "struct", - fields: [ - { - name: "amountPerMonth", - type: "u64", - }, - { - name: "members", - type: { - vec: "publicKey", - }, - }, - ], - }, - }, - { - name: "FutarchyAmm", - type: { - kind: "struct", - fields: [ - { - name: "state", - type: { - defined: "PoolState", - }, - }, - { - name: "totalLiquidity", - type: "u128", - }, - { - name: "baseMint", - type: "publicKey", - }, - { - name: "quoteMint", - type: "publicKey", - }, - { - name: "ammBaseVault", - type: "publicKey", - }, - { - name: "ammQuoteVault", - type: "publicKey", - }, - ], - }, - }, - { - name: "TwapOracle", - type: { - kind: "struct", - fields: [ - { - name: "aggregator", - docs: [ - "Running sum of slots_per_last_update * last_observation.", - "", - "Assuming latest observations are as big as possible (u64::MAX * 1e12),", - "we can store 18 million slots worth of observations, which turns out to", - "be ~85 days worth of slots.", - "", - "Assuming that latest observations are 100x smaller than they could theoretically", - "be, we can store 8500 days (23 years) worth of them. Even this is a very", - "very conservative assumption - META/USDC prices should be between 1e9 and", - "1e15, which would overflow after 1e15 years worth of slots.", - "", - "So in the case of an overflow, the aggregator rolls back to 0. It's the", - "client's responsibility to sanity check the assets or to handle an", - "aggregator at T2 being smaller than an aggregator at T1.", - ], - type: "u128", - }, - { - name: "lastUpdatedTimestamp", - type: "i64", - }, - { - name: "createdAtTimestamp", - type: "i64", - }, - { - name: "lastPrice", - docs: [ - "A price is the number of quote units per base unit multiplied by 1e12.", - "You cannot simply divide by 1e12 to get a price you can display in the UI", - "because the base and quote decimals may be different. Instead, do:", - "ui_price = (price * (10**(base_decimals - quote_decimals))) / 1e12", - ], - type: "u128", - }, - { - name: "lastObservation", - docs: [ - "If we did a raw TWAP over prices, someone could push the TWAP heavily with", - "a few extremely large outliers. So we use observations, which can only move", - "by `max_observation_change_per_update` per update.", - ], - type: "u128", - }, - { - name: "maxObservationChangePerUpdate", - docs: ["The most that an observation can change per update."], - type: "u128", - }, - { - name: "initialObservation", - docs: ["What the initial `latest_observation` is set to."], - type: "u128", - }, - { - name: "startDelaySeconds", - docs: [ - "Number of seconds after amm.created_at_slot to start recording TWAP", - ], - type: "u32", - }, - ], - }, - }, - { - name: "Pool", - type: { - kind: "struct", - fields: [ - { - name: "oracle", - type: { - defined: "TwapOracle", - }, - }, - { - name: "quoteReserves", - type: "u64", - }, - { - name: "baseReserves", - type: "u64", - }, - { - name: "quoteProtocolFeeBalance", - type: "u64", - }, - { - name: "baseProtocolFeeBalance", - type: "u64", - }, - ], - }, - }, - { - name: "PoolState", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - ], - }, - { - name: "Futarchy", - fields: [ - { - name: "spot", - type: { - defined: "Pool", - }, - }, - { - name: "pass", - type: { - defined: "Pool", - }, - }, - { - name: "fail", - type: { - defined: "Pool", - }, - }, - ], - }, - ], - }, - }, - { - name: "Market", - type: { - kind: "enum", - variants: [ - { - name: "Spot", - }, - { - name: "Pass", - }, - { - name: "Fail", - }, - ], - }, - }, - { - name: "SwapType", - type: { - kind: "enum", - variants: [ - { - name: "Buy", - }, - { - name: "Sell", - }, - ], - }, - }, - { - name: "Token", - type: { - kind: "enum", - variants: [ - { - name: "Base", - }, - { - name: "Quote", - }, - ], - }, - }, - { - name: "ProposalState", - type: { - kind: "enum", - variants: [ - { - name: "Draft", - fields: [ - { - name: "amountStaked", - type: "u64", - }, - ], - }, - { - name: "Pending", - }, - { - name: "Passed", - }, - { - name: "Failed", - }, - ], - }, - }, - ], - events: [ - { - name: "CollectFeesEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "quoteTokenAccount", - type: "publicKey", - index: false, - }, - { - name: "ammBaseVault", - type: "publicKey", - index: false, - }, - { - name: "ammQuoteVault", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteFeesCollected", - type: "u64", - index: false, - }, - { - name: "baseFeesCollected", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "InitializeDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - { - name: "initialSpendingLimit", - type: { - option: { - defined: "InitialSpendingLimit", - }, - }, - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UpdateDaoEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passThresholdBps", - type: "u16", - index: false, - }, - { - name: "secondsPerProposal", - type: "u32", - index: false, - }, - { - name: "twapInitialObservation", - type: "u128", - index: false, - }, - { - name: "twapMaxObservationChangePerUpdate", - type: "u128", - index: false, - }, - { - name: "minQuoteFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "minBaseFutarchicLiquidity", - type: "u64", - index: false, - }, - { - name: "baseToStake", - type: "u64", - index: false, - }, - ], - }, - { - name: "InitializeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "question", - type: "publicKey", - index: false, - }, - { - name: "quoteVault", - type: "publicKey", - index: false, - }, - { - name: "baseVault", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "number", - type: "u32", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "durationInSeconds", - type: "u32", - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisigVault", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "StakeToProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "UnstakeFromProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "staker", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "totalStaked", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "FinalizeProposalEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "passMarketTwap", - type: "u128", - index: false, - }, - { - name: "failMarketTwap", - type: "u128", - index: false, - }, - { - name: "threshold", - type: "u128", - index: false, - }, - { - name: "state", - type: { - defined: "ProposalState", - }, - index: false, - }, - { - name: "squadsProposal", - type: "publicKey", - index: false, - }, - { - name: "squadsMultisig", - type: "publicKey", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "SpotSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "user", - type: "publicKey", - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ConditionalSwapEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "proposal", - type: "publicKey", - index: false, - }, - { - name: "trader", - type: "publicKey", - index: false, - }, - { - name: "market", - type: { - defined: "Market", - }, - index: false, - }, - { - name: "swapType", - type: { - defined: "SwapType", - }, - index: false, - }, - { - name: "inputAmount", - type: "u64", - index: false, - }, - { - name: "outputAmount", - type: "u64", - index: false, - }, - { - name: "minOutputAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "ProvideLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "positionAuthority", - type: "publicKey", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "liquidityMinted", - type: "u128", - index: false, - }, - { - name: "minLiquidity", - type: "u128", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - { - name: "WithdrawLiquidityEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "dao", - type: "publicKey", - index: false, - }, - { - name: "liquidityProvider", - type: "publicKey", - index: false, - }, - { - name: "liquidityWithdrawn", - type: "u128", - index: false, - }, - { - name: "minBaseAmount", - type: "u64", - index: false, - }, - { - name: "minQuoteAmount", - type: "u64", - index: false, - }, - { - name: "baseAmount", - type: "u64", - index: false, - }, - { - name: "quoteAmount", - type: "u64", - index: false, - }, - { - name: "postAmmState", - type: { - defined: "FutarchyAmm", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "AmmTooOld", - msg: "Amms must have been created within 5 minutes (counted in slots) of proposal initialization", - }, - { - code: 6001, - name: "InvalidInitialObservation", - msg: "An amm has an `initial_observation` that doesn't match the `dao`'s config", - }, - { - code: 6002, - name: "InvalidMaxObservationChange", - msg: "An amm has a `max_observation_change_per_update` that doesn't match the `dao`'s config", - }, - { - code: 6003, - name: "InvalidStartDelaySlots", - msg: "An amm has a `start_delay_slots` that doesn't match the `dao`'s config", - }, - { - code: 6004, - name: "InvalidSettlementAuthority", - msg: "One of the vaults has an invalid `settlement_authority`", - }, - { - code: 6005, - name: "ProposalTooYoung", - msg: "Proposal is too young to be executed or rejected", - }, - { - code: 6006, - name: "MarketsTooYoung", - msg: "Markets too young for proposal to be finalized. TWAP might need to be cranked", - }, - { - code: 6007, - name: "ProposalAlreadyFinalized", - msg: "This proposal has already been finalized", - }, - { - code: 6008, - name: "InvalidVaultNonce", - msg: "A conditional vault has an invalid nonce. A nonce should encode the proposal number", - }, - { - code: 6009, - name: "ProposalNotPassed", - msg: "This proposal can't be executed because it isn't in the passed state", - }, - { - code: 6010, - name: "InsufficientLiquidity", - msg: "More liquidity needs to be in the AMM to launch this proposal", - }, - { - code: 6011, - name: "ProposalDurationTooShort", - msg: "Proposal duration must be longer 1 day and longer than 2 times the TWAP start delay", - }, - { - code: 6012, - name: "PassThresholdTooHigh", - msg: "Pass threshold must be less than 10%", - }, - { - code: 6013, - name: "QuestionMustBeBinary", - msg: "Question must have exactly 2 outcomes for binary futarchy", - }, - { - code: 6014, - name: "InvalidSquadsProposalStatus", - msg: "Squads proposal must be in Draft status", - }, - { - code: 6015, - name: "CastingOverflow", - msg: "Casting overflow. If you're seeing this, please report this", - }, - { - code: 6016, - name: "InsufficientBalance", - msg: "Insufficient balance", - }, - { - code: 6017, - name: "ZeroLiquidityRemove", - msg: "Cannot remove zero liquidity", - }, - { - code: 6018, - name: "SwapSlippageExceeded", - msg: "Swap slippage exceeded", - }, - { - code: 6019, - name: "AssertFailed", - msg: "Assert failed", - }, - { - code: 6020, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - { - code: 6021, - name: "ProposalNotInDraftState", - msg: "Proposal is not in draft state", - }, - { - code: 6022, - name: "InsufficientTokenBalance", - msg: "Insufficient token balance", - }, - { - code: 6023, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6024, - name: "InsufficientStakeToLaunch", - msg: "Insufficient stake to launch proposal", - }, - { - code: 6025, - name: "StakerNotFound", - msg: "Staker not found in proposal", - }, - { - code: 6026, - name: "PoolNotInSpotState", - msg: "Pool must be in spot state", - }, - { - code: 6027, - name: "InvalidDaoCreateLiquidity", - msg: "If you're providing liquidity, you must provide both base and quote token accounts", - }, - { - code: 6028, - name: "InvalidStakeAccount", - msg: "Invalid stake account", - }, - { - code: 6029, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6030, - name: "ProposalNotActive", - msg: "Proposal needs to be active to perform a conditional swap", - }, - { - code: 6031, - name: "InvalidTransaction", - msg: "This Squads transaction should only contain calls to update spending limits", - }, - ], -}; diff --git a/sdk2/src/index.ts b/sdk2/src/index.ts deleted file mode 100644 index bd08c833a..000000000 --- a/sdk2/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Default exports for latest versions of programs -export * from "./bid_wall/index.js"; -export * from "./conditional_vault/index.js"; -export * from "./futarchy/index.js"; -export * from "./launchpad/index.js"; -export * from "./liquidation/index.js"; -export * from "./mint_governor/index.js"; -export * from "./performance_package_v2/index.js"; -export * from "./price_based_performance_package/index.js"; - -// Shared exports -export * from "./utils.js"; -export * from "./constants.js"; -export * from "./pda.js"; -export * from "./priceMath.js"; - -export { sha256 } from "@noble/hashes/sha256"; diff --git a/sdk2/src/launchpad/v0.4/types/launchpad.ts b/sdk2/src/launchpad/v0.4/types/launchpad.ts deleted file mode 100644 index 50a6f63aa..000000000 --- a/sdk2/src/launchpad/v0.4/types/launchpad.ts +++ /dev/null @@ -1,1999 +0,0 @@ -export type Launchpad = { - version: "0.4.1"; - name: "launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "usdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "usdcMint"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchUsdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderUsdcAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "launchUsdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryUsdcAccount"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "ammConfig"; - isMut: true; - isSigner: false; - docs: [ - "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", - ]; - }, - { - name: "poolState"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "usdcMint"; - isMut: false; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "lpVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolUsdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "createPoolFee"; - isMut: true; - isSigner: false; - docs: ["create pool fee account"]; - }, - { - name: "observationState"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "daoTreasury"; - isMut: false; - isSigner: false; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchUsdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: true; - isSigner: true; - }, - { - name: "funderUsdcAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "launchTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this funding record. Useful for sorting events.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchUsdcVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchTokenVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "tokenMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "usdcMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: "i64"; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoTreasury"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "tokenMint"; - type: "publicKey"; - index: false; - }, - { - name: "usdcMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "fundingRecordSeqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "Launch needs to be in refunding state to get a refund"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - ]; -}; - -export const IDL: Launchpad = { - version: "0.4.1", - name: "launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "tokenMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "usdcVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "usdcMint", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchUsdcVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderUsdcAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "launchUsdcVault", - isMut: true, - isSigner: false, - }, - { - name: "launchTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryUsdcAccount", - isMut: true, - isSigner: false, - }, - { - name: "treasuryLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "ammConfig", - isMut: true, - isSigner: false, - docs: [ - "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", - ], - }, - { - name: "poolState", - isMut: true, - isSigner: false, - }, - { - name: "tokenMint", - isMut: true, - isSigner: false, - }, - { - name: "usdcMint", - isMut: false, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "lpVault", - isMut: true, - isSigner: false, - }, - { - name: "poolTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "poolUsdcVault", - isMut: true, - isSigner: false, - }, - { - name: "createPoolFee", - isMut: true, - isSigner: false, - docs: ["create pool fee account"], - }, - { - name: "observationState", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "daoTreasury", - isMut: false, - isSigner: false, - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchUsdcVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: true, - isSigner: true, - }, - { - name: "funderUsdcAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "tokenMint", - isMut: true, - isSigner: false, - }, - { - name: "launchTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "seqNum", - docs: [ - "The sequence number of this funding record. Useful for sorting events.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchUsdcVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchTokenVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "tokenMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "usdcMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: "i64", - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoTreasury", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "tokenMint", - type: "publicKey", - index: false, - }, - { - name: "usdcMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "fundingRecordSeqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "Launch needs to be in refunding state to get a refund", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - ], -}; diff --git a/sdk2/src/launchpad/v0.5/types/launchpad.ts b/sdk2/src/launchpad/v0.5/types/launchpad.ts deleted file mode 100644 index 0af6abd3c..000000000 --- a/sdk2/src/launchpad/v0.5/types/launchpad.ts +++ /dev/null @@ -1,2123 +0,0 @@ -export type Launchpad = { - version: "0.5.0"; - name: "launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryLpAccount"; - isMut: true; - isSigner: false; - }, - { - name: "poolState"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "lpMint"; - isMut: true; - isSigner: false; - }, - { - name: "lpVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolUsdcVault"; - isMut: true; - isSigner: false; - }, - { - name: "observationState"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "ammConfig"; - isMut: true; - isSigner: false; - docs: [ - "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", - ]; - }, - { - name: "createPoolFee"; - isMut: true; - isSigner: false; - docs: ["create pool fee account"]; - }, - { - name: "cpSwapProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this funding record. Useful for sorting events.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: "i64"; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "fundingRecordSeqNum"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "Launch needs to be in refunding state to get a refund"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount"; - }, - ]; -}; - -export const IDL: Launchpad = { - version: "0.5.0", - name: "launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "treasuryLpAccount", - isMut: true, - isSigner: false, - }, - { - name: "poolState", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "lpMint", - isMut: true, - isSigner: false, - }, - { - name: "lpVault", - isMut: true, - isSigner: false, - }, - { - name: "poolTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "poolUsdcVault", - isMut: true, - isSigner: false, - }, - { - name: "observationState", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "ammConfig", - isMut: true, - isSigner: false, - docs: [ - "Use the lowest fee pool, can see fees at https://api-v3.raydium.io/main/cpmm-config", - ], - }, - { - name: "createPoolFee", - isMut: true, - isSigner: false, - docs: ["create pool fee account"], - }, - { - name: "cpSwapProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "seqNum", - docs: [ - "The sequence number of this funding record. Useful for sorting events.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: "i64", - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "fundingRecordSeqNum", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "Launch needs to be in refunding state to get a refund", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount", - }, - ], -}; diff --git a/sdk2/src/launchpad/v0.6/types/launchpad.ts b/sdk2/src/launchpad/v0.6/types/launchpad.ts deleted file mode 100644 index 3950f26cf..000000000 --- a/sdk2/src/launchpad/v0.6/types/launchpad.ts +++ /dev/null @@ -1,2813 +0,0 @@ -export type Launchpad = { - version: "0.6.1"; - name: "launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CompleteLaunchArgs"; - }; - }, - ]; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "returnFunds"; - accounts: [ - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "recipientQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ReturnFundsArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "finalRaiseAmount"; - docs: ["The final raise amount."]; - type: { - option: "u64"; - }; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "CompleteLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "finalRaiseAmount"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ReturnFundsArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - index: false; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - index: false; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "finalRaiseAmount"; - type: { - option: "u64"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchFundsReturnedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "usdcReturned"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6012; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6013; - name: "InvalidPriceBasedPremineAmount"; - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; - }, - { - code: 6014; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; - }, - { - code: 6015; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6016; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be greater than or equal to the minimum raise amount"; - }, - { - code: 6017; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6018; - name: "MoneyAlreadyRefunded"; - msg: "Money already refunded"; - }, - { - code: 6019; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6020; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6021; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; - }, - { - code: 6022; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - ]; -}; - -export const IDL: Launchpad = { - version: "0.6.1", - name: "launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CompleteLaunchArgs", - }, - }, - ], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "returnFunds", - accounts: [ - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "recipientQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ReturnFundsArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "finalRaiseAmount", - docs: ["The final raise amount."], - type: { - option: "u64", - }, - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "CompleteLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "finalRaiseAmount", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - { - name: "teamAddress", - type: "publicKey", - }, - ], - }, - }, - { - name: "ReturnFundsArgs", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "performancePackageGrantee", - type: "publicKey", - index: false, - }, - { - name: "performancePackageTokenAmount", - type: "u64", - index: false, - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - index: false, - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - index: false, - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "finalRaiseAmount", - type: { - option: "u64", - }, - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - { - name: "LaunchFundsReturnedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "usdcReturned", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6012, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6013, - name: "InvalidPriceBasedPremineAmount", - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", - }, - { - code: 6014, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", - }, - { - code: 6015, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6016, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be greater than or equal to the minimum raise amount", - }, - { - code: 6017, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6018, - name: "MoneyAlreadyRefunded", - msg: "Money already refunded", - }, - { - code: 6019, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6020, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6021, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", - }, - { - code: 6022, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - ], -}; diff --git a/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts b/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts deleted file mode 100644 index 828949a83..000000000 --- a/sdk2/src/launchpad/v0.6/types/v0.6.0-launchpad.ts +++ /dev/null @@ -1,2553 +0,0 @@ -export type Launchpad = { - version: "0.6.0"; - name: "launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "autocratEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "CompleteLaunchArgs"; - }; - }, - ]; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "finalRaiseAmount"; - docs: ["The final raise amount."]; - type: { - option: "u64"; - }; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "CompleteLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "finalRaiseAmount"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6012; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6013; - name: "InvalidPriceBasedPremineAmount"; - msg: "Cannot do more than a 50% premine"; - }, - { - code: 6014; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; - }, - { - code: 6015; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6016; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be greater than or equal to the minimum raise amount"; - }, - { - code: 6017; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6018; - name: "MoneyAlreadyRefunded"; - msg: "Money already refunded"; - }, - { - code: 6019; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6020; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6021; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; - }, - ]; -}; - -export const IDL: Launchpad = { - version: "0.6.0", - name: "launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "autocratEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "CompleteLaunchArgs", - }, - }, - ], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "finalRaiseAmount", - docs: ["The final raise amount."], - type: { - option: "u64", - }, - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "CompleteLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "finalRaiseAmount", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6012, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6013, - name: "InvalidPriceBasedPremineAmount", - msg: "Cannot do more than a 50% premine", - }, - { - code: 6014, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", - }, - { - code: 6015, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6016, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be greater than or equal to the minimum raise amount", - }, - { - code: 6017, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6018, - name: "MoneyAlreadyRefunded", - msg: "Money already refunded", - }, - { - code: 6019, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6020, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6021, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", - }, - ], -}; diff --git a/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts b/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts deleted file mode 100644 index e5b1bf7e9..000000000 --- a/sdk2/src/launchpad/v0.7/types/launchpad_v7.ts +++ /dev/null @@ -1,4223 +0,0 @@ -export type LaunchpadV7 = { - version: "0.7.0"; - name: "launchpad_v7"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - isOptional: true; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "setFundingRecordApproval"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "approvedAmount"; - type: "u64"; - }, - ]; - }, - { - name: "completeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "futarchyEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallProgram"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claimAdditionalTokenAllocation"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipientTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "initializePerformancePackage"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageProgram"; - isMut: false; - isSigner: false; - }, - { - name: "priceBasedPerformancePackageEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "resizeFundingRecord"; - accounts: [ - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "resizeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "extendLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ExtendLaunchArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - { - name: "approvedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ]; - type: "u64"; - }, - { - name: "committedAmountAccumulator"; - docs: [ - "Running integral of committed_amount over time (committed_amount * seconds).", - ]; - type: "u128"; - }, - { - name: "lastAccumulatorUpdate"; - docs: ["Unix timestamp of the last accumulator update."]; - type: "i64"; - }, - ]; - }; - }, - { - name: "oldFundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - { - name: "approvedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - { - name: "totalApprovedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ]; - type: "u64"; - }, - { - name: "additionalTokensAmount"; - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ]; - type: "u64"; - }, - { - name: "additionalTokensRecipient"; - docs: [ - "The token account that will receive the additional tokens.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "additionalTokensClaimed"; - docs: ["Are the additional tokens claimed"]; - type: "bool"; - }, - { - name: "unixTimestampCompleted"; - docs: ["The unix timestamp when the launch was completed."]; - type: { - option: "i64"; - }; - }, - { - name: "isPerformancePackageInitialized"; - docs: ["Whether the performance package has been initialized."]; - type: "bool"; - }, - { - name: "accumulatorActivationDelaySeconds"; - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ]; - type: "u32"; - }, - { - name: "hasBidWall"; - docs: ["Whether the launch has a bid wall."]; - type: "bool"; - }, - ]; - }; - }, - { - name: "oldLaunch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to Raydium."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - { - name: "totalApprovedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ]; - type: "u64"; - }, - { - name: "additionalTokensAmount"; - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ]; - type: "u64"; - }, - { - name: "additionalTokensRecipient"; - docs: [ - "The token account that will receive the additional tokens.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "additionalTokensClaimed"; - docs: ["Are the additional tokens claimed"]; - type: "bool"; - }, - { - name: "unixTimestampCompleted"; - docs: ["The unix timestamp when the launch was completed."]; - type: { - option: "i64"; - }; - }, - { - name: "isPerformancePackageInitialized"; - type: "bool"; - }, - { - name: "accumulatorActivationDelaySeconds"; - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ]; - type: "u32"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ExtendLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "durationSeconds"; - type: "u32"; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - }, - { - name: "accumulatorActivationDelaySeconds"; - type: "u32"; - }, - { - name: "hasBidWall"; - type: "bool"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - index: false; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - index: false; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - index: false; - }, - { - name: "additionalTokensRecipient"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "accumulatorActivationDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "hasBidWall"; - type: "bool"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "committedAmountAccumulator"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "FundingRecordApprovalSetEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "approvedAmount"; - type: "u64"; - index: false; - }, - { - name: "totalApproved"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "totalApprovedAmount"; - type: "u64"; - index: false; - }, - { - name: "bidWall"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "bidWallAmount"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - index: false; - }, - { - name: "additionalTokensRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchPerformancePackageInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchExtendedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "oldSecondsForLaunch"; - type: "u32"; - index: false; - }, - { - name: "newSecondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidTokenKey"; - msg: "Token mint key must end in 'meta'"; - }, - { - code: 6005; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6006; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6007; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6008; - name: "LaunchNotRefunding"; - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed"; - }, - { - code: 6009; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6010; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6012; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6013; - name: "InvalidPriceBasedPremineAmount"; - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token"; - }, - { - code: 6014; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens"; - }, - { - code: 6015; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6016; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be greater than or equal to the minimum raise amount"; - }, - { - code: 6017; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6018; - name: "MoneyAlreadyRefunded"; - msg: "Money already refunded"; - }, - { - code: 6019; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6020; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6021; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch"; - }, - { - code: 6022; - name: "FinalRaiseAmountAlreadySet"; - msg: "The final raise amount has already been set"; - }, - { - code: 6023; - name: "TotalApprovedAmountTooLow"; - msg: "Total approved amount must be greater than or equal to the minimum raise amount"; - }, - { - code: 6024; - name: "InvalidAdditionalTokensRecipient"; - msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0"; - }, - { - code: 6025; - name: "NoAdditionalTokensRecipientSet"; - msg: "No additional tokens recipient set"; - }, - { - code: 6026; - name: "AdditionalTokensAlreadyClaimed"; - msg: "Additional tokens already claimed"; - }, - { - code: 6027; - name: "FundingRecordApprovalPeriodOver"; - msg: "Funding record approval period is over"; - }, - { - code: 6028; - name: "PerformancePackageAlreadyInitialized"; - msg: "Performance package already initialized"; - }, - { - code: 6029; - name: "InvalidDao"; - msg: "Invalid DAO"; - }, - { - code: 6030; - name: "InvalidAccumulatorActivationDelaySeconds"; - msg: "Accumulator activation delay must be less than the launch duration"; - }, - { - code: 6031; - name: "ExtendDurationExceedsMax"; - msg: "The extend duration would exceed the maximum allowed launch duration"; - }, - ]; -}; - -export const IDL: LaunchpadV7 = { - version: "0.7.0", - name: "launchpad_v7", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - isOptional: true, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "setFundingRecordApproval", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "approvedAmount", - type: "u64", - }, - ], - }, - { - name: "completeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "futarchyEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "bidWallProgram", - isMut: false, - isSigner: false, - }, - { - name: "bidWallEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claimAdditionalTokenAllocation", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipientTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "initializePerformancePackage", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageProgram", - isMut: false, - isSigner: false, - }, - { - name: "priceBasedPerformancePackageEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "resizeFundingRecord", - accounts: [ - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "resizeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "extendLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ExtendLaunchArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - { - name: "approvedAmount", - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ], - type: "u64", - }, - { - name: "committedAmountAccumulator", - docs: [ - "Running integral of committed_amount over time (committed_amount * seconds).", - ], - type: "u128", - }, - { - name: "lastAccumulatorUpdate", - docs: ["Unix timestamp of the last accumulator update."], - type: "i64", - }, - ], - }, - }, - { - name: "oldFundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - { - name: "approvedAmount", - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ], - type: "u64", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - { - name: "totalApprovedAmount", - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ], - type: "u64", - }, - { - name: "additionalTokensAmount", - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ], - type: "u64", - }, - { - name: "additionalTokensRecipient", - docs: [ - "The token account that will receive the additional tokens.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "additionalTokensClaimed", - docs: ["Are the additional tokens claimed"], - type: "bool", - }, - { - name: "unixTimestampCompleted", - docs: ["The unix timestamp when the launch was completed."], - type: { - option: "i64", - }, - }, - { - name: "isPerformancePackageInitialized", - docs: ["Whether the performance package has been initialized."], - type: "bool", - }, - { - name: "accumulatorActivationDelaySeconds", - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ], - type: "u32", - }, - { - name: "hasBidWall", - docs: ["Whether the launch has a bid wall."], - type: "bool", - }, - ], - }, - }, - { - name: "oldLaunch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: [ - "The launch signer address. Needed because Raydium pools need a SOL payer and this PDA can't hold SOL.", - ], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to Raydium."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - { - name: "totalApprovedAmount", - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ], - type: "u64", - }, - { - name: "additionalTokensAmount", - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ], - type: "u64", - }, - { - name: "additionalTokensRecipient", - docs: [ - "The token account that will receive the additional tokens.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "additionalTokensClaimed", - docs: ["Are the additional tokens claimed"], - type: "bool", - }, - { - name: "unixTimestampCompleted", - docs: ["The unix timestamp when the launch was completed."], - type: { - option: "i64", - }, - }, - { - name: "isPerformancePackageInitialized", - type: "bool", - }, - { - name: "accumulatorActivationDelaySeconds", - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ], - type: "u32", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ExtendLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "durationSeconds", - type: "u32", - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - { - name: "teamAddress", - type: "publicKey", - }, - { - name: "additionalTokensAmount", - type: "u64", - }, - { - name: "accumulatorActivationDelaySeconds", - type: "u32", - }, - { - name: "hasBidWall", - type: "bool", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "performancePackageGrantee", - type: "publicKey", - index: false, - }, - { - name: "performancePackageTokenAmount", - type: "u64", - index: false, - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - index: false, - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - index: false, - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - { - name: "additionalTokensAmount", - type: "u64", - index: false, - }, - { - name: "additionalTokensRecipient", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "accumulatorActivationDelaySeconds", - type: "u32", - index: false, - }, - { - name: "hasBidWall", - type: "bool", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "committedAmountAccumulator", - type: "u128", - index: false, - }, - ], - }, - { - name: "FundingRecordApprovalSetEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "approvedAmount", - type: "u64", - index: false, - }, - { - name: "totalApproved", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "totalApprovedAmount", - type: "u64", - index: false, - }, - { - name: "bidWall", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "bidWallAmount", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "additionalTokensAmount", - type: "u64", - index: false, - }, - { - name: "additionalTokensRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchPerformancePackageInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchExtendedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "oldSecondsForLaunch", - type: "u32", - index: false, - }, - { - name: "newSecondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidTokenKey", - msg: "Token mint key must end in 'meta'", - }, - { - code: 6005, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6006, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6007, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6008, - name: "LaunchNotRefunding", - msg: "For you to get a refund, either the launch needs to be in a refunding state or the launch must have been over-committed", - }, - { - code: 6009, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6010, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6012, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6013, - name: "InvalidPriceBasedPremineAmount", - msg: "Cannot do more than a 50% premine, minimum is 10 atoms of token", - }, - { - code: 6014, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must be forced to wait at least 18 months before unlocking their tokens", - }, - { - code: 6015, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6016, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be greater than or equal to the minimum raise amount", - }, - { - code: 6017, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6018, - name: "MoneyAlreadyRefunded", - msg: "Money already refunded", - }, - { - code: 6019, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6020, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6021, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount must be greater than or equal to $0.5 so that there's enough liquidity for the launch", - }, - { - code: 6022, - name: "FinalRaiseAmountAlreadySet", - msg: "The final raise amount has already been set", - }, - { - code: 6023, - name: "TotalApprovedAmountTooLow", - msg: "Total approved amount must be greater than or equal to the minimum raise amount", - }, - { - code: 6024, - name: "InvalidAdditionalTokensRecipient", - msg: "Invalid additional tokens recipient - should be set if additional tokens amount is greater than 0", - }, - { - code: 6025, - name: "NoAdditionalTokensRecipientSet", - msg: "No additional tokens recipient set", - }, - { - code: 6026, - name: "AdditionalTokensAlreadyClaimed", - msg: "Additional tokens already claimed", - }, - { - code: 6027, - name: "FundingRecordApprovalPeriodOver", - msg: "Funding record approval period is over", - }, - { - code: 6028, - name: "PerformancePackageAlreadyInitialized", - msg: "Performance package already initialized", - }, - { - code: 6029, - name: "InvalidDao", - msg: "Invalid DAO", - }, - { - code: 6030, - name: "InvalidAccumulatorActivationDelaySeconds", - msg: "Accumulator activation delay must be less than the launch duration", - }, - { - code: 6031, - name: "ExtendDurationExceedsMax", - msg: "The extend duration would exceed the maximum allowed launch duration", - }, - ], -}; diff --git a/sdk2/src/liquidation/v0.7/types/liquidation.ts b/sdk2/src/liquidation/v0.7/types/liquidation.ts deleted file mode 100644 index a83a162cf..000000000 --- a/sdk2/src/liquidation/v0.7/types/liquidation.ts +++ /dev/null @@ -1,1515 +0,0 @@ -export type Liquidation = { - version: "0.1.0"; - name: "liquidation"; - instructions: [ - { - name: "initializeLiquidation"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - }, - { - name: "recordAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "liquidationAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "liquidation"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLiquidationArgs"; - }; - }, - ]; - }, - { - name: "setRefundRecord"; - accounts: [ - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "recordAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidation"; - isMut: true; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "refundRecord"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "SetRefundRecordArgs"; - }; - }, - ]; - }, - { - name: "activateLiquidation"; - accounts: [ - { - name: "liquidationAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidation"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationAuthorityQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "recipient"; - isMut: true; - isSigner: true; - }, - { - name: "liquidation"; - isMut: true; - isSigner: false; - }, - { - name: "refundRecord"; - isMut: true; - isSigner: false; - }, - { - name: "recipientBaseAccount"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "recipientQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "withdrawRemainingQuote"; - accounts: [ - { - name: "liquidationAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "liquidation"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "liquidationAuthorityQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "liquidation"; - type: { - kind: "struct"; - fields: [ - { - name: "createKey"; - docs: ["Arbitrary keypair used to make the PDA unique."]; - type: "publicKey"; - }, - { - name: "recordAuthority"; - docs: [ - "The address that can create and modify RefundRecords during setup.", - ]; - type: "publicKey"; - }, - { - name: "liquidationAuthority"; - docs: [ - "The address that activates the liquidation and receives remaining quote tokens post-deadline.", - ]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: ["The project token mint (tokens to be burned)."]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The refund token mint (USDC)."]; - type: "publicKey"; - }, - { - name: "totalQuoteRefundable"; - docs: ["Sum of all RefundRecord quote_refundable values."]; - type: "u64"; - }, - { - name: "totalQuoteRefunded"; - docs: [ - "Sum of all quote tokens actually transferred to users so far.", - ]; - type: "u64"; - }, - { - name: "totalBaseAssigned"; - docs: ["Sum of all RefundRecord base_assigned values."]; - type: "u64"; - }, - { - name: "totalBaseBurned"; - docs: ["Sum of all base tokens actually burned so far."]; - type: "u64"; - }, - { - name: "startedAt"; - docs: [ - "Unix timestamp when ActivateLiquidation was called. 0 before activation.", - ]; - type: "i64"; - }, - { - name: "durationSeconds"; - docs: ["How long the refund window lasts after activation."]; - type: "u32"; - }, - { - name: "seqNum"; - docs: ["Event sequence number for indexing."]; - type: "u64"; - }, - { - name: "isRefunding"; - docs: ["Whether refunds are currently enabled."]; - type: "bool"; - }, - { - name: "pdaBump"; - docs: ["PDA bump seed."]; - type: "u8"; - }, - ]; - }; - }, - { - name: "refundRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "liquidation"; - docs: ["The parent Liquidation account."]; - type: "publicKey"; - }, - { - name: "recipient"; - docs: ["The user this record belongs to."]; - type: "publicKey"; - }, - { - name: "baseAssigned"; - docs: ["Total base tokens this user is eligible to burn."]; - type: "u64"; - }, - { - name: "baseBurned"; - docs: ["Base tokens this user has burned so far."]; - type: "u64"; - }, - { - name: "quoteRefundable"; - docs: [ - "Total quote tokens this user can receive if they burn all assigned base.", - ]; - type: "u64"; - }, - { - name: "quoteRefunded"; - docs: ["Quote tokens already transferred to this user."]; - type: "u64"; - }, - { - name: "pdaBump"; - docs: ["PDA bump seed."]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "liquidationSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializeLiquidationArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "durationSeconds"; - type: "u32"; - }, - ]; - }; - }, - { - name: "SetRefundRecordArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "baseAssigned"; - type: "u64"; - }, - { - name: "quoteRefundable"; - type: "u64"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LiquidationCreatedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "liquidation"; - type: "publicKey"; - index: false; - }, - { - name: "createKey"; - type: "publicKey"; - index: false; - }, - { - name: "recordAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "liquidationAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "durationSeconds"; - type: "u32"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - ]; - }, - { - name: "LiquidationActivatedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "liquidation"; - type: "publicKey"; - index: false; - }, - { - name: "totalQuoteFunded"; - type: "u64"; - index: false; - }, - { - name: "startedAt"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "RefundRecordSetEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "liquidation"; - type: "publicKey"; - index: false; - }, - { - name: "refundRecord"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "baseAssigned"; - type: "u64"; - index: false; - }, - { - name: "quoteRefundable"; - type: "u64"; - index: false; - }, - { - name: "liquidationTotalBaseAssigned"; - type: "u64"; - index: false; - }, - { - name: "liquidationTotalQuoteRefundable"; - type: "u64"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - ]; - }, - { - name: "RefundEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "liquidation"; - type: "publicKey"; - index: false; - }, - { - name: "refundRecord"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "baseBurned"; - type: "u64"; - index: false; - }, - { - name: "quoteRefunded"; - type: "u64"; - index: false; - }, - { - name: "postRecordBaseBurned"; - type: "u64"; - index: false; - }, - { - name: "postRecordQuoteRefunded"; - type: "u64"; - index: false; - }, - { - name: "postLiquidationTotalBaseBurned"; - type: "u64"; - index: false; - }, - { - name: "postLiquidationTotalQuoteRefunded"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "WithdrawRemainingQuoteEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "liquidation"; - type: "publicKey"; - index: false; - }, - { - name: "liquidationAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "RefundingNotEnabled"; - msg: "Refunding is not enabled"; - }, - { - code: 6001; - name: "AlreadyActivated"; - msg: "Liquidation is already activated"; - }, - { - code: 6002; - name: "NothingToFund"; - msg: "No quote tokens to fund"; - }, - { - code: 6003; - name: "NoBaseAssigned"; - msg: "No base tokens assigned"; - }, - { - code: 6004; - name: "RefundWindowExpired"; - msg: "Refund window has expired"; - }, - { - code: 6005; - name: "RefundWindowNotExpired"; - msg: "Refund window has not expired"; - }, - { - code: 6006; - name: "InvalidDuration"; - msg: "Duration must be greater than zero"; - }, - { - code: 6007; - name: "NothingToRefund"; - msg: "Nothing to refund"; - }, - { - code: 6008; - name: "InvalidAllocation"; - msg: "Invalid allocation"; - }, - { - code: 6009; - name: "InvalidAuthority"; - msg: "Invalid authority"; - }, - { - code: 6010; - name: "InvalidMint"; - msg: "Invalid mint"; - }, - ]; -}; - -export const IDL: Liquidation = { - version: "0.1.0", - name: "liquidation", - instructions: [ - { - name: "initializeLiquidation", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - }, - { - name: "recordAuthority", - isMut: false, - isSigner: false, - }, - { - name: "liquidationAuthority", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "liquidation", - isMut: true, - isSigner: false, - }, - { - name: "liquidationQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLiquidationArgs", - }, - }, - ], - }, - { - name: "setRefundRecord", - accounts: [ - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "recordAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidation", - isMut: true, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "refundRecord", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "SetRefundRecordArgs", - }, - }, - ], - }, - { - name: "activateLiquidation", - accounts: [ - { - name: "liquidationAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidation", - isMut: true, - isSigner: false, - }, - { - name: "liquidationAuthorityQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidationQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "recipient", - isMut: true, - isSigner: true, - }, - { - name: "liquidation", - isMut: true, - isSigner: false, - }, - { - name: "refundRecord", - isMut: true, - isSigner: false, - }, - { - name: "recipientBaseAccount", - isMut: true, - isSigner: false, - }, - { - name: "liquidationQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "recipientQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "withdrawRemainingQuote", - accounts: [ - { - name: "liquidationAuthority", - isMut: false, - isSigner: true, - }, - { - name: "liquidation", - isMut: true, - isSigner: false, - }, - { - name: "liquidationQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "liquidationAuthorityQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "liquidation", - type: { - kind: "struct", - fields: [ - { - name: "createKey", - docs: ["Arbitrary keypair used to make the PDA unique."], - type: "publicKey", - }, - { - name: "recordAuthority", - docs: [ - "The address that can create and modify RefundRecords during setup.", - ], - type: "publicKey", - }, - { - name: "liquidationAuthority", - docs: [ - "The address that activates the liquidation and receives remaining quote tokens post-deadline.", - ], - type: "publicKey", - }, - { - name: "baseMint", - docs: ["The project token mint (tokens to be burned)."], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The refund token mint (USDC)."], - type: "publicKey", - }, - { - name: "totalQuoteRefundable", - docs: ["Sum of all RefundRecord quote_refundable values."], - type: "u64", - }, - { - name: "totalQuoteRefunded", - docs: [ - "Sum of all quote tokens actually transferred to users so far.", - ], - type: "u64", - }, - { - name: "totalBaseAssigned", - docs: ["Sum of all RefundRecord base_assigned values."], - type: "u64", - }, - { - name: "totalBaseBurned", - docs: ["Sum of all base tokens actually burned so far."], - type: "u64", - }, - { - name: "startedAt", - docs: [ - "Unix timestamp when ActivateLiquidation was called. 0 before activation.", - ], - type: "i64", - }, - { - name: "durationSeconds", - docs: ["How long the refund window lasts after activation."], - type: "u32", - }, - { - name: "seqNum", - docs: ["Event sequence number for indexing."], - type: "u64", - }, - { - name: "isRefunding", - docs: ["Whether refunds are currently enabled."], - type: "bool", - }, - { - name: "pdaBump", - docs: ["PDA bump seed."], - type: "u8", - }, - ], - }, - }, - { - name: "refundRecord", - type: { - kind: "struct", - fields: [ - { - name: "liquidation", - docs: ["The parent Liquidation account."], - type: "publicKey", - }, - { - name: "recipient", - docs: ["The user this record belongs to."], - type: "publicKey", - }, - { - name: "baseAssigned", - docs: ["Total base tokens this user is eligible to burn."], - type: "u64", - }, - { - name: "baseBurned", - docs: ["Base tokens this user has burned so far."], - type: "u64", - }, - { - name: "quoteRefundable", - docs: [ - "Total quote tokens this user can receive if they burn all assigned base.", - ], - type: "u64", - }, - { - name: "quoteRefunded", - docs: ["Quote tokens already transferred to this user."], - type: "u64", - }, - { - name: "pdaBump", - docs: ["PDA bump seed."], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "liquidationSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializeLiquidationArgs", - type: { - kind: "struct", - fields: [ - { - name: "durationSeconds", - type: "u32", - }, - ], - }, - }, - { - name: "SetRefundRecordArgs", - type: { - kind: "struct", - fields: [ - { - name: "baseAssigned", - type: "u64", - }, - { - name: "quoteRefundable", - type: "u64", - }, - ], - }, - }, - ], - events: [ - { - name: "LiquidationCreatedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "liquidation", - type: "publicKey", - index: false, - }, - { - name: "createKey", - type: "publicKey", - index: false, - }, - { - name: "recordAuthority", - type: "publicKey", - index: false, - }, - { - name: "liquidationAuthority", - type: "publicKey", - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "durationSeconds", - type: "u32", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - ], - }, - { - name: "LiquidationActivatedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "liquidation", - type: "publicKey", - index: false, - }, - { - name: "totalQuoteFunded", - type: "u64", - index: false, - }, - { - name: "startedAt", - type: "i64", - index: false, - }, - ], - }, - { - name: "RefundRecordSetEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "liquidation", - type: "publicKey", - index: false, - }, - { - name: "refundRecord", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "baseAssigned", - type: "u64", - index: false, - }, - { - name: "quoteRefundable", - type: "u64", - index: false, - }, - { - name: "liquidationTotalBaseAssigned", - type: "u64", - index: false, - }, - { - name: "liquidationTotalQuoteRefundable", - type: "u64", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - ], - }, - { - name: "RefundEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "liquidation", - type: "publicKey", - index: false, - }, - { - name: "refundRecord", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "baseBurned", - type: "u64", - index: false, - }, - { - name: "quoteRefunded", - type: "u64", - index: false, - }, - { - name: "postRecordBaseBurned", - type: "u64", - index: false, - }, - { - name: "postRecordQuoteRefunded", - type: "u64", - index: false, - }, - { - name: "postLiquidationTotalBaseBurned", - type: "u64", - index: false, - }, - { - name: "postLiquidationTotalQuoteRefunded", - type: "u64", - index: false, - }, - ], - }, - { - name: "WithdrawRemainingQuoteEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "liquidation", - type: "publicKey", - index: false, - }, - { - name: "liquidationAuthority", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "RefundingNotEnabled", - msg: "Refunding is not enabled", - }, - { - code: 6001, - name: "AlreadyActivated", - msg: "Liquidation is already activated", - }, - { - code: 6002, - name: "NothingToFund", - msg: "No quote tokens to fund", - }, - { - code: 6003, - name: "NoBaseAssigned", - msg: "No base tokens assigned", - }, - { - code: 6004, - name: "RefundWindowExpired", - msg: "Refund window has expired", - }, - { - code: 6005, - name: "RefundWindowNotExpired", - msg: "Refund window has not expired", - }, - { - code: 6006, - name: "InvalidDuration", - msg: "Duration must be greater than zero", - }, - { - code: 6007, - name: "NothingToRefund", - msg: "Nothing to refund", - }, - { - code: 6008, - name: "InvalidAllocation", - msg: "Invalid allocation", - }, - { - code: 6009, - name: "InvalidAuthority", - msg: "Invalid authority", - }, - { - code: 6010, - name: "InvalidMint", - msg: "Invalid mint", - }, - ], -}; diff --git a/sdk2/src/mint_governor/v0.7/types/mint_governor.ts b/sdk2/src/mint_governor/v0.7/types/mint_governor.ts deleted file mode 100644 index b2d9b02c2..000000000 --- a/sdk2/src/mint_governor/v0.7/types/mint_governor.ts +++ /dev/null @@ -1,1473 +0,0 @@ -export type MintGovernor = { - version: "0.7.0"; - name: "mint_governor"; - instructions: [ - { - name: "initializeMintGovernor"; - accounts: [ - { - name: "mint"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - }, - { - name: "admin"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "transferAuthorityToGovernor"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mint"; - isMut: true; - isSigner: false; - }, - { - name: "currentAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "addMintAuthority"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "authorizedMinter"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "AddMintAuthorityArgs"; - }; - }, - ]; - }, - { - name: "mintTokens"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "mint"; - isMut: true; - isSigner: false; - }, - { - name: "destinationAta"; - isMut: true; - isSigner: false; - }, - { - name: "authorizedMinter"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "MintTokensArgs"; - }; - }, - ]; - }, - { - name: "updateMintAuthority"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "UpdateMintAuthorityArgs"; - }; - }, - ]; - }, - { - name: "removeMintAuthority"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "rentDestination"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "updateMintGovernorAdmin"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "newAdmin"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "reclaimAuthority"; - accounts: [ - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mint"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "newAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "mintAuthority"; - type: { - kind: "struct"; - fields: [ - { - name: "mintGovernor"; - type: "publicKey"; - }, - { - name: "authorizedMinter"; - type: "publicKey"; - }, - { - name: "maxTotal"; - type: { - option: "u64"; - }; - }, - { - name: "totalMinted"; - type: "u64"; - }, - { - name: "bump"; - type: "u8"; - }, - ]; - }; - }, - { - name: "mintGovernor"; - type: { - kind: "struct"; - fields: [ - { - name: "mint"; - type: "publicKey"; - }, - { - name: "admin"; - type: "publicKey"; - }, - { - name: "createKey"; - type: "publicKey"; - }, - { - name: "seqNum"; - type: "u64"; - }, - { - name: "bump"; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "mintGovernorSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "AddMintAuthorityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "maxTotal"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - { - name: "MintTokensArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }; - }, - { - name: "UpdateMintAuthorityArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "maxTotal"; - type: { - option: "u64"; - }; - }, - ]; - }; - }, - ]; - events: [ - { - name: "MintGovernorInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mint"; - type: "publicKey"; - index: false; - }, - { - name: "admin"; - type: "publicKey"; - index: false; - }, - { - name: "createKey"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - ]; - }, - { - name: "MintAuthorityTransferredEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mint"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MintAuthorityAddedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mintAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "authorizedMinter"; - type: "publicKey"; - index: false; - }, - { - name: "maxTotal"; - type: { - option: "u64"; - }; - index: false; - }, - ]; - }, - { - name: "TokensMintedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mint"; - type: "publicKey"; - index: false; - }, - { - name: "authorizedMinter"; - type: "publicKey"; - index: false; - }, - { - name: "destinationAta"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "postTotalMinted"; - type: "u64"; - index: false; - }, - { - name: "postMintSupply"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "MintAuthorityUpdatedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mintAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "authorizedMinter"; - type: "publicKey"; - index: false; - }, - { - name: "maxTotal"; - type: { - option: "u64"; - }; - index: false; - }, - ]; - }, - { - name: "MintAuthorityRemovedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "authorizedMinter"; - type: "publicKey"; - index: false; - }, - { - name: "totalMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "MintGovernorAdminUpdatedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "newAdmin"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "MintAuthorityReclaimedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mint"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnauthorizedAdmin"; - msg: "Unauthorized: signer is not the admin"; - }, - { - code: 6001; - name: "UnauthorizedMinter"; - msg: "Unauthorized: signer is not the authorized minter"; - }, - { - code: 6002; - name: "MintMismatch"; - msg: "Mint mismatch: mint_governor.mint does not match provided mint"; - }, - { - code: 6003; - name: "MintLimitExceeded"; - msg: "Mint limit exceeded: would exceed max_total"; - }, - ]; -}; - -export const IDL: MintGovernor = { - version: "0.7.0", - name: "mint_governor", - instructions: [ - { - name: "initializeMintGovernor", - accounts: [ - { - name: "mint", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - }, - { - name: "admin", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "transferAuthorityToGovernor", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mint", - isMut: true, - isSigner: false, - }, - { - name: "currentAuthority", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "addMintAuthority", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "authorizedMinter", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "AddMintAuthorityArgs", - }, - }, - ], - }, - { - name: "mintTokens", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "mint", - isMut: true, - isSigner: false, - }, - { - name: "destinationAta", - isMut: true, - isSigner: false, - }, - { - name: "authorizedMinter", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "MintTokensArgs", - }, - }, - ], - }, - { - name: "updateMintAuthority", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "UpdateMintAuthorityArgs", - }, - }, - ], - }, - { - name: "removeMintAuthority", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "rentDestination", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "updateMintGovernorAdmin", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "newAdmin", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "reclaimAuthority", - accounts: [ - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mint", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "newAuthority", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "mintAuthority", - type: { - kind: "struct", - fields: [ - { - name: "mintGovernor", - type: "publicKey", - }, - { - name: "authorizedMinter", - type: "publicKey", - }, - { - name: "maxTotal", - type: { - option: "u64", - }, - }, - { - name: "totalMinted", - type: "u64", - }, - { - name: "bump", - type: "u8", - }, - ], - }, - }, - { - name: "mintGovernor", - type: { - kind: "struct", - fields: [ - { - name: "mint", - type: "publicKey", - }, - { - name: "admin", - type: "publicKey", - }, - { - name: "createKey", - type: "publicKey", - }, - { - name: "seqNum", - type: "u64", - }, - { - name: "bump", - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "mintGovernorSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "AddMintAuthorityArgs", - type: { - kind: "struct", - fields: [ - { - name: "maxTotal", - type: { - option: "u64", - }, - }, - ], - }, - }, - { - name: "MintTokensArgs", - type: { - kind: "struct", - fields: [ - { - name: "amount", - type: "u64", - }, - ], - }, - }, - { - name: "UpdateMintAuthorityArgs", - type: { - kind: "struct", - fields: [ - { - name: "maxTotal", - type: { - option: "u64", - }, - }, - ], - }, - }, - ], - events: [ - { - name: "MintGovernorInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mint", - type: "publicKey", - index: false, - }, - { - name: "admin", - type: "publicKey", - index: false, - }, - { - name: "createKey", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - ], - }, - { - name: "MintAuthorityTransferredEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mint", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MintAuthorityAddedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mintAuthority", - type: "publicKey", - index: false, - }, - { - name: "authorizedMinter", - type: "publicKey", - index: false, - }, - { - name: "maxTotal", - type: { - option: "u64", - }, - index: false, - }, - ], - }, - { - name: "TokensMintedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mint", - type: "publicKey", - index: false, - }, - { - name: "authorizedMinter", - type: "publicKey", - index: false, - }, - { - name: "destinationAta", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "postTotalMinted", - type: "u64", - index: false, - }, - { - name: "postMintSupply", - type: "u64", - index: false, - }, - ], - }, - { - name: "MintAuthorityUpdatedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mintAuthority", - type: "publicKey", - index: false, - }, - { - name: "authorizedMinter", - type: "publicKey", - index: false, - }, - { - name: "maxTotal", - type: { - option: "u64", - }, - index: false, - }, - ], - }, - { - name: "MintAuthorityRemovedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "authorizedMinter", - type: "publicKey", - index: false, - }, - { - name: "totalMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "MintGovernorAdminUpdatedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "newAdmin", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "MintAuthorityReclaimedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mint", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnauthorizedAdmin", - msg: "Unauthorized: signer is not the admin", - }, - { - code: 6001, - name: "UnauthorizedMinter", - msg: "Unauthorized: signer is not the authorized minter", - }, - { - code: 6002, - name: "MintMismatch", - msg: "Mint mismatch: mint_governor.mint does not match provided mint", - }, - { - code: 6003, - name: "MintLimitExceeded", - msg: "Mint limit exceeded: would exceed max_total", - }, - ], -}; diff --git a/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts b/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts deleted file mode 100644 index 0956ed645..000000000 --- a/sdk2/src/performance_package_v2/v0.7/types/performance_package_v2.ts +++ /dev/null @@ -1,2139 +0,0 @@ -export type PerformancePackageV2 = { - version: "0.7.0"; - name: "performance_package_v2"; - constants: [ - { - name: "MAX_TRANCHES"; - type: { - defined: "usize"; - }; - value: "10"; - }, - { - name: "MAX_MIN_DURATION"; - type: "u32"; - value: "60 * 60 * 24 * 365"; - }, - ]; - instructions: [ - { - name: "initializePerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "mint"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernor"; - isMut: false; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - }, - { - name: "authority"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializePerformancePackageArgs"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "signer"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "mint"; - isMut: true; - isSigner: false; - }, - { - name: "recipientAta"; - isMut: true; - isSigner: false; - }, - { - name: "signer"; - isMut: false; - isSigner: true; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "changeAuthority"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "authority"; - isMut: false; - isSigner: true; - docs: ["Must be the current authority of the performance package"]; - }, - { - name: "newAuthority"; - isMut: false; - isSigner: false; - docs: ["The new authority address"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "proposeChange"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ProposeChangeArgs"; - }; - }, - ]; - }, - { - name: "executeChange"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "executor"; - isMut: false; - isSigner: true; - }, - { - name: "rentDestination"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "closePerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "rentDestination"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "changeRequest"; - docs: [ - "Temporary account for two-party approval flow.", - 'Seeds: `["change_request", performance_package, proposer, pda_nonce.to_le_bytes()]`', - ]; - type: { - kind: "struct"; - fields: [ - { - name: "performancePackage"; - docs: ["The performance package this change applies to"]; - type: "publicKey"; - }, - { - name: "proposer"; - docs: ["The proposer's pubkey at proposal time"]; - type: "publicKey"; - }, - { - name: "ppCreatedAtTimestamp"; - docs: [ - "PP's created_at_timestamp at proposal time; used to detect stale CRs after close/recreate", - ]; - type: "i64"; - }, - { - name: "proposedAt"; - docs: ["When the change was proposed"]; - type: "i64"; - }, - { - name: "pdaNonce"; - docs: [ - "For unique PDA derivation (allows multiple concurrent proposals)", - ]; - type: "u32"; - }, - { - name: "bump"; - type: "u8"; - }, - { - name: "newRecipient"; - docs: ["New recipient address (if changing)"]; - type: { - option: "publicKey"; - }; - }, - { - name: "newOracleReader"; - docs: ["New oracle configuration (if changing)"]; - type: { - option: { - defined: "OracleReader"; - }; - }; - }, - { - name: "newRewardFunction"; - docs: ["New reward function (if changing)"]; - type: { - option: { - defined: "RewardFunction"; - }; - }; - }, - ]; - }; - }, - { - name: "performancePackage"; - docs: [ - "The main account representing a performance package.", - "Acts as the `authorized_minter` in mint_governor.", - 'Seeds: `["performance_package", create_key]`', - ]; - type: { - kind: "struct"; - fields: [ - { - name: "mint"; - docs: ["Token mint controlled by mint_governor"]; - type: "publicKey"; - }, - { - name: "mintGovernor"; - docs: ["MintGovernor account"]; - type: "publicKey"; - }, - { - name: "mintAuthority"; - docs: ["MintAuthority PDA for this PP"]; - type: "publicKey"; - }, - { - name: "authority"; - docs: ["Usually the DAO multisig vault - can modify PP"]; - type: "publicKey"; - }, - { - name: "recipient"; - docs: ["Usually the team multisig - receives minted tokens"]; - type: "publicKey"; - }, - { - name: "oracleReader"; - docs: ["Stores start/end snapshots for oracle calculations"]; - type: { - defined: "OracleReader"; - }; - }, - { - name: "rewardFunction"; - docs: ["How to calculate rewards"]; - type: { - defined: "RewardFunction"; - }; - }, - { - name: "status"; - docs: ["Locked or Unlocking state"]; - type: { - defined: "PackageStatus"; - }; - }, - { - name: "minUnlockTimestamp"; - docs: ["Can't start unlock before this time"]; - type: "i64"; - }, - { - name: "createdAtTimestamp"; - docs: [ - "Timestamp when this PP was created; used to invalidate stale ChangeRequests", - ]; - type: "i64"; - }, - { - name: "totalRewardsPaidOut"; - docs: ["Cumulative tokens minted to the recipient"]; - type: "u64"; - }, - { - name: "seqNum"; - docs: ["Event sequence number"]; - type: "u64"; - }, - { - name: "createKey"; - docs: ["Used for PDA derivation"]; - type: "publicKey"; - }, - { - name: "bump"; - docs: ["PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - docs: ["Common fields included in all events for consistent metadata."]; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "performancePackageSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "InitializePerformancePackageArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "oracleReader"; - type: { - defined: "OracleReader"; - }; - }, - { - name: "rewardFunction"; - type: { - defined: "RewardFunction"; - }; - }, - { - name: "minUnlockTimestamp"; - type: "i64"; - }, - ]; - }; - }, - { - name: "ProposeChangeArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaNonce"; - type: "u32"; - }, - { - name: "newRecipient"; - type: { - option: "publicKey"; - }; - }, - { - name: "newOracleReader"; - type: { - option: { - defined: "OracleReader"; - }; - }; - }, - { - name: "newRewardFunction"; - type: { - option: { - defined: "RewardFunction"; - }; - }; - }, - ]; - }; - }, - { - name: "ThresholdTranche"; - docs: ["A threshold tranche for step-based rewards."]; - type: { - kind: "struct"; - fields: [ - { - name: "threshold"; - docs: ["Oracle value threshold"]; - type: "u128"; - }, - { - name: "cumulativeAmount"; - docs: [ - "Total tokens at this tranche (cumulative, not incremental)", - ]; - type: "u64"; - }, - ]; - }; - }, - { - name: "PackageStatus"; - docs: ["Lifecycle state for the performance package."]; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - }, - ]; - }; - }, - { - name: "OracleReader"; - docs: [ - "Oracle reader that knows how to read from an external oracle account.", - "Extracts a `value: u128` for reward calculations.", - ]; - type: { - kind: "enum"; - variants: [ - { - name: "Time"; - }, - { - name: "FutarchyTwap"; - fields: [ - { - name: "amm"; - docs: [ - "The Futarchy DAO account to read (contains embedded AMM)", - ]; - type: "publicKey"; - }, - { - name: "minDuration"; - docs: ["Minimum seconds between start and end"]; - type: "u32"; - }, - { - name: "startValue"; - docs: ["Start snapshot (recorded on start_unlock)"]; - type: "u128"; - }, - { - name: "startTime"; - type: "i64"; - }, - { - name: "endValue"; - docs: ["End snapshot (recorded on complete_unlock)"]; - type: "u128"; - }, - { - name: "endTime"; - type: "i64"; - }, - ]; - }, - ]; - }; - }, - { - name: "RewardFunction"; - docs: [ - "Reward function that calculates cumulative rewards from oracle values.", - "Returns total tokens deserved so far (not incremental).", - ]; - type: { - kind: "enum"; - variants: [ - { - name: "CliffLinear"; - fields: [ - { - name: "cliffValue"; - type: "u128"; - }, - { - name: "endValue"; - type: "u128"; - }, - { - name: "cliffAmount"; - type: "u64"; - }, - { - name: "totalAmount"; - docs: ["Total amount including cliff"]; - type: "u64"; - }, - ]; - }, - { - name: "Threshold"; - fields: [ - { - name: "tranches"; - docs: ["Must be sorted by threshold ascending"]; - type: { - vec: { - defined: "ThresholdTranche"; - }; - }; - }, - ]; - }, - ]; - }; - }, - ]; - events: [ - { - name: "PerformancePackageCreatedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "mint"; - type: "publicKey"; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "authority"; - type: "publicKey"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "createKey"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - ]; - }, - { - name: "UnlockStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "startTime"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompletedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "oracleValue"; - type: "u128"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "amountMinted"; - type: "u64"; - index: false; - }, - { - name: "totalRewardsPaidOut"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "AuthorityChangedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "ChangeProposedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "pdaNonce"; - type: "u32"; - index: false; - }, - { - name: "newRecipient"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "newOracleReader"; - type: { - option: { - defined: "OracleReader"; - }; - }; - index: false; - }, - { - name: "newRewardFunction"; - type: { - option: { - defined: "RewardFunction"; - }; - }; - index: false; - }, - ]; - }, - { - name: "ChangeExecutedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "executedBy"; - type: "publicKey"; - index: false; - }, - { - name: "newRecipient"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "newOracleReader"; - type: { - option: { - defined: "OracleReader"; - }; - }; - index: false; - }, - { - name: "newRewardFunction"; - type: { - option: { - defined: "RewardFunction"; - }; - }; - index: false; - }, - ]; - }, - { - name: "PerformancePackageClosedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "totalRewardsPaidOut"; - type: "u64"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "Unauthorized"; - msg: "Signer is neither authority nor recipient"; - }, - { - code: 6001; - name: "InvalidExecutor"; - msg: "Executor is not the opposite party from proposer"; - }, - { - code: 6002; - name: "InvalidAuthority"; - msg: "Signer is not the current authority"; - }, - { - code: 6003; - name: "InvalidAdmin"; - msg: "Signer is not the admin"; - }, - { - code: 6004; - name: "InvalidMintGovernor"; - msg: "Mint governor does not match the provided mint"; - }, - { - code: 6005; - name: "InvalidMintAuthority"; - msg: "Mint authority does not match expected configuration"; - }, - { - code: 6006; - name: "NotLocked"; - msg: "Expected Locked status"; - }, - { - code: 6007; - name: "NotUnlocking"; - msg: "Expected Unlocking status"; - }, - { - code: 6008; - name: "OracleMissingAccount"; - msg: "Expected remaining_accounts not provided"; - }, - { - code: 6009; - name: "OracleInvalidAccount"; - msg: "Account pubkey doesn't match expected"; - }, - { - code: 6010; - name: "OracleParseError"; - msg: "Failed to parse account data"; - }, - { - code: 6011; - name: "OracleInvalidState"; - msg: "Oracle state invalid"; - }, - { - code: 6012; - name: "OracleMinDurationNotReached"; - msg: "Minimum duration hasn't passed yet"; - }, - { - code: 6013; - name: "UnlockTimestampNotReached"; - msg: "Minimum unlock timestamp not yet reached"; - }, - { - code: 6014; - name: "RewardCalculationOverflow"; - msg: "Math overflow in reward function"; - }, - { - code: 6015; - name: "InvalidTranches"; - msg: "Tranches should be sorted and non-empty"; - }, - { - code: 6016; - name: "InvalidVestingSchedule"; - msg: "Invalid vesting schedule configuration"; - }, - { - code: 6017; - name: "ChangeRequestNotFound"; - msg: "Missing proposal for execute"; - }, - { - code: 6018; - name: "NoChangesProposed"; - msg: "All optional change fields are None"; - }, - { - code: 6019; - name: "MinDurationTooLarge"; - msg: "min_duration exceeds maximum allowed (365 days)"; - }, - { - code: 6020; - name: "StaleChangeRequest"; - msg: "Change request is stale: PP was recreated or the proposing party has changed"; - }, - ]; -}; - -export const IDL: PerformancePackageV2 = { - version: "0.7.0", - name: "performance_package_v2", - constants: [ - { - name: "MAX_TRANCHES", - type: { - defined: "usize", - }, - value: "10", - }, - { - name: "MAX_MIN_DURATION", - type: "u32", - value: "60 * 60 * 24 * 365", - }, - ], - instructions: [ - { - name: "initializePerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "mint", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernor", - isMut: false, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: false, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - }, - { - name: "authority", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializePerformancePackageArgs", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "signer", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "mint", - isMut: true, - isSigner: false, - }, - { - name: "recipientAta", - isMut: true, - isSigner: false, - }, - { - name: "signer", - isMut: false, - isSigner: true, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "changeAuthority", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "authority", - isMut: false, - isSigner: true, - docs: ["Must be the current authority of the performance package"], - }, - { - name: "newAuthority", - isMut: false, - isSigner: false, - docs: ["The new authority address"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "proposeChange", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ProposeChangeArgs", - }, - }, - ], - }, - { - name: "executeChange", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "executor", - isMut: false, - isSigner: true, - }, - { - name: "rentDestination", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "closePerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "rentDestination", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "changeRequest", - docs: [ - "Temporary account for two-party approval flow.", - 'Seeds: `["change_request", performance_package, proposer, pda_nonce.to_le_bytes()]`', - ], - type: { - kind: "struct", - fields: [ - { - name: "performancePackage", - docs: ["The performance package this change applies to"], - type: "publicKey", - }, - { - name: "proposer", - docs: ["The proposer's pubkey at proposal time"], - type: "publicKey", - }, - { - name: "ppCreatedAtTimestamp", - docs: [ - "PP's created_at_timestamp at proposal time; used to detect stale CRs after close/recreate", - ], - type: "i64", - }, - { - name: "proposedAt", - docs: ["When the change was proposed"], - type: "i64", - }, - { - name: "pdaNonce", - docs: [ - "For unique PDA derivation (allows multiple concurrent proposals)", - ], - type: "u32", - }, - { - name: "bump", - type: "u8", - }, - { - name: "newRecipient", - docs: ["New recipient address (if changing)"], - type: { - option: "publicKey", - }, - }, - { - name: "newOracleReader", - docs: ["New oracle configuration (if changing)"], - type: { - option: { - defined: "OracleReader", - }, - }, - }, - { - name: "newRewardFunction", - docs: ["New reward function (if changing)"], - type: { - option: { - defined: "RewardFunction", - }, - }, - }, - ], - }, - }, - { - name: "performancePackage", - docs: [ - "The main account representing a performance package.", - "Acts as the `authorized_minter` in mint_governor.", - 'Seeds: `["performance_package", create_key]`', - ], - type: { - kind: "struct", - fields: [ - { - name: "mint", - docs: ["Token mint controlled by mint_governor"], - type: "publicKey", - }, - { - name: "mintGovernor", - docs: ["MintGovernor account"], - type: "publicKey", - }, - { - name: "mintAuthority", - docs: ["MintAuthority PDA for this PP"], - type: "publicKey", - }, - { - name: "authority", - docs: ["Usually the DAO multisig vault - can modify PP"], - type: "publicKey", - }, - { - name: "recipient", - docs: ["Usually the team multisig - receives minted tokens"], - type: "publicKey", - }, - { - name: "oracleReader", - docs: ["Stores start/end snapshots for oracle calculations"], - type: { - defined: "OracleReader", - }, - }, - { - name: "rewardFunction", - docs: ["How to calculate rewards"], - type: { - defined: "RewardFunction", - }, - }, - { - name: "status", - docs: ["Locked or Unlocking state"], - type: { - defined: "PackageStatus", - }, - }, - { - name: "minUnlockTimestamp", - docs: ["Can't start unlock before this time"], - type: "i64", - }, - { - name: "createdAtTimestamp", - docs: [ - "Timestamp when this PP was created; used to invalidate stale ChangeRequests", - ], - type: "i64", - }, - { - name: "totalRewardsPaidOut", - docs: ["Cumulative tokens minted to the recipient"], - type: "u64", - }, - { - name: "seqNum", - docs: ["Event sequence number"], - type: "u64", - }, - { - name: "createKey", - docs: ["Used for PDA derivation"], - type: "publicKey", - }, - { - name: "bump", - docs: ["PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - docs: ["Common fields included in all events for consistent metadata."], - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "performancePackageSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "InitializePerformancePackageArgs", - type: { - kind: "struct", - fields: [ - { - name: "oracleReader", - type: { - defined: "OracleReader", - }, - }, - { - name: "rewardFunction", - type: { - defined: "RewardFunction", - }, - }, - { - name: "minUnlockTimestamp", - type: "i64", - }, - ], - }, - }, - { - name: "ProposeChangeArgs", - type: { - kind: "struct", - fields: [ - { - name: "pdaNonce", - type: "u32", - }, - { - name: "newRecipient", - type: { - option: "publicKey", - }, - }, - { - name: "newOracleReader", - type: { - option: { - defined: "OracleReader", - }, - }, - }, - { - name: "newRewardFunction", - type: { - option: { - defined: "RewardFunction", - }, - }, - }, - ], - }, - }, - { - name: "ThresholdTranche", - docs: ["A threshold tranche for step-based rewards."], - type: { - kind: "struct", - fields: [ - { - name: "threshold", - docs: ["Oracle value threshold"], - type: "u128", - }, - { - name: "cumulativeAmount", - docs: [ - "Total tokens at this tranche (cumulative, not incremental)", - ], - type: "u64", - }, - ], - }, - }, - { - name: "PackageStatus", - docs: ["Lifecycle state for the performance package."], - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - }, - ], - }, - }, - { - name: "OracleReader", - docs: [ - "Oracle reader that knows how to read from an external oracle account.", - "Extracts a `value: u128` for reward calculations.", - ], - type: { - kind: "enum", - variants: [ - { - name: "Time", - }, - { - name: "FutarchyTwap", - fields: [ - { - name: "amm", - docs: [ - "The Futarchy DAO account to read (contains embedded AMM)", - ], - type: "publicKey", - }, - { - name: "minDuration", - docs: ["Minimum seconds between start and end"], - type: "u32", - }, - { - name: "startValue", - docs: ["Start snapshot (recorded on start_unlock)"], - type: "u128", - }, - { - name: "startTime", - type: "i64", - }, - { - name: "endValue", - docs: ["End snapshot (recorded on complete_unlock)"], - type: "u128", - }, - { - name: "endTime", - type: "i64", - }, - ], - }, - ], - }, - }, - { - name: "RewardFunction", - docs: [ - "Reward function that calculates cumulative rewards from oracle values.", - "Returns total tokens deserved so far (not incremental).", - ], - type: { - kind: "enum", - variants: [ - { - name: "CliffLinear", - fields: [ - { - name: "cliffValue", - type: "u128", - }, - { - name: "endValue", - type: "u128", - }, - { - name: "cliffAmount", - type: "u64", - }, - { - name: "totalAmount", - docs: ["Total amount including cliff"], - type: "u64", - }, - ], - }, - { - name: "Threshold", - fields: [ - { - name: "tranches", - docs: ["Must be sorted by threshold ascending"], - type: { - vec: { - defined: "ThresholdTranche", - }, - }, - }, - ], - }, - ], - }, - }, - ], - events: [ - { - name: "PerformancePackageCreatedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "mint", - type: "publicKey", - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "authority", - type: "publicKey", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "createKey", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - ], - }, - { - name: "UnlockStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "startTime", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompletedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "oracleValue", - type: "u128", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "amountMinted", - type: "u64", - index: false, - }, - { - name: "totalRewardsPaidOut", - type: "u64", - index: false, - }, - ], - }, - { - name: "AuthorityChangedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "ChangeProposedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "pdaNonce", - type: "u32", - index: false, - }, - { - name: "newRecipient", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "newOracleReader", - type: { - option: { - defined: "OracleReader", - }, - }, - index: false, - }, - { - name: "newRewardFunction", - type: { - option: { - defined: "RewardFunction", - }, - }, - index: false, - }, - ], - }, - { - name: "ChangeExecutedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "executedBy", - type: "publicKey", - index: false, - }, - { - name: "newRecipient", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "newOracleReader", - type: { - option: { - defined: "OracleReader", - }, - }, - index: false, - }, - { - name: "newRewardFunction", - type: { - option: { - defined: "RewardFunction", - }, - }, - index: false, - }, - ], - }, - { - name: "PerformancePackageClosedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "totalRewardsPaidOut", - type: "u64", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "Unauthorized", - msg: "Signer is neither authority nor recipient", - }, - { - code: 6001, - name: "InvalidExecutor", - msg: "Executor is not the opposite party from proposer", - }, - { - code: 6002, - name: "InvalidAuthority", - msg: "Signer is not the current authority", - }, - { - code: 6003, - name: "InvalidAdmin", - msg: "Signer is not the admin", - }, - { - code: 6004, - name: "InvalidMintGovernor", - msg: "Mint governor does not match the provided mint", - }, - { - code: 6005, - name: "InvalidMintAuthority", - msg: "Mint authority does not match expected configuration", - }, - { - code: 6006, - name: "NotLocked", - msg: "Expected Locked status", - }, - { - code: 6007, - name: "NotUnlocking", - msg: "Expected Unlocking status", - }, - { - code: 6008, - name: "OracleMissingAccount", - msg: "Expected remaining_accounts not provided", - }, - { - code: 6009, - name: "OracleInvalidAccount", - msg: "Account pubkey doesn't match expected", - }, - { - code: 6010, - name: "OracleParseError", - msg: "Failed to parse account data", - }, - { - code: 6011, - name: "OracleInvalidState", - msg: "Oracle state invalid", - }, - { - code: 6012, - name: "OracleMinDurationNotReached", - msg: "Minimum duration hasn't passed yet", - }, - { - code: 6013, - name: "UnlockTimestampNotReached", - msg: "Minimum unlock timestamp not yet reached", - }, - { - code: 6014, - name: "RewardCalculationOverflow", - msg: "Math overflow in reward function", - }, - { - code: 6015, - name: "InvalidTranches", - msg: "Tranches should be sorted and non-empty", - }, - { - code: 6016, - name: "InvalidVestingSchedule", - msg: "Invalid vesting schedule configuration", - }, - { - code: 6017, - name: "ChangeRequestNotFound", - msg: "Missing proposal for execute", - }, - { - code: 6018, - name: "NoChangesProposed", - msg: "All optional change fields are None", - }, - { - code: 6019, - name: "MinDurationTooLarge", - msg: "min_duration exceeds maximum allowed (365 days)", - }, - { - code: 6020, - name: "StaleChangeRequest", - msg: "Change request is stale: PP was recreated or the proposing party has changed", - }, - ], -}; diff --git a/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts b/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts deleted file mode 100644 index 16224ab94..000000000 --- a/sdk2/src/price_based_performance_package/v0.6/types/price_based_performance_package.ts +++ /dev/null @@ -1,1941 +0,0 @@ -export type PriceBasedPerformancePackage = { - version: "0.6.0"; - name: "price_based_performance_package"; - constants: [ - { - name: "MAX_TRANCHES"; - type: { - defined: "usize"; - }; - value: "10"; - }, - ]; - instructions: [ - { - name: "initializePerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "createKey"; - isMut: false; - isSigner: true; - docs: ["Used to derive the PDA"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The mint of the tokens to be locked"]; - }, - { - name: "grantorTokenAccount"; - isMut: true; - isSigner: false; - docs: ["The token account containing the tokens to be locked"]; - }, - { - name: "grantor"; - isMut: false; - isSigner: true; - docs: ["The authority of the token account"]; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - docs: ["The locker's token account where tokens will be stored"]; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "InitializePerformancePackageParams"; - }; - }, - ]; - }, - { - name: "startUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "recipient"; - isMut: false; - isSigner: true; - docs: ["Only the token recipient can start unlock"]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "completeUnlock"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "oracleAccount"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - docs: ["The token account where locked tokens are stored"]; - }, - { - name: "tokenMint"; - isMut: false; - isSigner: false; - docs: ["The token mint - validated via has_one constraint on locker"]; - }, - { - name: "recipientTokenAccount"; - isMut: true; - isSigner: false; - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ]; - }, - { - name: "tokenRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - docs: ["Payer for creating the ATA if needed"]; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "proposeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "proposer"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ProposeChangeParams"; - }; - }, - ]; - }, - { - name: "executeChange"; - accounts: [ - { - name: "changeRequest"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "executor"; - isMut: true; - isSigner: true; - docs: [ - "The party executing the change (must be opposite of proposer)", - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "changePerformancePackageAuthority"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "currentAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "params"; - type: { - defined: "ChangePerformancePackageAuthorityParams"; - }; - }, - ]; - }, - { - name: "burnPerformancePackage"; - accounts: [ - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackageTokenVault"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: true; - isSigner: true; - }, - { - name: "spillAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: "performancePackage"; - type: { - kind: "struct"; - fields: [ - { - name: "tranches"; - docs: ["The tranches that make up the performance package"]; - type: { - vec: { - defined: "StoredTranche"; - }; - }; - }, - { - name: "totalTokenAmount"; - docs: ["Total amount of tokens in the performance package"]; - type: "u64"; - }, - { - name: "alreadyUnlockedAmount"; - docs: ["Amount of tokens already unlocked"]; - type: "u64"; - }, - { - name: "minUnlockTimestamp"; - docs: ["The timestamp when unlocking can begin"]; - type: "i64"; - }, - { - name: "oracleConfig"; - docs: ["Where to pull price data from"]; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - docs: [ - "Length of time in seconds for TWAP calculation, between 1 day and 1 year", - ]; - type: "u32"; - }, - { - name: "recipient"; - docs: ["The recipient of the tokens when unlocked"]; - type: "publicKey"; - }, - { - name: "state"; - docs: ["The current state of the locker"]; - type: { - defined: "PerformancePackageState"; - }; - }, - { - name: "createKey"; - docs: ["Used to derive the PDA"]; - type: "publicKey"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - { - name: "performancePackageAuthority"; - docs: [ - "The authorized locker authority that can execute changes, usually the organization", - ]; - type: "publicKey"; - }, - { - name: "tokenMint"; - docs: ["The mint of the locked tokens"]; - type: "publicKey"; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of the performance package, used for indexing events", - ]; - type: "u64"; - }, - { - name: "performancePackageTokenVault"; - docs: ["The vault that stores the tokens"]; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "changeRequest"; - type: { - kind: "struct"; - fields: [ - { - name: "performancePackage"; - docs: ["The performance package this change applies to"]; - type: "publicKey"; - }, - { - name: "changeType"; - docs: ["What is being changed"]; - type: { - defined: "ChangeType"; - }; - }, - { - name: "proposedAt"; - docs: ["When the change was proposed"]; - type: "i64"; - }, - { - name: "proposerType"; - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ]; - type: { - defined: "ProposerType"; - }; - }, - { - name: "pdaNonce"; - docs: ["Used to derive the PDA along with the proposer"]; - type: "u32"; - }, - { - name: "pdaBump"; - docs: ["The PDA bump"]; - type: "u8"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "performancePackageSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ChangePerformancePackageAuthorityParams"; - type: { - kind: "struct"; - fields: [ - { - name: "newPerformancePackageAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "InitializePerformancePackageParams"; - type: { - kind: "struct"; - fields: [ - { - name: "tranches"; - type: { - vec: { - defined: "Tranche"; - }; - }; - }, - { - name: "minUnlockTimestamp"; - type: "i64"; - }, - { - name: "oracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - { - name: "twapLengthSeconds"; - type: "u32"; - }, - { - name: "grantee"; - type: "publicKey"; - }, - { - name: "performancePackageAuthority"; - type: "publicKey"; - }, - ]; - }; - }, - { - name: "ProposeChangeParams"; - type: { - kind: "struct"; - fields: [ - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - }, - { - name: "pdaNonce"; - type: "u32"; - }, - ]; - }; - }, - { - name: "OracleConfig"; - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ]; - type: { - kind: "struct"; - fields: [ - { - name: "oracleAccount"; - type: "publicKey"; - }, - { - name: "byteOffset"; - type: "u32"; - }, - ]; - }; - }, - { - name: "Tranche"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - docs: ["The price at which this tranch unlocks"]; - type: "u128"; - }, - { - name: "tokenAmount"; - docs: ["The amount of tokens in this tranch"]; - type: "u64"; - }, - ]; - }; - }, - { - name: "StoredTranche"; - type: { - kind: "struct"; - fields: [ - { - name: "priceThreshold"; - type: "u128"; - }, - { - name: "tokenAmount"; - type: "u64"; - }, - { - name: "isUnlocked"; - type: "bool"; - }, - ]; - }; - }, - { - name: "PerformancePackageState"; - type: { - kind: "enum"; - variants: [ - { - name: "Locked"; - }, - { - name: "Unlocking"; - fields: [ - { - name: "startAggregator"; - docs: ["The aggregator value when unlocking started"]; - type: "u128"; - }, - { - name: "startTimestamp"; - docs: ["The timestamp when unlocking started"]; - type: "i64"; - }, - ]; - }, - ]; - }; - }, - { - name: "ChangeType"; - type: { - kind: "enum"; - variants: [ - { - name: "Oracle"; - fields: [ - { - name: "newOracleConfig"; - type: { - defined: "OracleConfig"; - }; - }, - ]; - }, - { - name: "Recipient"; - fields: [ - { - name: "newRecipient"; - type: "publicKey"; - }, - ]; - }, - ]; - }; - }, - { - name: "ProposerType"; - type: { - kind: "enum"; - variants: [ - { - name: "Recipient"; - }, - { - name: "Authority"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "PerformancePackageInitialized"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "UnlockStarted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "startAggregator"; - type: "u128"; - index: false; - }, - { - name: "startTimestamp"; - type: "i64"; - index: false; - }, - ]; - }, - { - name: "UnlockCompleted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "recipient"; - type: "publicKey"; - index: false; - }, - { - name: "twapPrice"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "ChangeProposed"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "proposer"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - ]; - }, - { - name: "ChangeExecuted"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "changeRequest"; - type: "publicKey"; - index: false; - }, - { - name: "executor"; - type: "publicKey"; - index: false; - }, - { - name: "changeType"; - type: { - defined: "ChangeType"; - }; - index: false; - }, - ]; - }, - { - name: "PerformancePackageAuthorityChanged"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "locker"; - type: "publicKey"; - index: false; - }, - { - name: "oldAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "newAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "UnlockTimestampNotReached"; - msg: "Unlock timestamp has not been reached yet"; - }, - { - code: 6001; - name: "UnlockTimestampInThePast"; - msg: "Unlock timestamp must be in the future"; - }, - { - code: 6002; - name: "InvalidPerformancePackageState"; - msg: "Performance package is not in the expected state"; - }, - { - code: 6003; - name: "TwapPeriodNotElapsed"; - msg: "TWAP calculation failed"; - }, - { - code: 6004; - name: "PriceThresholdNotMet"; - msg: "Price threshold not met"; - }, - { - code: 6005; - name: "InvalidOracleData"; - msg: "Invalid oracle account data"; - }, - { - code: 6006; - name: "UnauthorizedChangeRequest"; - msg: "Unauthorized to create or execute change request"; - }, - { - code: 6007; - name: "InvalidChangeRequest"; - msg: "Change request does not match locker"; - }, - { - code: 6008; - name: "UnauthorizedLockerAuthority"; - msg: "Unauthorized locker authority"; - }, - { - code: 6009; - name: "InvariantViolated"; - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this"; - }, - { - code: 6010; - name: "TranchePriceThresholdsNotMonotonic"; - msg: "Tranche price thresholds must be monotonically increasing"; - }, - { - code: 6011; - name: "TrancheTokenAmountZero"; - msg: "Tranche token amount must be greater than 0"; - }, - { - code: 6012; - name: "InvalidTwapLength"; - msg: "TWAP length must be greater than or equal to 1 day and less than 1 year"; - }, - { - code: 6013; - name: "InvalidAdmin"; - msg: "Invalid admin"; - }, - { - code: 6014; - name: "TotalTokenAmountOverflow"; - msg: "Total token amount calculation would overflow"; - }, - { - code: 6015; - name: "RecipientAuthorityMustDiffer"; - msg: "Recipient and performance package authority must be different keys"; - }, - ]; -}; - -export const IDL: PriceBasedPerformancePackage = { - version: "0.6.0", - name: "price_based_performance_package", - constants: [ - { - name: "MAX_TRANCHES", - type: { - defined: "usize", - }, - value: "10", - }, - ], - instructions: [ - { - name: "initializePerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "createKey", - isMut: false, - isSigner: true, - docs: ["Used to derive the PDA"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The mint of the tokens to be locked"], - }, - { - name: "grantorTokenAccount", - isMut: true, - isSigner: false, - docs: ["The token account containing the tokens to be locked"], - }, - { - name: "grantor", - isMut: false, - isSigner: true, - docs: ["The authority of the token account"], - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - docs: ["The locker's token account where tokens will be stored"], - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "InitializePerformancePackageParams", - }, - }, - ], - }, - { - name: "startUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "recipient", - isMut: false, - isSigner: true, - docs: ["Only the token recipient can start unlock"], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "completeUnlock", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "oracleAccount", - isMut: false, - isSigner: false, - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - docs: ["The token account where locked tokens are stored"], - }, - { - name: "tokenMint", - isMut: false, - isSigner: false, - docs: ["The token mint - validated via has_one constraint on locker"], - }, - { - name: "recipientTokenAccount", - isMut: true, - isSigner: false, - docs: [ - "The recipient's ATA where tokens will be sent - created if needed", - ], - }, - { - name: "tokenRecipient", - isMut: false, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - docs: ["Payer for creating the ATA if needed"], - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "proposeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "proposer", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ProposeChangeParams", - }, - }, - ], - }, - { - name: "executeChange", - accounts: [ - { - name: "changeRequest", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "executor", - isMut: true, - isSigner: true, - docs: [ - "The party executing the change (must be opposite of proposer)", - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "changePerformancePackageAuthority", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "currentAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "params", - type: { - defined: "ChangePerformancePackageAuthorityParams", - }, - }, - ], - }, - { - name: "burnPerformancePackage", - accounts: [ - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "performancePackageTokenVault", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: true, - isSigner: true, - }, - { - name: "spillAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - ], - accounts: [ - { - name: "performancePackage", - type: { - kind: "struct", - fields: [ - { - name: "tranches", - docs: ["The tranches that make up the performance package"], - type: { - vec: { - defined: "StoredTranche", - }, - }, - }, - { - name: "totalTokenAmount", - docs: ["Total amount of tokens in the performance package"], - type: "u64", - }, - { - name: "alreadyUnlockedAmount", - docs: ["Amount of tokens already unlocked"], - type: "u64", - }, - { - name: "minUnlockTimestamp", - docs: ["The timestamp when unlocking can begin"], - type: "i64", - }, - { - name: "oracleConfig", - docs: ["Where to pull price data from"], - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - docs: [ - "Length of time in seconds for TWAP calculation, between 1 day and 1 year", - ], - type: "u32", - }, - { - name: "recipient", - docs: ["The recipient of the tokens when unlocked"], - type: "publicKey", - }, - { - name: "state", - docs: ["The current state of the locker"], - type: { - defined: "PerformancePackageState", - }, - }, - { - name: "createKey", - docs: ["Used to derive the PDA"], - type: "publicKey", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - { - name: "performancePackageAuthority", - docs: [ - "The authorized locker authority that can execute changes, usually the organization", - ], - type: "publicKey", - }, - { - name: "tokenMint", - docs: ["The mint of the locked tokens"], - type: "publicKey", - }, - { - name: "seqNum", - docs: [ - "The sequence number of the performance package, used for indexing events", - ], - type: "u64", - }, - { - name: "performancePackageTokenVault", - docs: ["The vault that stores the tokens"], - type: "publicKey", - }, - ], - }, - }, - { - name: "changeRequest", - type: { - kind: "struct", - fields: [ - { - name: "performancePackage", - docs: ["The performance package this change applies to"], - type: "publicKey", - }, - { - name: "changeType", - docs: ["What is being changed"], - type: { - defined: "ChangeType", - }, - }, - { - name: "proposedAt", - docs: ["When the change was proposed"], - type: "i64", - }, - { - name: "proposerType", - docs: [ - "Who proposed this change (either token_recipient or locker_authority)", - ], - type: { - defined: "ProposerType", - }, - }, - { - name: "pdaNonce", - docs: ["Used to derive the PDA along with the proposer"], - type: "u32", - }, - { - name: "pdaBump", - docs: ["The PDA bump"], - type: "u8", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "performancePackageSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ChangePerformancePackageAuthorityParams", - type: { - kind: "struct", - fields: [ - { - name: "newPerformancePackageAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "InitializePerformancePackageParams", - type: { - kind: "struct", - fields: [ - { - name: "tranches", - type: { - vec: { - defined: "Tranche", - }, - }, - }, - { - name: "minUnlockTimestamp", - type: "i64", - }, - { - name: "oracleConfig", - type: { - defined: "OracleConfig", - }, - }, - { - name: "twapLengthSeconds", - type: "u32", - }, - { - name: "grantee", - type: "publicKey", - }, - { - name: "performancePackageAuthority", - type: "publicKey", - }, - ], - }, - }, - { - name: "ProposeChangeParams", - type: { - kind: "struct", - fields: [ - { - name: "changeType", - type: { - defined: "ChangeType", - }, - }, - { - name: "pdaNonce", - type: "u32", - }, - ], - }, - }, - { - name: "OracleConfig", - docs: [ - "Starting at `byte_offset` in `oracle_account`, this program expects to read:", - "- 16 bytes for the aggregator, stored as a little endian u128", - "- 8 bytes for the slot that the aggregator was last updated, stored as a", - "little endian u64", - "", - "The aggregator should be a weighted sum of prices, where the weight is the", - "number of seconds between prices. Here's an example:", - "- at second 0, the aggregator is 0", - "- at second 1, the price is 10 and the aggregator is 10 (10 * 1)", - "- at second 4, the price is 11 and 3 seconds have passed, so the aggregator is", - "10 + 11 * 3 = 43", - "", - "This allows our program to read a TWAP over a time period by reading the", - "aggregator value at the beginning and at the end, and dividing the difference", - "by the number of seconds between the two.", - ], - type: { - kind: "struct", - fields: [ - { - name: "oracleAccount", - type: "publicKey", - }, - { - name: "byteOffset", - type: "u32", - }, - ], - }, - }, - { - name: "Tranche", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - docs: ["The price at which this tranch unlocks"], - type: "u128", - }, - { - name: "tokenAmount", - docs: ["The amount of tokens in this tranch"], - type: "u64", - }, - ], - }, - }, - { - name: "StoredTranche", - type: { - kind: "struct", - fields: [ - { - name: "priceThreshold", - type: "u128", - }, - { - name: "tokenAmount", - type: "u64", - }, - { - name: "isUnlocked", - type: "bool", - }, - ], - }, - }, - { - name: "PerformancePackageState", - type: { - kind: "enum", - variants: [ - { - name: "Locked", - }, - { - name: "Unlocking", - fields: [ - { - name: "startAggregator", - docs: ["The aggregator value when unlocking started"], - type: "u128", - }, - { - name: "startTimestamp", - docs: ["The timestamp when unlocking started"], - type: "i64", - }, - ], - }, - ], - }, - }, - { - name: "ChangeType", - type: { - kind: "enum", - variants: [ - { - name: "Oracle", - fields: [ - { - name: "newOracleConfig", - type: { - defined: "OracleConfig", - }, - }, - ], - }, - { - name: "Recipient", - fields: [ - { - name: "newRecipient", - type: "publicKey", - }, - ], - }, - ], - }, - }, - { - name: "ProposerType", - type: { - kind: "enum", - variants: [ - { - name: "Recipient", - }, - { - name: "Authority", - }, - ], - }, - }, - ], - events: [ - { - name: "PerformancePackageInitialized", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "UnlockStarted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "startAggregator", - type: "u128", - index: false, - }, - { - name: "startTimestamp", - type: "i64", - index: false, - }, - ], - }, - { - name: "UnlockCompleted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "tokenAmount", - type: "u64", - index: false, - }, - { - name: "recipient", - type: "publicKey", - index: false, - }, - { - name: "twapPrice", - type: "u128", - index: false, - }, - ], - }, - { - name: "ChangeProposed", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "proposer", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - ], - }, - { - name: "ChangeExecuted", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "changeRequest", - type: "publicKey", - index: false, - }, - { - name: "executor", - type: "publicKey", - index: false, - }, - { - name: "changeType", - type: { - defined: "ChangeType", - }, - index: false, - }, - ], - }, - { - name: "PerformancePackageAuthorityChanged", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "locker", - type: "publicKey", - index: false, - }, - { - name: "oldAuthority", - type: "publicKey", - index: false, - }, - { - name: "newAuthority", - type: "publicKey", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "UnlockTimestampNotReached", - msg: "Unlock timestamp has not been reached yet", - }, - { - code: 6001, - name: "UnlockTimestampInThePast", - msg: "Unlock timestamp must be in the future", - }, - { - code: 6002, - name: "InvalidPerformancePackageState", - msg: "Performance package is not in the expected state", - }, - { - code: 6003, - name: "TwapPeriodNotElapsed", - msg: "TWAP calculation failed", - }, - { - code: 6004, - name: "PriceThresholdNotMet", - msg: "Price threshold not met", - }, - { - code: 6005, - name: "InvalidOracleData", - msg: "Invalid oracle account data", - }, - { - code: 6006, - name: "UnauthorizedChangeRequest", - msg: "Unauthorized to create or execute change request", - }, - { - code: 6007, - name: "InvalidChangeRequest", - msg: "Change request does not match locker", - }, - { - code: 6008, - name: "UnauthorizedLockerAuthority", - msg: "Unauthorized locker authority", - }, - { - code: 6009, - name: "InvariantViolated", - msg: "An invariant was violated. You should get in contact with the MetaDAO team if you see this", - }, - { - code: 6010, - name: "TranchePriceThresholdsNotMonotonic", - msg: "Tranche price thresholds must be monotonically increasing", - }, - { - code: 6011, - name: "TrancheTokenAmountZero", - msg: "Tranche token amount must be greater than 0", - }, - { - code: 6012, - name: "InvalidTwapLength", - msg: "TWAP length must be greater than or equal to 1 day and less than 1 year", - }, - { - code: 6013, - name: "InvalidAdmin", - msg: "Invalid admin", - }, - { - code: 6014, - name: "TotalTokenAmountOverflow", - msg: "Total token amount calculation would overflow", - }, - { - code: 6015, - name: "RecipientAuthorityMustDiffer", - msg: "Recipient and performance package authority must be different keys", - }, - ], -}; diff --git a/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts b/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts deleted file mode 100644 index 124942da9..000000000 --- a/sdk2/src/shared_liquidity_manager/v0.5/types/shared_liquidity_manager.ts +++ /dev/null @@ -1,177 +0,0 @@ -export type SharedLiquidityManager = { - version: "0.1.0"; - name: "shared_liquidity_manager"; - docs: ["TODO:", "- add unstake", "- add unit tests"]; - instructions: []; - errors: [ - { - code: 6000; - name: "InsufficientStake"; - msg: "Insufficient stake amount"; - }, - { - code: 6001; - name: "ProposalNotFinalized"; - msg: "Proposal is not finalized"; - }, - { - code: 6002; - name: "NoLpTokensToRemove"; - msg: "No LP tokens to remove from AMM"; - }, - { - code: 6003; - name: "NoTokensFromAmm"; - msg: "No tokens received from AMM removal"; - }, - { - code: 6004; - name: "InsufficientReservesReturned"; - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)"; - }, - { - code: 6005; - name: "PoolInUse"; - msg: "Pool is currently being used by an active proposal"; - }, - { - code: 6006; - name: "InsufficientLpShares"; - msg: "User does not have enough LP shares to withdraw"; - }, - { - code: 6007; - name: "SlippageExceeded"; - msg: "Slippage exceeded minimum token amounts"; - }, - { - code: 6008; - name: "NoLpTokensInPool"; - msg: "No LP tokens in pool's LP token account"; - }, - { - code: 6009; - name: "NotEnoughLpTokens"; - msg: "Not enough LP tokens to provide liquidity to proposal"; - }, - { - code: 6010; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6011; - name: "NoActiveProposal"; - msg: "No active proposal"; - }, - { - code: 6012; - name: "ProposalNotInDraftStatus"; - msg: "Proposal is not in draft status"; - }, - { - code: 6013; - name: "ProposalAlreadyActive"; - msg: "Proposal already active"; - }, - { - code: 6014; - name: "AmmAlreadyHasLiquidity"; - msg: "AMM already has liquidity"; - }, - { - code: 6015; - name: "QuestionAlreadyResolved"; - msg: "Question already resolved"; - }, - ]; -}; - -export const IDL: SharedLiquidityManager = { - version: "0.1.0", - name: "shared_liquidity_manager", - docs: ["TODO:", "- add unstake", "- add unit tests"], - instructions: [], - errors: [ - { - code: 6000, - name: "InsufficientStake", - msg: "Insufficient stake amount", - }, - { - code: 6001, - name: "ProposalNotFinalized", - msg: "Proposal is not finalized", - }, - { - code: 6002, - name: "NoLpTokensToRemove", - msg: "No LP tokens to remove from AMM", - }, - { - code: 6003, - name: "NoTokensFromAmm", - msg: "No tokens received from AMM removal", - }, - { - code: 6004, - name: "InsufficientReservesReturned", - msg: "Insufficient reserves returned to spot AMM (less than 99.5%)", - }, - { - code: 6005, - name: "PoolInUse", - msg: "Pool is currently being used by an active proposal", - }, - { - code: 6006, - name: "InsufficientLpShares", - msg: "User does not have enough LP shares to withdraw", - }, - { - code: 6007, - name: "SlippageExceeded", - msg: "Slippage exceeded minimum token amounts", - }, - { - code: 6008, - name: "NoLpTokensInPool", - msg: "No LP tokens in pool's LP token account", - }, - { - code: 6009, - name: "NotEnoughLpTokens", - msg: "Not enough LP tokens to provide liquidity to proposal", - }, - { - code: 6010, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6011, - name: "NoActiveProposal", - msg: "No active proposal", - }, - { - code: 6012, - name: "ProposalNotInDraftStatus", - msg: "Proposal is not in draft status", - }, - { - code: 6013, - name: "ProposalAlreadyActive", - msg: "Proposal already active", - }, - { - code: 6014, - name: "AmmAlreadyHasLiquidity", - msg: "AMM already has liquidity", - }, - { - code: 6015, - name: "QuestionAlreadyResolved", - msg: "Question already resolved", - }, - ], -}; diff --git a/sdk2/tsconfig.json b/sdk2/tsconfig.json deleted file mode 100644 index 72ee660a5..000000000 --- a/sdk2/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "types": ["mocha", "chai"], - "typeRoots": ["./node_modules/@types"], - "lib": ["esnext"], - "module": "NodeNext", - "target": "esnext", - "esModuleInterop": true, - "skipLibCheck": true, - "moduleResolution": "nodenext", - "sourceMap": true, - "outDir": "dist", - "strict": true, - "declaration": true - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "target", "tests", "migrations"] -} diff --git a/sdk2/yarn.lock b/sdk2/yarn.lock deleted file mode 100644 index bf1c0f358..000000000 --- a/sdk2/yarn.lock +++ /dev/null @@ -1,3331 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/runtime@^7.25.0": - version "7.28.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326" - integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ== - -"@bundlr-network/client@^0.8.8": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@bundlr-network/client/-/client-0.8.9.tgz#58e969a5d80f8d25d212d46bb7a060730a3c1736" - integrity sha512-SJ7BAt/KhONeFQ0+nbqrw2DUWrsev6y6cmlXt+3x7fPCkw7OJwudtxV/h2nBteZd65NXjqw8yzkmLiLfZ7CCRA== - dependencies: - "@solana/wallet-adapter-base" "^0.9.2" - "@solana/web3.js" "^1.36.0" - "@supercharge/promise-pool" "^2.1.0" - algosdk "^1.13.1" - arbundles "^0.6.21" - arweave "^1.11.4" - async-retry "^1.3.3" - axios "^0.25.0" - base64url "^3.0.1" - bignumber.js "^9.0.1" - bs58 "^4.0.1" - commander "^8.2.0" - csv "^6.0.5" - ethers "^5.5.1" - inquirer "^8.2.0" - js-sha256 "^0.9.0" - mime-types "^2.1.34" - near-api-js "^0.44.2" - near-seed-phrase "^0.2.0" - -"@coral-xyz/anchor@^0.29.0": - version "0.29.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" - integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== - dependencies: - "@coral-xyz/borsh" "^0.29.0" - "@noble/hashes" "^1.3.1" - "@solana/web3.js" "^1.68.0" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/borsh@^0.29.0": - version "0.29.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.29.0.tgz#79f7045df2ef66da8006d47f5399c7190363e71f" - integrity sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - -"@esbuild/android-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" - integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== - -"@esbuild/android-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" - integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== - -"@esbuild/android-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" - integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== - -"@esbuild/darwin-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" - integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== - -"@esbuild/darwin-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" - integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== - -"@esbuild/freebsd-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" - integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== - -"@esbuild/freebsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" - integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== - -"@esbuild/linux-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" - integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== - -"@esbuild/linux-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" - integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== - -"@esbuild/linux-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" - integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== - -"@esbuild/linux-loong64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" - integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== - -"@esbuild/linux-mips64el@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" - integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== - -"@esbuild/linux-ppc64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" - integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== - -"@esbuild/linux-riscv64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" - integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== - -"@esbuild/linux-s390x@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" - integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== - -"@esbuild/linux-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" - integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== - -"@esbuild/netbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" - integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== - -"@esbuild/openbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" - integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== - -"@esbuild/sunos-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" - integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== - -"@esbuild/win32-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" - integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== - -"@esbuild/win32-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" - integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== - -"@esbuild/win32-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" - integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== - -"@ethersproject/abi@5.8.0", "@ethersproject/abi@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.8.0.tgz#e79bb51940ac35fe6f3262d7fe2cdb25ad5f07d9" - integrity sha512-b9YS/43ObplgyV6SlyQsG53/vkSal0MNA1fskSC4mbnCMi8R+NkcH8K9FPYNESf6jUefBUniE4SOKms0E/KK1Q== - dependencies: - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/abstract-provider@5.8.0", "@ethersproject/abstract-provider@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.8.0.tgz#7581f9be601afa1d02b95d26b9d9840926a35b0c" - integrity sha512-wC9SFcmh4UK0oKuLJQItoQdzS/qZ51EJegK6EmAWlh+OptpQ/npECOR3QqECd8iGHC0RJb4WKbVdSfif4ammrg== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/networks" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/web" "^5.8.0" - -"@ethersproject/abstract-signer@5.8.0", "@ethersproject/abstract-signer@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.8.0.tgz#8d7417e95e4094c1797a9762e6789c7356db0754" - integrity sha512-N0XhZTswXcmIZQdYtUnd79VJzvEwXQw6PK0dTl9VoYrEBxxCPXqS0Eod7q5TNKRxe1/5WUMuR0u0nqTF/avdCA== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - -"@ethersproject/address@5.8.0", "@ethersproject/address@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.8.0.tgz#3007a2c352eee566ad745dca1dbbebdb50a6a983" - integrity sha512-GhH/abcC46LJwshoN+uBNoKVFPxUuZm6dA257z0vZkKmU1+t8xTn8oK7B9qrj8W2rFRMch4gbJl6PmVxjxBEBA== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - -"@ethersproject/base64@5.8.0", "@ethersproject/base64@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.8.0.tgz#61c669c648f6e6aad002c228465d52ac93ee83eb" - integrity sha512-lN0oIwfkYj9LbPx4xEkie6rAMJtySbpOAFXSDVQaBnAzYfB4X2Qr+FXJGxMoc3Bxp2Sm8OwvzMrywxyw0gLjIQ== - dependencies: - "@ethersproject/bytes" "^5.8.0" - -"@ethersproject/basex@5.8.0", "@ethersproject/basex@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.8.0.tgz#1d279a90c4be84d1c1139114a1f844869e57d03a" - integrity sha512-PIgTszMlDRmNwW9nhS6iqtVfdTAKosA7llYXNmGPw4YAI1PUyMv28988wAb41/gHF/WqGdoLv0erHaRcHRKW2Q== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - -"@ethersproject/bignumber@5.8.0", "@ethersproject/bignumber@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.8.0.tgz#c381d178f9eeb370923d389284efa19f69efa5d7" - integrity sha512-ZyaT24bHaSeJon2tGPKIiHszWjD/54Sz8t57Toch475lCLljC6MgPmxk7Gtzz+ddNN5LuHea9qhAe0x3D+uYPA== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - bn.js "^5.2.1" - -"@ethersproject/bytes@5.8.0", "@ethersproject/bytes@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.8.0.tgz#9074820e1cac7507a34372cadeb035461463be34" - integrity sha512-vTkeohgJVCPVHu5c25XWaWQOZ4v+DkGoC42/TS2ond+PARCxTJvgTFUNDZovyQ/uAQ4EcpqqowKydcdmRKjg7A== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/constants@5.8.0", "@ethersproject/constants@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.8.0.tgz#12f31c2f4317b113a4c19de94e50933648c90704" - integrity sha512-wigX4lrf5Vu+axVTIvNsuL6YrV4O5AXl5ubcURKMEME5TnWBouUh0CDTWxZ2GpnRn1kcCgE7l8O5+VbV9QTTcg== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - -"@ethersproject/contracts@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.8.0.tgz#243a38a2e4aa3e757215ea64e276f8a8c9d8ed73" - integrity sha512-0eFjGz9GtuAi6MZwhb4uvUM216F38xiuR0yYCjKJpNfSEy4HUM8hvqqBj9Jmm0IUz8l0xKEhWwLIhPgxNY0yvQ== - dependencies: - "@ethersproject/abi" "^5.8.0" - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - -"@ethersproject/hash@5.8.0", "@ethersproject/hash@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.8.0.tgz#b8893d4629b7f8462a90102572f8cd65a0192b4c" - integrity sha512-ac/lBcTbEWW/VGJij0CNSw/wPcw9bSRgCB0AIBz8CvED/jfvDoV9hsIIiWfvWmFEi8RcXtlNwp2jv6ozWOsooA== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/base64" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/hdnode@5.8.0", "@ethersproject/hdnode@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.8.0.tgz#a51ae2a50bcd48ef6fd108c64cbae5e6ff34a761" - integrity sha512-4bK1VF6E83/3/Im0ERnnUeWOY3P1BZml4ZD3wcH8Ys0/d1h1xaFt6Zc+Dh9zXf9TapGro0T4wvO71UTCp3/uoA== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/basex" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/pbkdf2" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/wordlists" "^5.8.0" - -"@ethersproject/json-wallets@5.8.0", "@ethersproject/json-wallets@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/json-wallets/-/json-wallets-5.8.0.tgz#d18de0a4cf0f185f232eb3c17d5e0744d97eb8c9" - integrity sha512-HxblNck8FVUtNxS3VTEYJAcwiKYsBIF77W15HufqlBF9gGfhmYOJtYZp8fSDZtn9y5EaXTE87zDwzxRoTFk11w== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hdnode" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/pbkdf2" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - aes-js "3.0.0" - scrypt-js "3.0.1" - -"@ethersproject/keccak256@5.8.0", "@ethersproject/keccak256@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.8.0.tgz#d2123a379567faf2d75d2aaea074ffd4df349e6a" - integrity sha512-A1pkKLZSz8pDaQ1ftutZoaN46I6+jvuqugx5KYNeQOPqq+JZ0Txm7dlWesCHB5cndJSu5vP2VKptKf7cksERng== - dependencies: - "@ethersproject/bytes" "^5.8.0" - js-sha3 "0.8.0" - -"@ethersproject/logger@5.8.0", "@ethersproject/logger@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.8.0.tgz#f0232968a4f87d29623a0481690a2732662713d6" - integrity sha512-Qe6knGmY+zPPWTC+wQrpitodgBfH7XoceCGL5bJVejmH+yCS3R8jJm8iiWuvWbG76RUmyEG53oqv6GMVWqunjA== - -"@ethersproject/networks@5.8.0", "@ethersproject/networks@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.8.0.tgz#8b4517a3139380cba9fb00b63ffad0a979671fde" - integrity sha512-egPJh3aPVAzbHwq8DD7Po53J4OUSsA1MjQp8Vf/OZPav5rlmWUaFLiq8cvQiGK0Z5K6LYzm29+VA/p4RL1FzNg== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/pbkdf2@5.8.0", "@ethersproject/pbkdf2@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.8.0.tgz#cd2621130e5dd51f6a0172e63a6e4a0c0a0ec37e" - integrity sha512-wuHiv97BrzCmfEaPbUFpMjlVg/IDkZThp9Ri88BpjRleg4iePJaj2SW8AIyE8cXn5V1tuAaMj6lzvsGJkGWskg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - -"@ethersproject/properties@5.8.0", "@ethersproject/properties@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.8.0.tgz#405a8affb6311a49a91dabd96aeeae24f477020e" - integrity sha512-PYuiEoQ+FMaZZNGrStmN7+lWjlsoufGIHdww7454FIaGdbe/p5rnaCXTr5MtBYl3NkeoVhHZuyzChPeGeKIpQw== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/providers@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.8.0.tgz#6c2ae354f7f96ee150439f7de06236928bc04cb4" - integrity sha512-3Il3oTzEx3o6kzcg9ZzbE+oCZYyY+3Zh83sKkn4s1DZfTUjIegHnN2Cm0kbn9YFy45FDVcuCLLONhU7ny0SsCw== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/base64" "^5.8.0" - "@ethersproject/basex" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/networks" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/web" "^5.8.0" - bech32 "1.1.4" - ws "8.18.0" - -"@ethersproject/random@5.8.0", "@ethersproject/random@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.8.0.tgz#1bced04d49449f37c6437c701735a1a022f0057a" - integrity sha512-E4I5TDl7SVqyg4/kkA/qTfuLWAQGXmSOgYyO01So8hLfwgKvYK5snIlzxJMk72IFdG/7oh8yuSqY2KX7MMwg+A== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/rlp@5.8.0", "@ethersproject/rlp@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.8.0.tgz#5a0d49f61bc53e051532a5179472779141451de5" - integrity sha512-LqZgAznqDbiEunaUvykH2JAoXTT9NV0Atqk8rQN9nx9SEgThA/WMx5DnW8a9FOufo//6FZOCHZ+XiClzgbqV9Q== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/sha2@5.8.0", "@ethersproject/sha2@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.8.0.tgz#8954a613bb78dac9b46829c0a95de561ef74e5e1" - integrity sha512-dDOUrXr9wF/YFltgTBYS0tKslPEKr6AekjqDW2dbn1L1xmjGR+9GiKu4ajxovnrDbwxAKdHjW8jNcwfz8PAz4A== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - hash.js "1.1.7" - -"@ethersproject/signing-key@5.8.0", "@ethersproject/signing-key@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.8.0.tgz#9797e02c717b68239c6349394ea85febf8893119" - integrity sha512-LrPW2ZxoigFi6U6aVkFN/fa9Yx/+4AtIUe4/HACTvKJdhm0eeb107EVCIQcrLZkxaSIgc/eCrX8Q1GtbH+9n3w== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - bn.js "^5.2.1" - elliptic "6.6.1" - hash.js "1.1.7" - -"@ethersproject/solidity@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.8.0.tgz#429bb9fcf5521307a9448d7358c26b93695379b9" - integrity sha512-4CxFeCgmIWamOHwYN9d+QWGxye9qQLilpgTU0XhYs1OahkclF+ewO+3V1U0mvpiuQxm5EHHmv8f7ClVII8EHsA== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/strings@5.8.0", "@ethersproject/strings@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.8.0.tgz#ad79fafbf0bd272d9765603215ac74fd7953908f" - integrity sha512-qWEAk0MAvl0LszjdfnZ2uC8xbR2wdv4cDabyHiBh3Cldq/T8dPH3V4BbBsAYJUeonwD+8afVXld274Ls+Y1xXg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/transactions@5.8.0", "@ethersproject/transactions@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.8.0.tgz#1e518822403abc99def5a043d1c6f6fe0007e46b" - integrity sha512-UglxSDjByHG0TuU17bDfCemZ3AnKO2vYrL5/2n2oXvKzvb7Cz+W9gOWXKARjp2URVwcWlQlPOEQyAviKwT4AHg== - dependencies: - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - -"@ethersproject/units@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.8.0.tgz#c12f34ba7c3a2de0e9fa0ed0ee32f3e46c5c2c6a" - integrity sha512-lxq0CAnc5kMGIiWW4Mr041VT8IhNM+Pn5T3haO74XZWFulk7wH1Gv64HqE96hT4a7iiNMdOCFEBgaxWuk8ETKQ== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/wallet@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.8.0.tgz#49c300d10872e6986d953e8310dc33d440da8127" - integrity sha512-G+jnzmgg6UxurVKRKvw27h0kvG75YKXZKdlLYmAHeF32TGUzHkOFd7Zn6QHOTYRFWnfjtSSFjBowKo7vfrXzPA== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/hdnode" "^5.8.0" - "@ethersproject/json-wallets" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/wordlists" "^5.8.0" - -"@ethersproject/web@5.8.0", "@ethersproject/web@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.8.0.tgz#3e54badc0013b7a801463a7008a87988efce8a37" - integrity sha512-j7+Ksi/9KfGviws6Qtf9Q7KCqRhpwrYKQPs+JBA/rKVFF/yaWLHJEH3zfVP2plVu+eys0d2DlFmhoQJayFewcw== - dependencies: - "@ethersproject/base64" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/wordlists@5.8.0", "@ethersproject/wordlists@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.8.0.tgz#7a5654ee8d1bb1f4dbe43f91d217356d650ad821" - integrity sha512-2df9bbXicZws2Sb5S6ET493uJ0Z84Fjr3pC4tu/qlnZERibZCeUVuqdtt+7Tv9xxhUxHoIekIA7avrKUWHrezg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@inquirer/external-editor@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@inquirer/external-editor/-/external-editor-1.0.3.tgz#c23988291ee676290fdab3fd306e64010a6d13b8" - integrity sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA== - dependencies: - chardet "^2.1.1" - iconv-lite "^0.7.0" - -"@metaplex-foundation/beet-solana@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.0.tgz#52891e78674aaa54e0031f1bca5bfbc40de12e8d" - integrity sha512-B1L94N3ZGMo53b0uOSoznbuM5GBNJ8LwSeznxBxJ+OThvfHQ4B5oMUqb+0zdLRfkKGS7Q6tpHK9P+QK0j3w2cQ== - dependencies: - "@metaplex-foundation/beet" ">=0.1.0" - "@solana/web3.js" "^1.56.2" - bs58 "^5.0.0" - debug "^4.3.4" - -"@metaplex-foundation/beet@0.7.1": - version "0.7.1" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.1.tgz#0975314211643f87b5f6f3e584fa31abcf4c612c" - integrity sha512-hNCEnS2WyCiYyko82rwuISsBY3KYpe828ubsd2ckeqZr7tl0WVLivGkoyA/qdiaaHEBGdGl71OpfWa2rqL3DiA== - dependencies: - ansicolors "^0.3.2" - bn.js "^5.2.0" - debug "^4.3.3" - -"@metaplex-foundation/beet@>=0.1.0": - version "0.7.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.2.tgz#fa4726e4cfd4fb6fed6cddc9b5213c1c2a2d0b77" - integrity sha512-K+g3WhyFxKPc0xIvcIjNyV1eaTVJTiuaHZpig7Xx0MuYRMoJLLvhLTnUXhFdR5Tu2l2QSyKwfyXDgZlzhULqFg== - dependencies: - ansicolors "^0.3.2" - assert "^2.1.0" - bn.js "^5.2.0" - debug "^4.3.3" - -"@metaplex-foundation/cusper@^0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/cusper/-/cusper-0.0.2.tgz#dc2032a452d6c269e25f016aa4dd63600e2af975" - integrity sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA== - -"@metaplex-foundation/umi-bundle-defaults@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-bundle-defaults/-/umi-bundle-defaults-0.9.2.tgz#f8e296b1a0ecb3a6511dbaca4131bc9263071cfc" - integrity sha512-kV3tfvgvRjVP1p9OFOtH+ibOtN9omVJSwKr0We4/9r45e5LTj+32su0V/rixZUkG1EZzzOYBsxhtIE0kIw/Hrw== - dependencies: - "@metaplex-foundation/umi-downloader-http" "^0.9.2" - "@metaplex-foundation/umi-eddsa-web3js" "^0.9.2" - "@metaplex-foundation/umi-http-fetch" "^0.9.2" - "@metaplex-foundation/umi-program-repository" "^0.9.2" - "@metaplex-foundation/umi-rpc-chunk-get-accounts" "^0.9.2" - "@metaplex-foundation/umi-rpc-web3js" "^0.9.2" - "@metaplex-foundation/umi-serializer-data-view" "^0.9.2" - "@metaplex-foundation/umi-transaction-factory-web3js" "^0.9.2" - -"@metaplex-foundation/umi-downloader-http@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-downloader-http/-/umi-downloader-http-0.9.2.tgz#df84b11df9141854ca1cf7c6c8374658e67de767" - integrity sha512-tzPT9hBwenzTzAQg07rmsrqZfgguAXELbcJrsYMoASp5VqWFXYIP00g94KET6XLjWUXH4P1J2zoa6hGennPXHA== - -"@metaplex-foundation/umi-eddsa-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-eddsa-web3js/-/umi-eddsa-web3js-0.9.2.tgz#92225595137c5585dae63b148786ab77fcb6d625" - integrity sha512-hhPCxXbYIp4BC4z9gK78sXpWLkNSrfv4ndhF5ruAkdIp7GcRVYKj0QnOUO6lGYGiIkNlw20yoTwOe1CT//OfTQ== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - "@noble/curves" "^1.0.0" - -"@metaplex-foundation/umi-http-fetch@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-http-fetch/-/umi-http-fetch-0.9.2.tgz#e233ec34b789ed5257168b97d72fc9b039155046" - integrity sha512-YCZuBu24T9ZzEDe4+w12LEZm/fO9pkyViZufGgASC5NX93814Lvf6Ssjn/hZzjfA7CvZbvLFbmujc6CV3Q/m9Q== - dependencies: - node-fetch "^2.6.7" - -"@metaplex-foundation/umi-options@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-options/-/umi-options-0.8.9.tgz#9c9e269d9eee7d055ad6831dcb30a30127dcb0c5" - integrity sha512-jSQ61sZMPSAk/TXn8v8fPqtz3x8d0/blVZXLLbpVbo2/T5XobiI6/MfmlUosAjAUaQl6bHRF8aIIqZEFkJiy4A== - -"@metaplex-foundation/umi-program-repository@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-program-repository/-/umi-program-repository-0.9.2.tgz#53fce2bf506bb97fdb6a53e2118f8d1dd28fd0b5" - integrity sha512-g3+FPqXEmYsBa8eETtUE2gb2Oe3mqac0z3/Ur1TvAg5TtIy3mzRzOy/nza+sgzejnfcxcVg835rmpBaxpBnjDA== - -"@metaplex-foundation/umi-public-keys@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-public-keys/-/umi-public-keys-0.8.9.tgz#ca7a927c924ed8e28d0f8bb3dc0f2adc1f9011ec" - integrity sha512-CxMzN7dgVGOq9OcNCJe2casKUpJ3RmTVoOvDFyeoTQuK+vkZ1YSSahbqC1iGuHEtKTLSjtWjKvUU6O7zWFTw3Q== - dependencies: - "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" - -"@metaplex-foundation/umi-rpc-chunk-get-accounts@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-chunk-get-accounts/-/umi-rpc-chunk-get-accounts-0.9.2.tgz#f93bd43d4c65cdfdb0a68145a837fb6b13e0e832" - integrity sha512-YRwVf6xH0jPBAUgMhEPi+UbjioAeqTXmjsN2TnmQCPAmHbrHrMRj0rlWYwFLWAgkmoxazYrXP9lqOFRrfOGAEA== - -"@metaplex-foundation/umi-rpc-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-web3js/-/umi-rpc-web3js-0.9.2.tgz#b00a4cc1a9bd5d930164d1ba43f816107655c0d9" - integrity sha512-MqcsBz8B4wGl6jxsf2Jo/rAEpYReU9VCSR15QSjhvADHMmdFxCIZCCAgE+gDE2Vuanfl437VhOcP3g5Uw8C16Q== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - -"@metaplex-foundation/umi-serializer-data-view@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializer-data-view/-/umi-serializer-data-view-0.9.2.tgz#a05d88e7120b839e3acba35f7b4e12fe8be2becc" - integrity sha512-5vGptadJxUxvUcyrwFZxXlEc6Q7AYySBesizCtrBFUY8w8PnF2vzmS45CP1MLySEATNH6T9mD4Rs0tLb87iQyA== - -"@metaplex-foundation/umi-serializers-core@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-core/-/umi-serializers-core-0.8.9.tgz#cd5ae763a59e54dd01f1284f4a6bf4e78e4aab9c" - integrity sha512-WT82tkiYJ0Qmscp7uTj1Hz6aWQPETwaKLAENAUN5DeWghkuBKtuxyBKVvEOuoXerJSdhiAk0e8DWA4cxcTTQ/w== - -"@metaplex-foundation/umi-serializers-encodings@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-encodings/-/umi-serializers-encodings-0.8.9.tgz#0f02605ee3e6fbeac1abc4fb267a7cc96ecb4410" - integrity sha512-N3VWLDTJ0bzzMKcJDL08U3FaqRmwlN79FyE4BHj6bbAaJ9LEHjDQ9RJijZyWqTm0jE7I750fU7Ow5EZL38Xi6Q== - dependencies: - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - -"@metaplex-foundation/umi-serializers-numbers@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-numbers/-/umi-serializers-numbers-0.8.9.tgz#28c10367f6aebac0276ec1bce81d0d8db54b05de" - integrity sha512-NtBf1fnVNQJHFQjLFzRu2i9GGnigb9hOm/Gfrk628d0q0tRJB7BOM3bs5C61VAs7kJs4yd+pDNVAERJkknQ7Lg== - dependencies: - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - -"@metaplex-foundation/umi-serializers@^0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers/-/umi-serializers-0.9.0.tgz#af6d03a3bf821bf73b7b3450bb8df0407f2f69d6" - integrity sha512-hAOW9Djl4w4ioKeR4erDZl5IG4iJdP0xA19ZomdaCbMhYAAmG/FEs5khh0uT2mq53/MnzWcXSUPoO8WBN4Q+Vg== - dependencies: - "@metaplex-foundation/umi-options" "^0.8.9" - "@metaplex-foundation/umi-public-keys" "^0.8.9" - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" - "@metaplex-foundation/umi-serializers-numbers" "^0.8.9" - -"@metaplex-foundation/umi-transaction-factory-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-transaction-factory-web3js/-/umi-transaction-factory-web3js-0.9.2.tgz#294c3ca996897bb95b993b808fb9252bd085db15" - integrity sha512-fR1Kf21uylMFd1Smkltmj4jTNxhqSWf416owsJ+T+cvJi2VCOcOwq/3UFzOrpz78fA0RhsajKYKj0HYsRnQI1g== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - -"@metaplex-foundation/umi-uploader-bundlr@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-uploader-bundlr/-/umi-uploader-bundlr-0.9.2.tgz#0d832816a32970cac9f412a0b0a8234415ab8534" - integrity sha512-wmixKqWyEO0lRB2GNvm5XOwi3jEyCtPZ6Oqds6sY5YHYdrn1Cqgd1TcdAuu7+DuojcNFErTjWsaQ1F9QR502QQ== - dependencies: - "@bundlr-network/client" "^0.8.8" - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - bignumber.js "^9.0.2" - buffer "^6.0.3" - -"@metaplex-foundation/umi-web3js-adapters@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-web3js-adapters/-/umi-web3js-adapters-0.9.2.tgz#1e0ebb4e3c31e8bead27892b20204292ad6955c5" - integrity sha512-RQqUTtHYY9fmEMnq7s3Hiv/81flGaoI0ZVVoafnFVaQLnxU6QBKxtboRZHk43XtD9CiFh5f9izrMJX7iK7KlOA== - dependencies: - buffer "^6.0.3" - -"@metaplex-foundation/umi@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi/-/umi-0.9.2.tgz#6460bff91d2ac7745842eda1ee6a28fba4d2ffb2" - integrity sha512-9i4Acm4pruQfJcpRrc2EauPBwkfDN0I9QTvJyZocIlKgoZwD6A6wH0PViH1AjOVG5CQCd1YI3tJd5XjYE1ElBw== - dependencies: - "@metaplex-foundation/umi-options" "^0.8.9" - "@metaplex-foundation/umi-public-keys" "^0.8.9" - "@metaplex-foundation/umi-serializers" "^0.9.0" - -"@noble/curves@^1.0.0", "@noble/curves@^1.4.2": - version "1.9.7" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951" - integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw== - dependencies: - "@noble/hashes" "1.8.0" - -"@noble/ed25519@^1.6.1": - version "1.7.5" - resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.5.tgz#94df8bdb9fec9c4644a56007eecb57b0e9fbd0d7" - integrity sha512-xuS0nwRMQBvSxDa7UxMb61xTiH3MxTgUfhyPUALVIe0FlOAz4sjELwyDRyUvqeEYfRSG9qNjFIycqLZppg4RSA== - -"@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0": - version "1.8.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a" - integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A== - -"@randlabs/communication-bridge@1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3" - integrity sha512-CzS0U8IFfXNK7QaJFE4pjbxDGfPjbXBEsEaCn9FN15F+ouSAEUQkva3Gl66hrkBZOGexKFEWMwUHIDKpZ2hfVg== - -"@randlabs/myalgo-connect@^1.1.2": - version "1.4.2" - resolved "https://registry.yarnpkg.com/@randlabs/myalgo-connect/-/myalgo-connect-1.4.2.tgz#ce3ad97b3889ea21da75852187511d3f6be0fa05" - integrity sha512-K9hEyUi7G8tqOp7kWIALJLVbGCByhilcy6123WfcorxWwiE1sbQupPyIU5f3YdQK6wMjBsyTWiLW52ZBMp7sXA== - dependencies: - "@randlabs/communication-bridge" "1.0.1" - -"@solana/buffer-layout-utils@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" - integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/web3.js" "^1.32.0" - bigint-buffer "^1.1.5" - bignumber.js "^9.0.1" - -"@solana/buffer-layout@^4.0.0", "@solana/buffer-layout@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" - integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== - dependencies: - buffer "~6.0.3" - -"@solana/codecs-core@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.0.0-rc.1.tgz#1a2d76b9c7b9e7b7aeb3bd78be81c2ba21e3ce22" - integrity sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ== - dependencies: - "@solana/errors" "2.0.0-rc.1" - -"@solana/codecs-core@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.3.0.tgz#6bf2bb565cb1ae880f8018635c92f751465d8695" - integrity sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw== - dependencies: - "@solana/errors" "2.3.0" - -"@solana/codecs-data-structures@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-rc.1.tgz#d47b2363d99fb3d643f5677c97d64a812982b888" - integrity sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog== - dependencies: - "@solana/codecs-core" "2.0.0-rc.1" - "@solana/codecs-numbers" "2.0.0-rc.1" - "@solana/errors" "2.0.0-rc.1" - -"@solana/codecs-numbers@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.0.0-rc.1.tgz#f34978ddf7ea4016af3aaed5f7577c1d9869a614" - integrity sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ== - dependencies: - "@solana/codecs-core" "2.0.0-rc.1" - "@solana/errors" "2.0.0-rc.1" - -"@solana/codecs-numbers@^2.1.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.3.0.tgz#ac7e7f38aaf7fcd22ce2061fbdcd625e73828dc6" - integrity sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg== - dependencies: - "@solana/codecs-core" "2.3.0" - "@solana/errors" "2.3.0" - -"@solana/codecs-strings@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-2.0.0-rc.1.tgz#e1d9167075b8c5b0b60849f8add69c0f24307018" - integrity sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g== - dependencies: - "@solana/codecs-core" "2.0.0-rc.1" - "@solana/codecs-numbers" "2.0.0-rc.1" - "@solana/errors" "2.0.0-rc.1" - -"@solana/codecs@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/codecs/-/codecs-2.0.0-rc.1.tgz#146dc5db58bd3c28e04b4c805e6096c2d2a0a875" - integrity sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ== - dependencies: - "@solana/codecs-core" "2.0.0-rc.1" - "@solana/codecs-data-structures" "2.0.0-rc.1" - "@solana/codecs-numbers" "2.0.0-rc.1" - "@solana/codecs-strings" "2.0.0-rc.1" - "@solana/options" "2.0.0-rc.1" - -"@solana/errors@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.0.0-rc.1.tgz#3882120886eab98a37a595b85f81558861b29d62" - integrity sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ== - dependencies: - chalk "^5.3.0" - commander "^12.1.0" - -"@solana/errors@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.3.0.tgz#4ac9380343dbeffb9dffbcb77c28d0e457c5fa31" - integrity sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ== - dependencies: - chalk "^5.4.1" - commander "^14.0.0" - -"@solana/options@2.0.0-rc.1": - version "2.0.0-rc.1" - resolved "https://registry.yarnpkg.com/@solana/options/-/options-2.0.0-rc.1.tgz#06924ba316dc85791fc46726a51403144a85fc4d" - integrity sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA== - dependencies: - "@solana/codecs-core" "2.0.0-rc.1" - "@solana/codecs-data-structures" "2.0.0-rc.1" - "@solana/codecs-numbers" "2.0.0-rc.1" - "@solana/codecs-strings" "2.0.0-rc.1" - "@solana/errors" "2.0.0-rc.1" - -"@solana/spl-token-metadata@^0.1.2": - version "0.1.6" - resolved "https://registry.yarnpkg.com/@solana/spl-token-metadata/-/spl-token-metadata-0.1.6.tgz#d240947aed6e7318d637238022a7b0981b32ae80" - integrity sha512-7sMt1rsm/zQOQcUWllQX9mD2O6KhSAtY1hFR2hfFwgqfFWzSY9E9GDvFVNYUI1F0iQKcm6HmePU9QbKRXTEBiA== - dependencies: - "@solana/codecs" "2.0.0-rc.1" - -"@solana/spl-token@^0.3.6", "@solana/spl-token@^0.3.7", "@solana/spl-token@^0.3.8": - version "0.3.11" - resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.11.tgz#cdc10f9472b29b39c8983c92592cadd06627fb9a" - integrity sha512-bvohO3rIMSVL24Pb+I4EYTJ6cL82eFpInEXD/I8K8upOGjpqHsKUoAempR/RnUlI1qSFNyFlWJfu6MNUgfbCQQ== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/buffer-layout-utils" "^0.2.0" - "@solana/spl-token-metadata" "^0.1.2" - buffer "^6.0.3" - -"@solana/wallet-adapter-base@^0.9.2": - version "0.9.27" - resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.27.tgz#f76463db172ac1d7d1f5aa064800363777731dfd" - integrity sha512-kXjeNfNFVs/NE9GPmysBRKQ/nf+foSaq3kfVSeMcO/iVgigyRmB551OjU3WyAolLG/1jeEfKLqF9fKwMCRkUqg== - dependencies: - "@solana/wallet-standard-features" "^1.3.0" - "@wallet-standard/base" "^1.1.0" - "@wallet-standard/features" "^1.1.0" - eventemitter3 "^5.0.1" - -"@solana/wallet-standard-features@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-features/-/wallet-standard-features-1.3.0.tgz#c489eca9d0c78f97084b4af6ca8ad8c1ca197de5" - integrity sha512-ZhpZtD+4VArf6RPitsVExvgkF+nGghd1rzPjd97GmBximpnt1rsUxMOEyoIEuH3XBxPyNB6Us7ha7RHWQR+abg== - dependencies: - "@wallet-standard/base" "^1.1.0" - "@wallet-standard/features" "^1.1.0" - -"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.70.3", "@solana/web3.js@^1.76.0": - version "1.98.4" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" - integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== - dependencies: - "@babel/runtime" "^7.25.0" - "@noble/curves" "^1.4.2" - "@noble/hashes" "^1.4.0" - "@solana/buffer-layout" "^4.0.1" - "@solana/codecs-numbers" "^2.1.0" - agentkeepalive "^4.5.0" - bn.js "^5.2.1" - borsh "^0.7.0" - bs58 "^4.0.1" - buffer "6.0.3" - fast-stable-stringify "^1.0.0" - jayson "^4.1.1" - node-fetch "^2.7.0" - rpc-websockets "^9.0.2" - superstruct "^2.0.2" - -"@sqds/multisig@^2.1.4": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@sqds/multisig/-/multisig-2.1.4.tgz#f69067ee8e23e86b1170ae7509cdfbc460ac9d0d" - integrity sha512-5w+NmwHOzl96nI50R/fjSD6uFydRLNUquhoEmmWbGepS4D9DnQyF2TKcUBfTyxV3sgJt00ypBt7SXB3y8WOzUQ== - dependencies: - "@metaplex-foundation/beet" "0.7.1" - "@metaplex-foundation/beet-solana" "0.4.0" - "@metaplex-foundation/cusper" "^0.0.2" - "@solana/spl-token" "^0.3.6" - "@solana/web3.js" "^1.70.3" - "@types/bn.js" "^5.1.1" - assert "^2.0.0" - bn.js "^5.2.1" - buffer "6.0.3" - invariant "2.2.4" - -"@supercharge/promise-pool@^2.1.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-2.4.0.tgz#6050eea8c2d7f92ddd4ddc582ee328b15c034ad3" - integrity sha512-O9CMipBlq5OObdt1uKJGIzm9cdjpPWfj+a+Zw9EgWKxaMNHKC7EU7X9taj3H0EGQNLOSq2jAcOa3EzxlfHsD6w== - -"@swc/helpers@^0.5.11": - version "0.5.17" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.17.tgz#5a7be95ac0f0bf186e7e6e890e7a6f6cda6ce971" - integrity sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A== - dependencies: - tslib "^2.8.0" - -"@types/bn.js@^5.1.0", "@types/bn.js@^5.1.1": - version "5.2.0" - resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.2.0.tgz#4349b9710e98f9ab3cdc50f1c5e4dcbd8ef29c80" - integrity sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q== - dependencies: - "@types/node" "*" - -"@types/chai@^4.3.0": - version "4.3.20" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.20.tgz#cb291577ed342ca92600430841a00329ba05cecc" - integrity sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ== - -"@types/connect@^3.4.33": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" - integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== - dependencies: - "@types/node" "*" - -"@types/json5@^0.0.29": - version "0.0.29" - resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" - integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== - -"@types/mocha@^9.0.0": - version "9.1.1" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" - integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== - -"@types/node@*": - version "25.0.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-25.0.3.tgz#79b9ac8318f373fbfaaf6e2784893efa9701f269" - integrity sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA== - dependencies: - undici-types "~7.16.0" - -"@types/node@11.11.6": - version "11.11.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" - integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== - -"@types/node@^12.12.54": - version "12.20.55" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" - integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== - -"@types/uuid@^8.3.4": - version "8.3.4" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" - integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== - -"@types/ws@^7.4.4": - version "7.4.7" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" - integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== - dependencies: - "@types/node" "*" - -"@types/ws@^8.2.2": - version "8.18.1" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.18.1.tgz#48464e4bf2ddfd17db13d845467f6070ffea4aa9" - integrity sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg== - dependencies: - "@types/node" "*" - -"@ungap/promise-all-settled@1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" - integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== - -"@wallet-standard/base@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wallet-standard/base/-/base-1.1.0.tgz#214093c0597a1e724ee6dbacd84191dfec62bb33" - integrity sha512-DJDQhjKmSNVLKWItoKThJS+CsJQjR9AOBOirBVT1F9YpRyC9oYHE+ZnSf8y8bxUphtKqdQMPVQ2mHohYdRvDVQ== - -"@wallet-standard/features@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wallet-standard/features/-/features-1.1.0.tgz#f256d7b18940c8d134f66164330db358a8f5200e" - integrity sha512-hiEivWNztx73s+7iLxsuD1sOJ28xtRix58W7Xnz4XzzA/pF0+aicnWgjOdA10doVDEDZdUuZCIIqG96SFNlDUg== - dependencies: - "@wallet-standard/base" "^1.1.0" - -aes-js@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" - integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== - -agentkeepalive@^4.5.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.6.0.tgz#35f73e94b3f40bf65f105219c623ad19c136ea6a" - integrity sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ== - dependencies: - humanize-ms "^1.2.1" - -algo-msgpack-with-bigint@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz#38bb717220525b3ff42232eefdcd9efb9ad405d6" - integrity sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ== - -algosdk@^1.13.1: - version "1.24.1" - resolved "https://registry.yarnpkg.com/algosdk/-/algosdk-1.24.1.tgz#afc4102457ae0c38a32de6b84f4d713aedfc9e89" - integrity sha512-9moZxdqeJ6GdE4N6fA/GlUP4LrbLZMYcYkt141J4Ss68OfEgH9qW0wBuZ3ZOKEx/xjc5bg7mLP2Gjg7nwrkmww== - dependencies: - algo-msgpack-with-bigint "^2.1.1" - buffer "^6.0.2" - cross-fetch "^3.1.5" - hi-base32 "^0.5.1" - js-sha256 "^0.9.0" - js-sha3 "^0.8.0" - js-sha512 "^0.8.0" - json-bigint "^1.0.0" - tweetnacl "^1.0.3" - vlq "^2.0.4" - -ansi-colors@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-escapes@^4.2.1: - version "4.3.2" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" - integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== - dependencies: - type-fest "^0.21.3" - -ansi-regex@=5.0.1, ansi-regex@^4.1.0, ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@=4.3.0, ansi-styles@^4.0.0, ansi-styles@^4.1.0, ansi-styles@^6.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -ansicolors@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" - integrity sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg== - -anymatch@~3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" - integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -arbundles@^0.6.21: - version "0.6.23" - resolved "https://registry.yarnpkg.com/arbundles/-/arbundles-0.6.23.tgz#c00cda953df67fa65d4297486237cc8e0c072c47" - integrity sha512-+gr93F3fivN+6dhiImT6BQNaXz4oECPn2GYjCZjS2yEoq7hM78FRvVp6kQyjEdhnuBFQr/q4oS/nkjnQlHdj9Q== - dependencies: - "@noble/ed25519" "^1.6.1" - "@randlabs/myalgo-connect" "^1.1.2" - "@solana/wallet-adapter-base" "^0.9.2" - algosdk "^1.13.1" - arweave "^1.11.4" - arweave-stream-tx "^1.1.0" - avsc "https://github.com/Irys-xyz/avsc#csp-fixes" - axios "^0.21.3" - base64url "^3.0.1" - bs58 "^4.0.1" - ethers "^5.5.1" - keccak "^3.0.2" - multistream "^4.1.0" - process "^0.11.10" - secp256k1 "^4.0.2" - tmp-promise "^3.0.2" - -arconnect@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/arconnect/-/arconnect-0.4.2.tgz#83de7638fb46183e82d7ec7efb5594c5f7cdc806" - integrity sha512-Jkpd4QL3TVqnd3U683gzXmZUVqBUy17DdJDuL/3D9rkysLgX6ymJ2e+sR+xyZF5Rh42CBqDXWNMmCjBXeP7Gbw== - dependencies: - arweave "^1.10.13" - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -arrify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== - -arweave-stream-tx@^1.1.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/arweave-stream-tx/-/arweave-stream-tx-1.2.2.tgz#2d5c66554301baacd02586a152fbb198b422112f" - integrity sha512-bNt9rj0hbAEzoUZEF2s6WJbIz8nasZlZpxIw03Xm8fzb9gRiiZlZGW3lxQLjfc9Z0VRUWDzwtqoYeEoB/JDToQ== - dependencies: - exponential-backoff "^3.1.0" - -arweave@^1.10.13, arweave@^1.11.4: - version "1.15.7" - resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.15.7.tgz#d09265d128e93a471203649de083ba7fec52cb29" - integrity sha512-F+Y4iWU1qea9IsKQ/YNmLsY4DHQVsaJBuhEbFxQn9cfGHOmtXE+bwo14oY8xqymsqSNf/e1PeIfLk7G7qN/hVA== - dependencies: - arconnect "^0.4.2" - asn1.js "^5.4.1" - base64-js "^1.5.1" - bignumber.js "^9.0.2" - -asn1.js@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - -assert@^2.0.0, assert@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/assert/-/assert-2.1.0.tgz#6d92a238d05dc02e7427c881fb8be81c8448b2dd" - integrity sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw== - dependencies: - call-bind "^1.0.2" - is-nan "^1.3.2" - object-is "^1.1.5" - object.assign "^4.1.4" - util "^0.12.5" - -assertion-error@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" - integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== - -async-retry@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" - integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== - dependencies: - retry "0.13.1" - -available-typed-arrays@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" - integrity sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ== - dependencies: - possible-typed-array-names "^1.0.0" - -"avsc@https://github.com/Irys-xyz/avsc#csp-fixes": - version "5.4.7" - resolved "https://github.com/Irys-xyz/avsc#a730cc8018b79e114b6a3381bbb57760a24c6cef" - -axios@^0.21.3: - version "0.21.4" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" - integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== - dependencies: - follow-redirects "^1.14.0" - -axios@^0.25.0: - version "0.25.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a" - integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g== - dependencies: - follow-redirects "^1.14.7" - -backslash@=0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/backslash/-/backslash-0.2.0.tgz#6c3c1fce7e7e714ccfc10fd74f0f73410677375f" - integrity sha512-Avs+8FUZ1HF/VFP4YWwHQZSGzRPm37ukU1JQYQWijuHhtXdOuAzcZ8PcAzfIw898a8PyBzdn+RtnKA6MzW0X2A== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.2: - version "3.0.11" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff" - integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA== - dependencies: - safe-buffer "^5.0.1" - -base-x@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.1.tgz#817fb7b57143c501f649805cb247617ad016a885" - integrity sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw== - -base64-js@^1.3.1, base64-js@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -base64url@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" - integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== - -bech32@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" - integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== - -bigint-buffer@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" - integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== - dependencies: - bindings "^1.3.0" - -bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.0.2: - version "9.3.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.3.1.tgz#759c5aaddf2ffdc4f154f7b493e1c8770f88c4d7" - integrity sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ== - -binary-extensions@^2.0.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" - integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== - -bindings@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - -bip39-light@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/bip39-light/-/bip39-light-1.0.7.tgz#06a72f251b89389a136d3f177f29b03342adc5ba" - integrity sha512-WDTmLRQUsiioBdTs9BmSEmkJza+8xfJmptsNJjxnoq3EydSa/ZBXT6rm66KoT3PJIRYMnhSKNR7S9YL1l7R40Q== - dependencies: - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - -bip39@3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" - integrity sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ== - dependencies: - "@types/node" "11.11.6" - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - randombytes "^2.0.1" - -bl@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" - integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== - dependencies: - buffer "^5.5.0" - inherits "^2.0.4" - readable-stream "^3.4.0" - -bn.js@5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -bn.js@^4.0.0, bn.js@^4.11.9: - version "4.12.2" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.2.tgz#3d8fed6796c24e177737f7cc5172ee04ef39ec99" - integrity sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw== - -bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: - version "5.2.2" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.2.tgz#82c09f9ebbb17107cd72cb7fd39bd1f9d0aaa566" - integrity sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw== - -borsh@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.6.0.tgz#a7c9eeca6a31ca9e0607cb49f329cb659eb791e1" - integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - -borsh@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" - integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - -brace-expansion@^1.1.7: - version "1.1.12" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" - integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@~3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" - integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== - dependencies: - fill-range "^7.1.1" - -brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== - -browser-stdout@1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" - integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== - -bs58@^4.0.0, bs58@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" - integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== - dependencies: - base-x "^3.0.2" - -bs58@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" - integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== - dependencies: - base-x "^4.0.0" - -buffer-from@^1.0.0, buffer-from@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-layout@^1.2.0, buffer-layout@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" - integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== - -buffer@6.0.3, buffer@^6.0.2, buffer@^6.0.3, buffer@~6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - -buffer@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -bufferutil@^4.0.1: - version "4.0.9" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.9.tgz#6e81739ad48a95cad45a279588e13e95e24a800a" - integrity sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw== - dependencies: - node-gyp-build "^4.3.0" - -call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" - integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== - dependencies: - es-errors "^1.3.0" - function-bind "^1.1.2" - -call-bind@^1.0.0, call-bind@^1.0.2, call-bind@^1.0.7, call-bind@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.8.tgz#0736a9660f537e3388826f440d5ec45f744eaa4c" - integrity sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww== - dependencies: - call-bind-apply-helpers "^1.0.0" - es-define-property "^1.0.0" - get-intrinsic "^1.2.4" - set-function-length "^1.2.2" - -call-bound@^1.0.2, call-bound@^1.0.3, call-bound@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/call-bound/-/call-bound-1.0.4.tgz#238de935d2a2a692928c538c7ccfa91067fd062a" - integrity sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg== - dependencies: - call-bind-apply-helpers "^1.0.2" - get-intrinsic "^1.3.0" - -camelcase@^6.0.0, camelcase@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - -capability@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/capability/-/capability-0.2.5.tgz#51ad87353f1936ffd77f2f21c74633a4dea88801" - integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== - -chai@^4.3.4: - version "4.5.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.5.0.tgz#707e49923afdd9b13a8b0b47d33d732d13812fd8" - integrity sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw== - dependencies: - assertion-error "^1.1.0" - check-error "^1.0.3" - deep-eql "^4.1.3" - get-func-name "^2.0.2" - loupe "^2.3.6" - pathval "^1.1.1" - type-detect "^4.1.0" - -chalk-template@=0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/chalk-template/-/chalk-template-0.4.0.tgz#692c034d0ed62436b9062c1707fadcd0f753204b" - integrity sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg== - dependencies: - chalk "^4.1.2" - -chalk@=4.1.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@^5.3.0, chalk@^5.4.1: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -chardet@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-2.1.1.tgz#5c75593704a642f71ee53717df234031e65373c8" - integrity sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ== - -check-error@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.3.tgz#a6502e4312a7ee969f646e83bb3ddd56281bd694" - integrity sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg== - dependencies: - get-func-name "^2.0.2" - -chokidar@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.7" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.7.tgz#bd094bfef42634ccfd9e13b9fc73274997111e39" - integrity sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA== - dependencies: - inherits "^2.0.4" - safe-buffer "^5.2.1" - to-buffer "^1.2.2" - -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - -cli-spinners@^2.5.0: - version "2.9.2" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" - integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== - -cli-width@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" - integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== - -color-convert@=2.0.1, color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@=2.0.0, color-name@^2.0.0, color-name@~1.1.4: - version "2.0.0" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-2.0.0.tgz#03ff6b1b5aec9bb3cf1ed82400c2790dfcd01d2d" - integrity sha512-SbtvAMWvASO5TE2QP07jHBMXKafgdZz8Vrsrn96fiL+O92/FN/PLARzUW5sKt013fjAprK2d2iCn2hk2Xb5oow== - -color-string@=2.1.0, color-string@^1.9.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-2.1.0.tgz#a1cc4bb16a23032ff1048a2458a170323b15a23f" - integrity sha512-gNVoDzpaSwvftp6Y8nqk97FtZoXP9Yj7KGYB8yIXuv0JcfqbYihTrd1OU5iZW9btfXde4YAOCRySBHT7O910MA== - dependencies: - color-name "^2.0.0" - -color@=4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/color/-/color-4.2.3.tgz#d781ecb5e57224ee43ea9627560107c0e0c6463a" - integrity sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A== - dependencies: - color-convert "^2.0.1" - color-string "^1.9.0" - -commander@^12.1.0: - version "12.1.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" - integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== - -commander@^14.0.0: - version "14.0.2" - resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.2.tgz#b71fd37fe4069e4c3c7c13925252ada4eba14e8e" - integrity sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ== - -commander@^2.20.3: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -commander@^8.2.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" - integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -create-hash@^1.1.0, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@1.1.7, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - -cross-fetch@^3.1.5: - version "3.2.0" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.2.0.tgz#34e9192f53bc757d6614304d9e5e6fb4edb782e3" - integrity sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q== - dependencies: - node-fetch "^2.7.0" - -crypto-hash@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" - integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== - -csv-generate@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/csv-generate/-/csv-generate-4.5.0.tgz#5fbbb89bd9f8ce705871c9baf02e1d4bb4000fb3" - integrity sha512-aQr/vmOKyBSBHNwYhAoXw1+kUsPnMSwmYgpNoo36rIXoG1ecWILnvPGZeQ6oUjzrWknZAD3+jfpqYOBAl4x15A== - -csv-parse@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-6.1.0.tgz#c642ec5b7fc57c1f477a07d179beb5ff0dfd5ed0" - integrity sha512-CEE+jwpgLn+MmtCpVcPtiCZpVtB6Z2OKPTr34pycYYoL7sxdOkXDdQ4lRiw6ioC0q6BLqhc6cKweCVvral8yhw== - -csv-stringify@^6.6.0: - version "6.6.0" - resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-6.6.0.tgz#d384859cfb71d0a4a73c5bcc36a4daf5440cb033" - integrity sha512-YW32lKOmIBgbxtu3g5SaiqWNwa/9ISQt2EcgOq0+RAIFufFp9is6tqNnKahqE5kuKvrnYAzs28r+s6pXJR8Vcw== - -csv@^6.0.5: - version "6.4.1" - resolved "https://registry.yarnpkg.com/csv/-/csv-6.4.1.tgz#c9a62130c025f8adb2a85a75d4c2608612995822" - integrity sha512-ajGosmTGnTwYyGl8STqZDu7R6LkDf3xL39XiOmliV/GufQeVUxHzTKIm4NOBCwmEuujK7B6isxs4Uqt9GcRCvA== - dependencies: - csv-generate "^4.5.0" - csv-parse "^6.1.0" - csv-stringify "^6.6.0" - stream-transform "^3.4.0" - -debug@4.3.3, debug@=4.4.1, debug@^4.3.3, debug@^4.3.4: - version "4.4.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" - integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ== - dependencies: - ms "^2.1.3" - -decamelize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" - integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== - -decimal.js@^10.4.3: - version "10.6.0" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.6.0.tgz#e649a43e3ab953a72192ff5983865e509f37ed9a" - integrity sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg== - -deep-eql@^4.1.3: - version "4.1.4" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.4.tgz#d0d3912865911bb8fac5afb4e3acfa6a28dc72b7" - integrity sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg== - dependencies: - type-detect "^4.0.0" - -defaults@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" - integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== - dependencies: - clone "^1.0.2" - -define-data-property@^1.0.1, define-data-property@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" - integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - gopd "^1.0.1" - -define-properties@^1.1.3, define-properties@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" - integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== - dependencies: - define-data-property "^1.0.1" - has-property-descriptors "^1.0.0" - object-keys "^1.1.1" - -delay@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" - integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== - -depd@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - -diff@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" - integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== - -diff@^3.1.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" - integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== - -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - -dunder-proto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" - integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== - dependencies: - call-bind-apply-helpers "^1.0.1" - es-errors "^1.3.0" - gopd "^1.2.0" - -elliptic@6.6.1, elliptic@^6.5.7: - version "6.6.1" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" - integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -error-ex@=1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" - integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== - dependencies: - is-arrayish "^0.2.1" - -error-polyfill@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/error-polyfill/-/error-polyfill-0.1.3.tgz#df848b61ad8834f7a5db69a70b9913df86721d15" - integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== - dependencies: - capability "^0.2.5" - o3 "^1.0.3" - u3 "^0.1.1" - -es-define-property@^1.0.0, es-define-property@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" - integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== - -es-errors@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" - integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== - -es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz#1c4f2c4837327597ce69d2ca190a7fdd172338c1" - integrity sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA== - dependencies: - es-errors "^1.3.0" - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ== - dependencies: - es6-promise "^4.0.3" - -esbuild@^0.17.15: - version "0.17.19" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" - integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== - optionalDependencies: - "@esbuild/android-arm" "0.17.19" - "@esbuild/android-arm64" "0.17.19" - "@esbuild/android-x64" "0.17.19" - "@esbuild/darwin-arm64" "0.17.19" - "@esbuild/darwin-x64" "0.17.19" - "@esbuild/freebsd-arm64" "0.17.19" - "@esbuild/freebsd-x64" "0.17.19" - "@esbuild/linux-arm" "0.17.19" - "@esbuild/linux-arm64" "0.17.19" - "@esbuild/linux-ia32" "0.17.19" - "@esbuild/linux-loong64" "0.17.19" - "@esbuild/linux-mips64el" "0.17.19" - "@esbuild/linux-ppc64" "0.17.19" - "@esbuild/linux-riscv64" "0.17.19" - "@esbuild/linux-s390x" "0.17.19" - "@esbuild/linux-x64" "0.17.19" - "@esbuild/netbsd-x64" "0.17.19" - "@esbuild/openbsd-x64" "0.17.19" - "@esbuild/sunos-x64" "0.17.19" - "@esbuild/win32-arm64" "0.17.19" - "@esbuild/win32-ia32" "0.17.19" - "@esbuild/win32-x64" "0.17.19" - -escalade@^3.1.1: - version "3.2.0" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" - integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== - -escape-string-regexp@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - -ethers@^5.5.1: - version "5.8.0" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.8.0.tgz#97858dc4d4c74afce83ea7562fe9493cedb4d377" - integrity sha512-DUq+7fHrCg1aPDFCHx6UIPb3nmt2XMpM7Y/g2gLhsl3lIBqeAfOJIl1qEvRf2uq3BiKxmh6Fh5pfp2ieyek7Kg== - dependencies: - "@ethersproject/abi" "5.8.0" - "@ethersproject/abstract-provider" "5.8.0" - "@ethersproject/abstract-signer" "5.8.0" - "@ethersproject/address" "5.8.0" - "@ethersproject/base64" "5.8.0" - "@ethersproject/basex" "5.8.0" - "@ethersproject/bignumber" "5.8.0" - "@ethersproject/bytes" "5.8.0" - "@ethersproject/constants" "5.8.0" - "@ethersproject/contracts" "5.8.0" - "@ethersproject/hash" "5.8.0" - "@ethersproject/hdnode" "5.8.0" - "@ethersproject/json-wallets" "5.8.0" - "@ethersproject/keccak256" "5.8.0" - "@ethersproject/logger" "5.8.0" - "@ethersproject/networks" "5.8.0" - "@ethersproject/pbkdf2" "5.8.0" - "@ethersproject/properties" "5.8.0" - "@ethersproject/providers" "5.8.0" - "@ethersproject/random" "5.8.0" - "@ethersproject/rlp" "5.8.0" - "@ethersproject/sha2" "5.8.0" - "@ethersproject/signing-key" "5.8.0" - "@ethersproject/solidity" "5.8.0" - "@ethersproject/strings" "5.8.0" - "@ethersproject/transactions" "5.8.0" - "@ethersproject/units" "5.8.0" - "@ethersproject/wallet" "5.8.0" - "@ethersproject/web" "5.8.0" - "@ethersproject/wordlists" "5.8.0" - -eventemitter3@^4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -eventemitter3@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" - integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== - -exponential-backoff@^3.1.0: - version "3.1.3" - resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.3.tgz#51cf92c1c0493c766053f9d3abee4434c244d2f6" - integrity sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA== - -eyes@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" - integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ== - -fast-stable-stringify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" - integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== - -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - -fill-range@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" - integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== - dependencies: - to-regex-range "^5.0.1" - -find-up@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^6.0.0" - path-exists "^4.0.0" - -flat@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - -follow-redirects@^1.14.0, follow-redirects@^1.14.7: - version "1.15.11" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340" - integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ== - -for-each@^0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.5.tgz#d650688027826920feeb0af747ee7b9421a41d47" - integrity sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg== - dependencies: - is-callable "^1.2.7" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - -function-bind@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" - integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== - -generator-function@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/generator-function/-/generator-function-2.0.1.tgz#0e75dd410d1243687a0ba2e951b94eedb8f737a2" - integrity sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-func-name@^2.0.1, get-func-name@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" - integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== - -get-intrinsic@^1.2.4, get-intrinsic@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" - integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== - dependencies: - call-bind-apply-helpers "^1.0.2" - es-define-property "^1.0.1" - es-errors "^1.3.0" - es-object-atoms "^1.1.1" - function-bind "^1.1.2" - get-proto "^1.0.1" - gopd "^1.2.0" - has-symbols "^1.1.0" - hasown "^2.0.2" - math-intrinsics "^1.1.0" - -get-proto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" - integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== - dependencies: - dunder-proto "^1.0.1" - es-object-atoms "^1.0.0" - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -gopd@^1.0.1, gopd@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" - integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== - -growl@1.10.5: - version "1.10.5" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" - integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== - -has-ansi@=4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-4.0.1.tgz#f216a8c8d7b129e490dc15f4a62cc1cdb9603ce8" - integrity sha512-Qr4RtTm30xvEdqUXbSBVWDu+PrTokJOwe/FU+VdfJPk+MXAPoeOzKpRyrDTnZIJwAkQ4oBLTU53nu0HrkF/Z2A== - dependencies: - ansi-regex "^4.1.0" - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" - integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== - dependencies: - es-define-property "^1.0.0" - -has-symbols@^1.0.3, has-symbols@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" - integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== - -has-tostringtag@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" - integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== - dependencies: - has-symbols "^1.0.3" - -hash-base@^3.0.0, hash-base@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.2.tgz#79d72def7611c3f6e3c3b5730652638001b10a74" - integrity sha512-Bb33KbowVTIj5s7Ked1OsqHUeCpz//tPwR+E2zJgJKo9Z5XolZ9b6bdUgjmYlwnWhoOQKoTd1TYToZGn5mAYOg== - dependencies: - inherits "^2.0.4" - readable-stream "^2.3.8" - safe-buffer "^5.2.1" - to-buffer "^1.2.1" - -hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - -hasown@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" - integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== - dependencies: - function-bind "^1.1.2" - -he@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - -hi-base32@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/hi-base32/-/hi-base32-0.5.1.tgz#1279f2ddae2673219ea5870c2121d2a33132857e" - integrity sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA== - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -http-errors@^1.7.2: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - -humanize-ms@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" - integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== - dependencies: - ms "^2.0.0" - -iconv-lite@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.7.1.tgz#d4af1d2092f2bb05aab6296e5e7cd286d2f15432" - integrity sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw== - dependencies: - safer-buffer ">= 2.1.2 < 3.0.0" - -ieee754@^1.1.13, ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -inquirer@^8.2.0: - version "8.2.7" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.2.7.tgz#62f6b931a9b7f8735dc42db927316d8fb6f71de8" - integrity sha512-UjOaSel/iddGZJ5xP/Eixh6dY1XghiBw4XK13rCCIJcJfyhhoul/7KhLLUGtebEj6GDYM6Vnx/mVsjx2L/mFIA== - dependencies: - "@inquirer/external-editor" "^1.0.0" - ansi-escapes "^4.2.1" - chalk "^4.1.1" - cli-cursor "^3.1.0" - cli-width "^3.0.0" - figures "^3.0.0" - lodash "^4.17.21" - mute-stream "0.0.8" - ora "^5.4.1" - run-async "^2.4.0" - rxjs "^7.5.5" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - wrap-ansi "^6.0.1" - -invariant@2.2.4: - version "2.2.4" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" - integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== - dependencies: - loose-envify "^1.0.0" - -is-arguments@^1.0.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.2.0.tgz#ad58c6aecf563b78ef2bf04df540da8f5d7d8e1b" - integrity sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA== - dependencies: - call-bound "^1.0.2" - has-tostringtag "^1.0.2" - -is-arrayish@=0.3.2, is-arrayish@^0.2.1, is-arrayish@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" - integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-callable@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" - integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-fullwidth-code-point@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" - integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== - -is-generator-function@^1.0.7: - version "1.1.2" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.1.2.tgz#ae3b61e3d5ea4e4839b90bad22b02335051a17d5" - integrity sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA== - dependencies: - call-bound "^1.0.4" - generator-function "^2.0.0" - get-proto "^1.0.1" - has-tostringtag "^1.0.2" - safe-regex-test "^1.1.0" - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-interactive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" - integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w== - -is-nan@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" - integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-obj@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" - integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== - -is-regex@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.2.1.tgz#76d70a3ed10ef9be48eb577887d74205bf0cad22" - integrity sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g== - dependencies: - call-bound "^1.0.2" - gopd "^1.2.0" - has-tostringtag "^1.0.2" - hasown "^2.0.2" - -is-typed-array@^1.1.14, is-typed-array@^1.1.3: - version "1.1.15" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" - integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== - dependencies: - which-typed-array "^1.1.16" - -is-unicode-supported@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" - integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== - -isarray@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" - integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== - -isomorphic-ws@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" - integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== - -jayson@^4.1.1: - version "4.2.0" - resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.2.0.tgz#b71762393fa40bc9637eaf734ca6f40d3b8c0c93" - integrity sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg== - dependencies: - "@types/connect" "^3.4.33" - "@types/node" "^12.12.54" - "@types/ws" "^7.4.4" - commander "^2.20.3" - delay "^5.0.0" - es6-promisify "^5.0.0" - eyes "^0.1.8" - isomorphic-ws "^4.0.1" - json-stringify-safe "^5.0.1" - stream-json "^1.9.1" - uuid "^8.3.2" - ws "^7.5.10" - -js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - -js-sha3@0.8.0, js-sha3@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - -js-sha512@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4" - integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ== - -"js-tokens@^3.0.0 || ^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" - integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - -js-yaml@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== - dependencies: - argparse "^2.0.1" - -json-bigint@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" - integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== - dependencies: - bignumber.js "^9.0.0" - -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== - -json5@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" - integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== - dependencies: - minimist "^1.2.0" - -keccak@^3.0.2: - version "3.0.4" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" - integrity sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q== - dependencies: - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - readable-stream "^3.6.0" - -locate-path@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" - integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== - dependencies: - p-locate "^5.0.0" - -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log-symbols@4.1.0, log-symbols@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" - integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== - dependencies: - chalk "^4.1.0" - is-unicode-supported "^0.1.0" - -loose-envify@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" - integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== - dependencies: - js-tokens "^3.0.0 || ^4.0.0" - -loupe@^2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.7.tgz#6e69b7d4db7d3ab436328013d37d1c8c3540c697" - integrity sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA== - dependencies: - get-func-name "^2.0.1" - -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -math-intrinsics@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" - integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== - -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== - -minimatch@4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" - integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.0, minimist@^1.2.6: - version "1.2.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" - integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== - -mkdirp@^0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - -mocha@^9.0.3: - version "9.2.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" - integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== - dependencies: - "@ungap/promise-all-settled" "1.1.2" - ansi-colors "4.1.1" - browser-stdout "1.3.1" - chokidar "3.5.3" - debug "4.3.3" - diff "5.0.0" - escape-string-regexp "4.0.0" - find-up "5.0.0" - glob "7.2.0" - growl "1.10.5" - he "1.2.0" - js-yaml "4.1.0" - log-symbols "4.1.0" - minimatch "4.2.1" - ms "2.1.3" - nanoid "3.3.1" - serialize-javascript "6.0.0" - strip-json-comments "3.1.1" - supports-color "8.1.1" - which "2.0.2" - workerpool "6.2.0" - yargs "16.2.0" - yargs-parser "20.2.4" - yargs-unparser "2.0.0" - -ms@2.1.3, ms@^2.0.0, ms@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -multistream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8" - integrity sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw== - dependencies: - once "^1.4.0" - readable-stream "^3.6.0" - -mustache@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" - integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== - -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - -nanoid@3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -near-api-js@^0.44.2: - version "0.44.2" - resolved "https://registry.yarnpkg.com/near-api-js/-/near-api-js-0.44.2.tgz#e451f68f2c56bd885c7b918db5818a3e6e9423d0" - integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== - dependencies: - bn.js "5.2.0" - borsh "^0.6.0" - bs58 "^4.0.0" - depd "^2.0.0" - error-polyfill "^0.1.3" - http-errors "^1.7.2" - js-sha256 "^0.9.0" - mustache "^4.0.0" - node-fetch "^2.6.1" - text-encoding-utf-8 "^1.0.2" - tweetnacl "^1.0.1" - -near-hd-key@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/near-hd-key/-/near-hd-key-1.2.1.tgz#f508ff15436cf8a439b543220f3cc72188a46756" - integrity sha512-SIrthcL5Wc0sps+2e1xGj3zceEa68TgNZDLuCx0daxmfTP7sFTB3/mtE2pYhlFsCxWoMn+JfID5E1NlzvvbRJg== - dependencies: - bip39 "3.0.2" - create-hmac "1.1.7" - tweetnacl "1.0.3" - -near-seed-phrase@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/near-seed-phrase/-/near-seed-phrase-0.2.1.tgz#7d5b54d5e836d295f10b0bdfdae9086443651d20" - integrity sha512-feMuums+kVL3LSuPcP4ld07xHCb2mu6z48SGfP3W+8tl1Qm5xIcjiQzY2IDPBvFgajRDxWSb8GzsRHoInazByw== - dependencies: - bip39-light "^1.0.7" - bs58 "^4.0.1" - near-hd-key "^1.2.1" - tweetnacl "^1.0.2" - -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - -node-addon-api@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" - integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== - -node-addon-api@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" - integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== - -node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: - version "4.8.4" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.4.tgz#8a70ee85464ae52327772a90d66c6077a900cfc8" - integrity sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -o3@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/o3/-/o3-1.0.3.tgz#192ce877a882dfa6751f0412a865fafb2da1dac0" - integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== - dependencies: - capability "^0.2.5" - -object-is@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.6.tgz#1a6a53aed2dd8f7e6775ff870bea58545956ab07" - integrity sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q== - dependencies: - call-bind "^1.0.7" - define-properties "^1.2.1" - -object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.4: - version "4.1.7" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.7.tgz#8c14ca1a424c6a561b0bb2a22f66f5049a945d3d" - integrity sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw== - dependencies: - call-bind "^1.0.8" - call-bound "^1.0.3" - define-properties "^1.2.1" - es-object-atoms "^1.0.0" - has-symbols "^1.1.0" - object-keys "^1.1.1" - -once@^1.3.0, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -onetime@^5.1.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -ora@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18" - integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ== - dependencies: - bl "^4.1.0" - chalk "^4.1.0" - cli-cursor "^3.1.0" - cli-spinners "^2.5.0" - is-interactive "^1.0.0" - is-unicode-supported "^0.1.0" - log-symbols "^4.1.0" - strip-ansi "^6.0.0" - wcwidth "^1.0.1" - -p-limit@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" - integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== - dependencies: - p-limit "^3.0.2" - -pako@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" - integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -pathval@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" - integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== - -pbkdf2@^3.0.9: - version "3.1.5" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.5.tgz#444a59d7a259a95536c56e80c89de31cc01ed366" - integrity sha512-Q3CG/cYvCO1ye4QKkuH7EXxs3VC/rI1/trd+qX2+PolbaKG0H+bgcZzrTt96mMyRtejk+JMCiLUn3y29W8qmFQ== - dependencies: - create-hash "^1.2.0" - create-hmac "^1.1.7" - ripemd160 "^2.0.3" - safe-buffer "^5.2.1" - sha.js "^2.4.12" - to-buffer "^1.2.1" - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -possible-typed-array-names@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz#93e3582bc0e5426586d9d07b79ee40fc841de4ae" - integrity sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg== - -prettier@3.6.2: - version "3.6.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393" - integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ== - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== - -randombytes@^2.0.1, randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -readable-stream@^2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" - integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.4.0, readable-stream@^3.6.0: - version "3.6.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" - integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - -retry@0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - -ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.3.tgz#9be54e4ba5e3559c8eee06a25cd7648bbccdf5a8" - integrity sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA== - dependencies: - hash-base "^3.1.2" - inherits "^2.0.4" - -rpc-websockets@^9.0.2: - version "9.3.2" - resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.3.2.tgz#26b4d7ebaf8e53422528619a3c314e83590d85bf" - integrity sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA== - dependencies: - "@swc/helpers" "^0.5.11" - "@types/uuid" "^8.3.4" - "@types/ws" "^8.2.2" - buffer "^6.0.3" - eventemitter3 "^5.0.1" - uuid "^8.3.2" - ws "^8.5.0" - optionalDependencies: - bufferutil "^4.0.1" - utf-8-validate "^5.0.2" - -run-async@^2.4.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" - integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== - -rxjs@^7.5.5: - version "7.8.2" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.2.tgz#955bc473ed8af11a002a2be52071bf475638607b" - integrity sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA== - dependencies: - tslib "^2.1.0" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-regex-test@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" - integrity sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw== - dependencies: - call-bound "^1.0.2" - es-errors "^1.3.0" - is-regex "^1.2.1" - -"safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -scrypt-js@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - -secp256k1@^4.0.2: - version "4.0.4" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.4.tgz#58f0bfe1830fe777d9ca1ffc7574962a8189f8ab" - integrity sha512-6JfvwvjUOn8F/jUoBY2Q1v5WY5XS+rj8qSe0v8Y4ezH4InLgTEeOOPQsRll9OV429Pvo6BCHGavIyJfr3TAhsw== - dependencies: - elliptic "^6.5.7" - node-addon-api "^5.0.0" - node-gyp-build "^4.2.0" - -serialize-javascript@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -set-function-length@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" - integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== - dependencies: - define-data-property "^1.1.4" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - gopd "^1.0.1" - has-property-descriptors "^1.0.2" - -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - -sha.js@^2.4.0, sha.js@^2.4.12, sha.js@^2.4.8: - version "2.4.12" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.12.tgz#eb8b568bf383dfd1867a32c3f2b74eb52bdbf23f" - integrity sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w== - dependencies: - inherits "^2.0.4" - safe-buffer "^5.2.1" - to-buffer "^1.2.0" - -signal-exit@^3.0.2: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - -simple-swizzle@=0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" - integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg== - dependencies: - is-arrayish "^0.3.1" - -slice-ansi@=5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" - integrity sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ== - dependencies: - ansi-styles "^6.0.0" - is-fullwidth-code-point "^4.0.0" - -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - -solana-bankrun-darwin-arm64@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.2.0.tgz#747e27f38e30d9022c9cccdead2e8d37cf006d55" - integrity sha512-ENQ5Z/CYeY8ZVWIc2VutY/gMlBaHi93/kDw9w0iVwewoV+/YpQmP2irwrshIKu6ggRPTF3Ehlh2V6fGVIYWcXw== - -solana-bankrun-darwin-universal@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.2.0.tgz#5b325b49578d7a9d74b02f7a05741658e46fd073" - integrity sha512-HE45TvZXzBipm1fMn87+fkHeIuQ/KFAi5G/S29y/TLuBYt4RDI935RkWiT0rEQ7KwnwO6Y1aTsOaQXldY5R7uQ== - -solana-bankrun-darwin-x64@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.2.0.tgz#d03eafd69c8dd9a53c84e993660c67cc71d531de" - integrity sha512-42UsVrnac2Oo4UaIDo60zfI3Xn1i8W6fmcc9ixJQZNTtdO8o2/sY4mFxcJx9lhLMhda5FPHrQbGYgYdIs0kK0g== - -solana-bankrun-linux-x64-gnu@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.2.0.tgz#eb133902e78afc5271ba034bd5353ad5f4005c10" - integrity sha512-WnqQjfBBdcI0ZLysjvRStI8gX7vm1c3CI6CC03lgkUztH+Chcq9C4LI9m2M8mXza8Xkn9ryeKAmX36Bx/yoVzg== - -solana-bankrun-linux-x64-musl@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.2.0.tgz#a99c5187f34ab5979c708281da74093c64baab4a" - integrity sha512-8mtf14ZBoah30+MIJBUwb5BlGLRZyK5cZhCkYnC/ROqaIDN8RxMM44NL63gTUIaNHsFwWGA9xR0KSeljeh3PKQ== - -solana-bankrun@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.2.0.tgz#e1df2126ee887b9eae17962f09db18aaa25d736f" - integrity sha512-TS6vYoO/9YJZng7oiLOVyuz8V7yLow5Hp4SLYWW71XM3702v+z9f1fvUBKudRfa4dfpta4tRNufApSiBIALxJQ== - dependencies: - "@solana/web3.js" "^1.68.0" - bs58 "^4.0.1" - optionalDependencies: - solana-bankrun-darwin-arm64 "0.2.0" - solana-bankrun-darwin-universal "0.2.0" - solana-bankrun-darwin-x64 "0.2.0" - solana-bankrun-linux-x64-gnu "0.2.0" - solana-bankrun-linux-x64-musl "0.2.0" - -source-map-support@^0.5.6: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -spl-token-bankrun@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/spl-token-bankrun/-/spl-token-bankrun-0.2.3.tgz#929e7ea8872ad4f2065d97b185b8cb1b92b2366d" - integrity sha512-jQ0V+2GsL6rMrZfqLSbYBtYc5EvdVgsgVeYsZlJLRqrBoVENGve6oDAnJnuiY8JMXGxUs53iYYhG871knI7Vww== - dependencies: - "@solana/spl-token" "^0.3.8" - solana-bankrun "^0.2.0" - -"statuses@>= 1.5.0 < 2": - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - -stream-chain@^2.2.5: - version "2.2.5" - resolved "https://registry.yarnpkg.com/stream-chain/-/stream-chain-2.2.5.tgz#b30967e8f14ee033c5b9a19bbe8a2cba90ba0d09" - integrity sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA== - -stream-json@^1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/stream-json/-/stream-json-1.9.1.tgz#e3fec03e984a503718946c170db7d74556c2a187" - integrity sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw== - dependencies: - stream-chain "^2.2.5" - -stream-transform@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/stream-transform/-/stream-transform-3.4.0.tgz#38d562fbdad38c3b6cda959ad36751014bb26e18" - integrity sha512-QO3OGhKyeIV8p6eRQdG+W6WounFw519zk690hHCNfhgfP9bylVS+NTXsuBc7n+RsGn31UgFPGrWYIgoAbArKEw== - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-ansi@=6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== - -strip-json-comments@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -superstruct@^0.15.4: - version "0.15.5" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" - integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== - -superstruct@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54" - integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A== - -supports-color@8.1.1, supports-color@=7.2.0, supports-color@^7.0.0, supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -supports-hyperlinks@=2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" - integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== - dependencies: - has-flag "^4.0.0" - supports-color "^7.0.0" - -text-encoding-utf-8@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" - integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== - -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== - -tmp-promise@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.3.tgz#60a1a1cc98c988674fcbfd23b6e3367bdeac4ce7" - integrity sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ== - dependencies: - tmp "^0.2.0" - -tmp@^0.2.0: - version "0.2.5" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" - integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== - -to-buffer@^1.2.0, to-buffer@^1.2.1, to-buffer@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.2.2.tgz#ffe59ef7522ada0a2d1cb5dfe03bb8abc3cdc133" - integrity sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw== - dependencies: - isarray "^2.0.5" - safe-buffer "^5.2.1" - typed-array-buffer "^1.0.3" - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - -toml@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" - integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -ts-mocha@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.1.0.tgz#17a1c055f5f7733fd82447c4420740db87221bc8" - integrity sha512-T0C0Xm3/WqCuF2tpa0GNGESTBoKZaiqdUP8guNv4ZY316AFXlyidnrzQ1LUrCT0Wb1i3J0zFTgOh/55Un44WdA== - dependencies: - ts-node "7.0.1" - optionalDependencies: - tsconfig-paths "^3.5.0" - -ts-node@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" - integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== - dependencies: - arrify "^1.0.0" - buffer-from "^1.1.0" - diff "^3.1.0" - make-error "^1.1.1" - minimist "^1.2.0" - mkdirp "^0.5.1" - source-map-support "^0.5.6" - yn "^2.0.0" - -tsconfig-paths@^3.5.0: - version "3.15.0" - resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz#5299ec605e55b1abb23ec939ef15edaf483070d4" - integrity sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg== - dependencies: - "@types/json5" "^0.0.29" - json5 "^1.0.2" - minimist "^1.2.6" - strip-bom "^3.0.0" - -tslib@^2.0.3, tslib@^2.1.0, tslib@^2.8.0: - version "2.8.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" - integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== - -tweetnacl@1.0.3, tweetnacl@^1.0.1, tweetnacl@^1.0.2, tweetnacl@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - -type-detect@^4.0.0, type-detect@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.1.0.tgz#deb2453e8f08dcae7ae98c626b13dddb0155906c" - integrity sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw== - -type-fest@^0.21.3: - version "0.21.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" - integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== - -typed-array-buffer@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536" - integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - is-typed-array "^1.1.14" - -typescript@5.9.3: - version "5.9.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" - integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== - -u3@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/u3/-/u3-0.1.1.tgz#5f52044f42ee76cd8de33148829e14528494b73b" - integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== - -undici-types@~7.16.0: - version "7.16.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" - integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== - -utf-8-validate@^5.0.2: - version "5.0.10" - resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" - integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== - dependencies: - node-gyp-build "^4.3.0" - -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - -util@^0.12.5: - version "0.12.5" - resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" - integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== - dependencies: - inherits "^2.0.3" - is-arguments "^1.0.4" - is-generator-function "^1.0.7" - is-typed-array "^1.1.3" - which-typed-array "^1.1.2" - -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -vlq@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/vlq/-/vlq-2.0.4.tgz#6057b85729245b9829e3cc7755f95b228d4fe041" - integrity sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA== - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== - dependencies: - defaults "^1.0.3" - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which-typed-array@^1.1.16, which-typed-array@^1.1.2: - version "1.1.19" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.19.tgz#df03842e870b6b88e117524a4b364b6fc689f956" - integrity sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw== - dependencies: - available-typed-arrays "^1.0.7" - call-bind "^1.0.8" - call-bound "^1.0.4" - for-each "^0.3.5" - get-proto "^1.0.1" - gopd "^1.2.0" - has-tostringtag "^1.0.2" - -which@2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -workerpool@6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" - integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== - -wrap-ansi@=7.0.0, wrap-ansi@^6.0.1, wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -ws@8.18.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" - integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== - -ws@^7.5.10: - version "7.5.10" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" - integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== - -ws@^8.5.0: - version "8.18.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" - integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yargs-parser@20.2.4: - version "20.2.4" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" - integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs-unparser@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" - integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== - dependencies: - camelcase "^6.0.0" - decamelize "^4.0.0" - flat "^5.0.2" - is-plain-obj "^2.1.0" - -yargs@16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yn@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" - integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ== - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index b7675e285..a8a50defc 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -1,4 +1,8 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; +import { + PERMISSIONLESS_ACCOUNT, + PriceMath, + METADAO_MULTISIG_VAULT, +} from "@metadaoproject/futarchy"; import { ComputeBudgetProgram, PublicKey, @@ -13,7 +17,6 @@ import BN from "bn.js"; import { setupBasicDao } from "../../utils.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; -import { METADAO_MULTISIG_VAULT } from "../../../sdk/src/v0.6/constants.js"; const { Permissions, Permission } = multisig.types; const THOUSAND_BUCK_PRICE = PriceMath.getAmmPrice(1000, 9, 6); diff --git a/tests/futarchy/unit/collectFees.test.ts b/tests/futarchy/unit/collectFees.test.ts index 54fcf27de..fa1e3ecec 100644 --- a/tests/futarchy/unit/collectFees.test.ts +++ b/tests/futarchy/unit/collectFees.test.ts @@ -12,9 +12,8 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import BN from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; -import { METADAO_MULTISIG_VAULT } from "../../../sdk/src/v0.6/constants.js"; export default function suite() { let META: PublicKey, USDC: PublicKey, dao: PublicKey; diff --git a/tests/futarchy/unit/collectMeteoraDammFees.test.ts b/tests/futarchy/unit/collectMeteoraDammFees.test.ts index ba9f459e8..02ece1ed7 100644 --- a/tests/futarchy/unit/collectMeteoraDammFees.test.ts +++ b/tests/futarchy/unit/collectMeteoraDammFees.test.ts @@ -13,6 +13,7 @@ import { LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, + METADAO_MULTISIG_VAULT, } from "@metadaoproject/futarchy"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../../launchpad_v7/utils.js"; @@ -24,7 +25,6 @@ import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, } from "@solana/spl-token"; -import { METADAO_MULTISIG_VAULT } from "../../../sdk/src/v0.7/constants.js"; import { CpAmm } from "@meteora-ag/cp-amm-sdk"; export default function suite() { diff --git a/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts b/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts deleted file mode 100644 index 3eb5f5413..000000000 --- a/tests/priceBasedPerformancePackage/unit/changeLockerAuthority.test.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { - PublicKey, - Keypair, - Transaction, - SystemProgram, -} from "@solana/web3.js"; -import { assert } from "chai"; -import BN from "bn.js"; -import { - getPerformancePackageAddr, - InitializePerformancePackageParams, -} from "@metadaoproject/futarchy"; - -export default function () { - let createKey: Keypair; - let tokenMint: PublicKey; - let tokenAuthority: PublicKey; - let tokenAccount: PublicKey; - let recipient: Keypair; - let currentAuthority: Keypair; - let newAuthority: Keypair; - let performancePackage: PublicKey; - let oracleAccount: Keypair; - - beforeEach(async function () { - // Create test accounts - createKey = Keypair.generate(); - tokenAuthority = this.payer.publicKey; - recipient = Keypair.generate(); - currentAuthority = Keypair.generate(); - newAuthority = Keypair.generate(); - oracleAccount = Keypair.generate(); - - // Fund the accounts with SOL - const fundingTx = new Transaction().add( - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: createKey.publicKey, - lamports: 1000000000, // 1 SOL - }), - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: recipient.publicKey, - lamports: 1000000000, // 1 SOL - }), - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: currentAuthority.publicKey, - lamports: 1000000000, // 1 SOL - }), - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: newAuthority.publicKey, - lamports: 1000000000, // 1 SOL - }), - ); - fundingTx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - fundingTx.sign(this.payer); - await this.banksClient.processTransaction(fundingTx); - - // Create token mint and accounts - tokenMint = await this.createMint(tokenAuthority, 6); - tokenAccount = await this.createTokenAccount(tokenMint, tokenAuthority); - - // Mint tokens to the authority's account - await this.mintTo(tokenMint, tokenAuthority, this.payer, 1000000); // 1M tokens - - // Initialize a performancePackage - const params: InitializePerformancePackageParams = { - minUnlockTimestamp: new BN( - Number((await this.context.banksClient.getClock()).unixTimestamp) + - 3600, - ), - oracleConfig: { - oracleAccount: oracleAccount.publicKey, - byteOffset: 0, - }, - twapLengthSeconds: 3600, - grantee: recipient.publicKey, - performancePackageAuthority: currentAuthority.publicKey, - tranches: [ - { priceThreshold: new BN(1000000), tokenAmount: new BN(100000) }, - ], - }; - - await this.priceBasedPerformancePackage - .initializePerformancePackageIx({ - params, - createKey: createKey.publicKey, - tokenMint, - grantor: tokenAuthority, - grantorTokenAccount: tokenAccount, - }) - .rpc(); - - // Get performancePackage address - performancePackage = getPerformancePackageAddr({ - createKey: createKey.publicKey, - })[0]; - }); - - it("should change performancePackage authority successfully", async function () { - // Verify initial authority - const initialPerformancePackage = - await this.priceBasedPerformancePackage.getPerformancePackage( - performancePackage, - ); - assert.equal( - initialPerformancePackage.performancePackageAuthority.toString(), - currentAuthority.publicKey.toString(), - ); - - // Change the performancePackage authority - const tx = await this.priceBasedPerformancePackage - .changePerformancePackageAuthorityIx({ - performancePackage, - currentAuthority: currentAuthority.publicKey, - newPerformancePackageAuthority: newAuthority.publicKey, - }) - .transaction(); - - tx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - tx.feePayer = currentAuthority.publicKey; - tx.sign(currentAuthority); - await this.banksClient.processTransaction(tx); - - // Verify authority was changed - const updatedPerformancePackage = - await this.priceBasedPerformancePackage.getPerformancePackage( - performancePackage, - ); - assert.equal( - updatedPerformancePackage.performancePackageAuthority.toString(), - newAuthority.publicKey.toString(), - ); - }); - - it("should fail if unauthorized party tries to change authority", async function () { - const unauthorizedWallet = Keypair.generate(); - - // Fund the unauthorized wallet - const fundTx = new Transaction().add( - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: unauthorizedWallet.publicKey, - lamports: 1000000000, // 1 SOL - }), - ); - fundTx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - fundTx.sign(this.payer); - await this.banksClient.processTransaction(fundTx); - - try { - const tx = await this.priceBasedPerformancePackage - .changePerformancePackageAuthorityIx({ - performancePackage, - currentAuthority: unauthorizedWallet.publicKey, - newPerformancePackageAuthority: newAuthority.publicKey, - }) - .transaction(); - - tx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - tx.feePayer = unauthorizedWallet.publicKey; - tx.sign(unauthorizedWallet); - await this.banksClient.processTransaction(tx); - - assert.fail("Should have failed with unauthorized authority change"); - } catch (error) { - assert.include(error.message.toLowerCase(), "0x1778"); - } - }); - - it("should fail if current authority doesn't match performancePackage authority", async function () { - const wrongAuthority = Keypair.generate(); - - // Fund the wrong authority - const fundTx = new Transaction().add( - SystemProgram.transfer({ - fromPubkey: this.payer.publicKey, - toPubkey: wrongAuthority.publicKey, - lamports: 1000000000, // 1 SOL - }), - ); - fundTx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - fundTx.sign(this.payer); - await this.banksClient.processTransaction(fundTx); - - try { - const tx = await this.priceBasedPerformancePackage - .changePerformancePackageAuthorityIx({ - performancePackage, - currentAuthority: wrongAuthority.publicKey, - newPerformancePackageAuthority: newAuthority.publicKey, - }) - .transaction(); - - tx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - tx.feePayer = wrongAuthority.publicKey; - tx.sign(wrongAuthority); - await this.banksClient.processTransaction(tx); - - assert.fail("Should have failed with wrong current authority"); - } catch (error) { - assert.include(error.message.toLowerCase(), "0x1778"); - } - }); - - it("should allow new authority to perform authority actions", async function () { - // First change the authority - const changeTx = await this.priceBasedPerformancePackage - .changePerformancePackageAuthorityIx({ - performancePackage, - currentAuthority: currentAuthority.publicKey, - newPerformancePackageAuthority: newAuthority.publicKey, - }) - .transaction(); - - changeTx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - changeTx.feePayer = currentAuthority.publicKey; - changeTx.sign(currentAuthority); - await this.banksClient.processTransaction(changeTx); - - // Now try to propose a change using the new authority - const pdaNonce = Math.floor(Math.random() * 1000000); - const proposeTx = await this.priceBasedPerformancePackage - .proposeChangeIx({ - params: { - changeType: { - oracle: { - newOracleConfig: { - oracleAccount: Keypair.generate().publicKey, - byteOffset: 8, - }, - }, - }, - pdaNonce: pdaNonce, - }, - performancePackage, - proposer: newAuthority.publicKey, // New authority proposes - }) - .transaction(); - - proposeTx.recentBlockhash = ( - await this.context.banksClient.getLatestBlockhash() - )[0]; - proposeTx.feePayer = newAuthority.publicKey; - proposeTx.sign(newAuthority); - await this.banksClient.processTransaction(proposeTx); - - // Verify the change request was created successfully - const changeRequestAddr = - this.priceBasedPerformancePackage.getChangeRequestAddress( - performancePackage, - newAuthority.publicKey, - pdaNonce, - ); - const changeRequest = - await this.priceBasedPerformancePackage.getChangeRequest( - changeRequestAddr, - ); - assert.isNotNull(changeRequest.proposerType.authority); - }); -} diff --git a/yarn.lock b/yarn.lock index 937d44c21..32b96873a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -974,7 +974,7 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@metadaoproject/futarchy@./sdk2": +"@metadaoproject/futarchy@./sdk": version "0.8.0-alpha.0" dependencies: "@coral-xyz/anchor" "^0.29.0" From 22b51b3844ce2abe94236bf24a05c07ee72066db Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 28 Apr 2026 18:31:13 +0200 Subject: [PATCH 094/100] update workflow to not include sdk2 anymore --- .github/workflows/anchor-test.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/anchor-test.yaml b/.github/workflows/anchor-test.yaml index 445fa6080..9dfdd6f92 100644 --- a/.github/workflows/anchor-test.yaml +++ b/.github/workflows/anchor-test.yaml @@ -28,15 +28,11 @@ jobs: run: | cd sdk yarn install - cd ../sdk2 - yarn install - name: Build SDK run: | cd sdk yarn build - cd ../sdk2 - yarn build - uses: metadaoproject/anchor-test@v2.3 with: From b7909142984fcf0b05ec5416b78290961944bd5e Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 29 Apr 2026 18:24:58 +0200 Subject: [PATCH 095/100] redeploy SDK under new name --- CLAUDE.md | 36 +++++--- package.json | 2 +- scripts/setupFutarchyAmm.ts | 2 +- scripts/v0.3/crankTwap.ts | 4 +- scripts/v0.3/finalizeProposal.ts | 2 +- scripts/v0.3/initializeDao.ts | 2 +- scripts/v0.3/initializeProposal.ts | 2 +- scripts/v0.3/initializeVault.ts | 2 +- scripts/v0.3/uploadMetadata.ts | 4 +- scripts/v0.4/claimAllLaunch.ts | 4 +- scripts/v0.4/finalizeLaunch.ts | 2 +- scripts/v0.4/initializeDao.ts | 2 +- scripts/v0.4/initializeLaunch.ts | 2 +- scripts/v0.4/initializeMetricMarket.ts | 10 +-- scripts/v0.4/initializeProposal.ts | 6 +- scripts/v0.4/startLaunch.ts | 2 +- scripts/v0.4/uploadMetadata.ts | 4 +- scripts/v0.5/assignPermissionlessAccount.ts | 4 +- scripts/v0.5/claimAllLaunch.ts | 4 +- scripts/v0.5/executeProposal.ts | 4 +- scripts/v0.5/finalizeLaunch.ts | 2 +- scripts/v0.5/initializeDao.ts | 4 +- scripts/v0.5/initializeLaunch.ts | 2 +- scripts/v0.5/initializeProposal.ts | 8 +- scripts/v0.5/migrateMeta.ts | 4 +- scripts/v0.5/recoverProposalFunds.ts | 8 +- scripts/v0.5/squads/executeProposal.ts | 2 +- .../v0.5/squads/initalizeTransferProposal.ts | 2 +- scripts/v0.5/squads/removeSpendingLimit.ts | 2 +- scripts/v0.5/squads/updateSpendingLimit.ts | 2 +- scripts/v0.5/startLaunch.ts | 2 +- scripts/v0.6/burnPerformancePackage.ts | 4 +- scripts/v0.6/claimAllLaunch.ts | 2 +- scripts/v0.6/collectMeteoraDammFees.ts | 4 +- scripts/v0.6/createDao.ts | 4 +- scripts/v0.6/dumpDaos.ts | 2 +- scripts/v0.6/dumpDaosProposals.ts | 2 +- scripts/v0.6/executeGeneralProposal.ts | 4 +- scripts/v0.6/executeProposal.ts | 2 +- scripts/v0.6/finalizeLaunch.ts | 2 +- scripts/v0.6/finalizeProposal.ts | 2 +- scripts/v0.6/initializeDao.ts | 4 +- scripts/v0.6/launch.ts | 2 +- scripts/v0.6/launchLoyal.ts | 2 +- scripts/v0.6/launchPaystream.ts | 2 +- scripts/v0.6/launchSOLO.ts | 2 +- scripts/v0.6/launchZKLSOL.ts | 2 +- scripts/v0.6/migrateDaos.ts | 2 +- scripts/v0.6/provideLiquidity.ts | 4 +- scripts/v0.6/returnFunds.ts | 4 +- scripts/v0.7/burnPerformancePackage.ts | 2 +- scripts/v0.7/claimAllLaunch.ts | 2 +- scripts/v0.7/claimLaunchAdditionalTokens.ts | 2 +- scripts/v0.7/closeLaunch.ts | 2 +- scripts/v0.7/collectAllFees.ts | 6 +- scripts/v0.7/collectFees.ts | 4 +- scripts/v0.7/collectMeteoraDammFees.ts | 4 +- scripts/v0.7/completeLaunch.ts | 2 +- scripts/v0.7/dumpDaos.ts | 2 +- scripts/v0.7/dumpLaunches.ts | 2 +- scripts/v0.7/dumpLaunchesAndFundingRecords.ts | 2 +- scripts/v0.7/extendLaunch.ts | 4 +- scripts/v0.7/hurupay/setupLaunch.ts | 2 +- scripts/v0.7/initializePerformancePackage.ts | 2 +- scripts/v0.7/launchP2P.ts | 2 +- scripts/v0.7/launchRNGR.ts | 2 +- scripts/v0.7/launchTemplate.ts | 2 +- .../approveWithPointsWeightedPhase.ts | 2 +- scripts/v0.7/removeProposal.ts | 4 +- scripts/v0.7/resizeDaos.ts | 2 +- scripts/v0.7/resizeLaunches.ts | 2 +- .../v0.7/resizeLaunchesAndFundingRecords.ts | 2 +- scripts/v0.7/startLaunch.ts | 2 +- sdk/README.md | 90 +++++++++++++++++++ sdk/package.json | 4 +- tests/bidWall/main.test.ts | 2 +- tests/bidWall/unit/cancelBidWall.test.ts | 2 +- tests/bidWall/unit/closeBidWall.test.ts | 2 +- tests/bidWall/unit/collectFees.test.ts | 2 +- tests/bidWall/unit/initializeBidWall.test.ts | 2 +- tests/bidWall/unit/sellTokens.test.ts | 2 +- tests/bidWall/utils.ts | 2 +- .../binaryPredictionMarket.test.ts | 2 +- .../multiOptionPredictionMarket.test.ts | 2 +- .../integration/scalarGrantMarket.test.ts | 2 +- tests/conditionalVault/unit.ts | 2 +- .../addMetadataToConditionalTokens.test.ts | 2 +- .../unit/initializeConditionalVault.test.ts | 2 +- .../unit/initializeQuestion.test.ts | 4 +- .../conditionalVault/unit/mergeTokens.test.ts | 2 +- .../unit/redeemTokens.test.ts | 2 +- .../unit/resolveQuestion.test.ts | 2 +- .../conditionalVault/unit/splitTokens.test.ts | 2 +- .../futarchy/integration/fullProposal.test.ts | 2 +- .../futarchy/integration/futarchyAmm.test.ts | 2 +- .../integration/proposalBatchTx.test.ts | 2 +- tests/futarchy/main.test.ts | 2 +- .../unit/adminApproveMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminCancelProposal.test.ts | 2 +- .../unit/adminExecuteMultisigProposal.test.ts | 2 +- .../futarchy/unit/adminRemoveProposal.test.ts | 2 +- tests/futarchy/unit/collectFees.test.ts | 2 +- .../unit/collectMeteoraDammFees.test.ts | 2 +- tests/futarchy/unit/conditionalSwap.test.ts | 2 +- .../unit/executeSpendingLimitChange.test.ts | 2 +- .../unit/finalizeOptimisticProposal.test.ts | 2 +- tests/futarchy/unit/finalizeProposal.test.ts | 2 +- tests/futarchy/unit/initializeDao.test.ts | 2 +- .../futarchy/unit/initializeProposal.test.ts | 2 +- ...itiateVaultSpendOptimisticProposal.test.ts | 2 +- tests/futarchy/unit/launchProposal.test.ts | 2 +- tests/futarchy/unit/provideLiquidity.test.ts | 2 +- .../futarchy/unit/unstakeFromProposal.test.ts | 2 +- tests/futarchy/unit/updateDao.test.ts | 2 +- tests/integration/fullLaunch.test.ts | 2 +- tests/integration/fullLaunch_v7.test.ts | 2 +- tests/integration/mintAndSwap.test.ts | 2 +- tests/launchpad/main.test.ts | 2 +- tests/launchpad/unit/claim.test.ts | 4 +- tests/launchpad/unit/closeLaunch.test.ts | 4 +- tests/launchpad/unit/completeLaunch.test.ts | 4 +- tests/launchpad/unit/fund.test.ts | 4 +- tests/launchpad/unit/initializeLaunch.test.ts | 4 +- tests/launchpad/unit/refund.test.ts | 4 +- tests/launchpad/unit/returnFunds.test.ts | 4 +- tests/launchpad/unit/startLaunch.test.ts | 4 +- tests/launchpad/utils.ts | 2 +- tests/launchpad_v7/main.test.ts | 2 +- tests/launchpad_v7/unit/claim.test.ts | 2 +- .../claimAdditionalTokenAllocation.test.ts | 2 +- tests/launchpad_v7/unit/closeLaunch.test.ts | 2 +- .../launchpad_v7/unit/completeLaunch.test.ts | 2 +- tests/launchpad_v7/unit/extendLaunch.test.ts | 2 +- tests/launchpad_v7/unit/fund.test.ts | 2 +- .../unit/initializeLaunch.test.ts | 4 +- .../unit/initializePerformancePackage.test.ts | 2 +- tests/launchpad_v7/unit/refund.test.ts | 2 +- .../unit/setFundingRecordApproval.test.ts | 2 +- tests/launchpad_v7/unit/startLaunch.test.ts | 4 +- tests/launchpad_v7/utils.ts | 4 +- tests/liquidation/main.test.ts | 2 +- .../unit/activateLiquidation.test.ts | 2 +- .../unit/initializeLiquidation.test.ts | 2 +- tests/liquidation/unit/refund.test.ts | 2 +- .../liquidation/unit/setRefundRecord.test.ts | 2 +- .../unit/withdrawRemainingQuote.test.ts | 2 +- tests/liquidation/utils.ts | 2 +- tests/main.test.ts | 4 +- tests/mintGovernor/main.test.ts | 2 +- .../unit/addMintAuthority.test.ts | 2 +- .../unit/initializeMintGovernor.test.ts | 2 +- tests/mintGovernor/unit/mintTokens.test.ts | 2 +- .../unit/reclaimAuthority.test.ts | 2 +- .../unit/removeMintAuthority.test.ts | 2 +- .../unit/transferAuthorityToGovernor.test.ts | 2 +- .../unit/updateMintAuthority.test.ts | 2 +- .../unit/updateMintGovernorAdmin.test.ts | 2 +- tests/mintGovernor/utils.ts | 2 +- tests/performancePackageV2/main.test.ts | 2 +- .../unit/changeAuthority.test.ts | 2 +- .../unit/closePerformancePackage.test.ts | 2 +- .../unit/completeUnlock.test.ts | 2 +- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 2 +- .../unit/proposeChange.test.ts | 2 +- .../unit/startUnlock.test.ts | 2 +- tests/performancePackageV2/utils.ts | 4 +- .../unit/burnPerformancePackage.test.ts | 2 +- .../unit/completeUnlock.test.ts | 2 +- .../unit/executeChange.test.ts | 2 +- .../unit/initializePerformancePackage.test.ts | 2 +- .../unit/startUnlock.test.ts | 2 +- tests/utils.ts | 2 +- yarn.lock | 4 +- 174 files changed, 337 insertions(+), 233 deletions(-) create mode 100644 sdk/README.md diff --git a/CLAUDE.md b/CLAUDE.md index e8de76b8b..13a1b7caf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -40,8 +40,10 @@ programs/ # Solana programs (Anchor) ├── mint_governor/ # Delegated minting authority management └── damm_v2_cpi/ # Meteora AMM CPI wrapper -sdk/ # TypeScript client library -├── src/v0.3/ - v0.7/ # Versioned SDKs (backward compatible) +sdk/ # TypeScript client library (@metadaoproject/programs) +├── src// # One module per program (futarchy, launchpad, conditional_vault, ...) +│ ├── v0.X/ # Each program is independently versioned +│ └── index.ts # Re-exports the latest version └── package.json tests/ # TypeScript tests (bankrun + mocha) @@ -180,7 +182,7 @@ Always append new error variants to the **end** of `#[error_code]` enums. Anchor ### Adding New Instructions 1. Add instruction to Rust program in `programs/[program]/src/instructions/` -2. Update client methods in SDK (`sdk/src/v0.7/`) +2. Update client methods in the corresponding SDK module at the program's current version (e.g. `sdk/src/futarchy/v0.6/`, `sdk/src/launchpad/v0.7/`) 3. Add unit tests in `tests/[program]/unit/` ### Testing with Bankrun @@ -249,17 +251,29 @@ When designing instructions that involve Squads CPIs, check whether either patte ## SDK Usage -```typescript -// Import versioned clients -import { FutarchyClient, ConditionalVaultClient } from "@metadaoproject/futarchy/v0.7"; +The SDK is published as `@metadaoproject/programs` and is organized **per program**, with each program independently versioned. There is no single SDK-wide version anymore — futarchy is at v0.6, launchpad is at v0.7, conditional_vault is at v0.4, etc. -// Key utilities in sdk/src/v0.7/ -// - constants.ts: Program IDs, MAINNET_USDC, SQUADS_PROGRAM_ID -// - PDA derivation: getDaoAddr, getProposalAddr, etc. -// - PriceMath.getAmmPrice for price calculations +```typescript +// Top-level imports resolve to the latest version of each program (preferred) +import { + FutarchyClient, + LaunchpadClient, + ConditionalVaultClient, + MAINNET_USDC, +} from "@metadaoproject/programs"; + +// Or import from a specific program module +import { FutarchyClient } from "@metadaoproject/programs/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad"; + +// Or pin to a specific version (only when reading historical accounts or +// interacting with an older deployed program) +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; ``` -**Important:** Always use SDK v0.7 imports (`@metadaoproject/futarchy/v0.7`) for new code. Do not use older SDK versions (v0.3-v0.6). +Each program module exports a `Client` class (constructed via `Client.createClient({ provider })`), PDA helpers, and generated Anchor types. Shared utilities (`constants.ts`, top-level `pda.ts`, `AmmMath`) are exported from the package root. + +**Important:** Always use top-level or per-program imports for new code. Only reach for a versioned subpath (e.g. `@metadaoproject/programs/futarchy/v0.6`) when you specifically need an older program version. See `sdk/README.md` for the full layout. ## Key External Dependencies diff --git a/package.json b/package.json index d3c1bc563..cda3e841c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dependencies": { "@coral-xyz/anchor": "=0.29.0", "@inquirer/prompts": "^7.3.3", - "@metadaoproject/futarchy": "./sdk", + "@metadaoproject/programs": "./sdk", "@metaplex-foundation/mpl-token-metadata": "^3.2.0", "@metaplex-foundation/umi": "^0.9.1", "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", diff --git a/scripts/setupFutarchyAmm.ts b/scripts/setupFutarchyAmm.ts index 8802ad284..eb0138491 100644 --- a/scripts/setupFutarchyAmm.ts +++ b/scripts/setupFutarchyAmm.ts @@ -1,7 +1,7 @@ // @ts-nocheck // Legacy script import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient, getDaoAddr } from "@metadaoproject/futarchy/v0.6"; +import { AutocratClient, getDaoAddr } from "@metadaoproject/programs/v0.6"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.3/crankTwap.ts b/scripts/v0.3/crankTwap.ts index fdea3242d..eba1ee94d 100644 --- a/scripts/v0.3/crankTwap.ts +++ b/scripts/v0.3/crankTwap.ts @@ -1,6 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { AmmClient } from "@metadaoproject/futarchy/amm/v0.3"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; +import { AmmClient } from "@metadaoproject/programs/amm/v0.3"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3"; import { PublicKey } from "@solana/web3.js"; const proposal1 = new PublicKey("Dssb1oTTqKjWJTe8QVrStFXxcMZfd7LTSpTRbuHuNdnW"); diff --git a/scripts/v0.3/finalizeProposal.ts b/scripts/v0.3/finalizeProposal.ts index ac917b6da..c3f22a64b 100644 --- a/scripts/v0.3/finalizeProposal.ts +++ b/scripts/v0.3/finalizeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3"; const { PublicKey } = anchor.web3; diff --git a/scripts/v0.3/initializeDao.ts b/scripts/v0.3/initializeDao.ts index 1ffb0162c..3c1a94650 100644 --- a/scripts/v0.3/initializeDao.ts +++ b/scripts/v0.3/initializeDao.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3"; import { DEAN_DEVNET, DEVNET_DARK, diff --git a/scripts/v0.3/initializeProposal.ts b/scripts/v0.3/initializeProposal.ts index d68c3bf51..6358c36c3 100644 --- a/scripts/v0.3/initializeProposal.ts +++ b/scripts/v0.3/initializeProposal.ts @@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import * as token from "@solana/spl-token"; import { LAMPORTS_PER_SOL } from "@solana/web3.js"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3"; const { PublicKey } = anchor.web3; diff --git a/scripts/v0.3/initializeVault.ts b/scripts/v0.3/initializeVault.ts index 69557396b..de578e1d4 100644 --- a/scripts/v0.3/initializeVault.ts +++ b/scripts/v0.3/initializeVault.ts @@ -8,7 +8,7 @@ import { getVaultAddr, getVaultFinalizeMintAddr, getVaultRevertMintAddr, -} from "@metadaoproject/futarchy/conditional_vault/v0.3"; +} from "@metadaoproject/programs/conditional_vault/v0.3"; const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey( "4nCk4qKJSJf8pzJadMnr9LubA6Y7Zw3EacsVqH1TwVXH", diff --git a/scripts/v0.3/uploadMetadata.ts b/scripts/v0.3/uploadMetadata.ts index bc56ef2c0..7595de907 100644 --- a/scripts/v0.3/uploadMetadata.ts +++ b/scripts/v0.3/uploadMetadata.ts @@ -1,7 +1,7 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.3"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.3"; +import { ConditionalVaultClient } from "@metadaoproject/programs/conditional_vault/v0.3"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.3"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.4/claimAllLaunch.ts b/scripts/v0.4/claimAllLaunch.ts index de933927c..0c34db005 100644 --- a/scripts/v0.4/claimAllLaunch.ts +++ b/scripts/v0.4/claimAllLaunch.ts @@ -5,8 +5,8 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.4"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.4"; import { homedir } from "os"; import { join } from "path"; import { input } from "@inquirer/prompts"; diff --git a/scripts/v0.4/finalizeLaunch.ts b/scripts/v0.4/finalizeLaunch.ts index 1c99262f7..245d9fa6d 100644 --- a/scripts/v0.4/finalizeLaunch.ts +++ b/scripts/v0.4/finalizeLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.4"; import { homedir } from "os"; import { join } from "path"; import { input } from "@inquirer/prompts"; diff --git a/scripts/v0.4/initializeDao.ts b/scripts/v0.4/initializeDao.ts index 65737dbc8..b86072286 100644 --- a/scripts/v0.4/initializeDao.ts +++ b/scripts/v0.4/initializeDao.ts @@ -1,6 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; import { Keypair } from "@solana/web3.js"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.4"; import * as token from "@solana/spl-token"; import { BN } from "bn.js"; diff --git a/scripts/v0.4/initializeLaunch.ts b/scripts/v0.4/initializeLaunch.ts index 38a6c05c8..2baf32fb0 100644 --- a/scripts/v0.4/initializeLaunch.ts +++ b/scripts/v0.4/initializeLaunch.ts @@ -5,7 +5,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.4"; +} from "@metadaoproject/programs/launchpad/v0.4"; import { BN } from "bn.js"; import { homedir } from "os"; import { join } from "path"; diff --git a/scripts/v0.4/initializeMetricMarket.ts b/scripts/v0.4/initializeMetricMarket.ts index 29ded17cd..aff33bbd3 100644 --- a/scripts/v0.4/initializeMetricMarket.ts +++ b/scripts/v0.4/initializeMetricMarket.ts @@ -8,11 +8,11 @@ import { getFailAndPassMintAddrs, getQuestionAddr, getVaultAddr, -} from "@metadaoproject/futarchy/conditional_vault/v0.4"; -import { sha256 } from "@metadaoproject/futarchy"; -import { Question } from "@metadaoproject/futarchy/conditional_vault/v0.4"; -import { Amm, AmmClient, getAmmAddr } from "@metadaoproject/futarchy/amm/v0.4"; -import { MAINNET_USDC } from "@metadaoproject/futarchy/"; +} from "@metadaoproject/programs/conditional_vault/v0.4"; +import { sha256 } from "@metadaoproject/programs"; +import { Question } from "@metadaoproject/programs/conditional_vault/v0.4"; +import { Amm, AmmClient, getAmmAddr } from "@metadaoproject/programs/amm/v0.4"; +import { MAINNET_USDC } from "@metadaoproject/programs/"; import { BN } from "bn.js"; import { homedir } from "os"; import { join } from "path"; diff --git a/scripts/v0.4/initializeProposal.ts b/scripts/v0.4/initializeProposal.ts index a57ef6f20..e0dabff53 100644 --- a/scripts/v0.4/initializeProposal.ts +++ b/scripts/v0.4/initializeProposal.ts @@ -4,9 +4,9 @@ import * as anchor from "@coral-xyz/anchor"; import { AutocratClient, AutocratIDL, -} from "@metadaoproject/futarchy/autocrat/v0.4"; -import { PriceMath } from "@metadaoproject/futarchy"; -import { AUTOCRAT_V0_4_PROGRAM_ID } from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs/autocrat/v0.4"; +import { PriceMath } from "@metadaoproject/programs"; +import { AUTOCRAT_V0_4_PROGRAM_ID } from "@metadaoproject/programs"; async function main() { // Initialize clients diff --git a/scripts/v0.4/startLaunch.ts b/scripts/v0.4/startLaunch.ts index f19b877a3..5c432a65d 100644 --- a/scripts/v0.4/startLaunch.ts +++ b/scripts/v0.4/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.4"; import { homedir } from "os"; import { join } from "path"; import fs from "fs"; diff --git a/scripts/v0.4/uploadMetadata.ts b/scripts/v0.4/uploadMetadata.ts index eadbd96b7..cbe525bd1 100644 --- a/scripts/v0.4/uploadMetadata.ts +++ b/scripts/v0.4/uploadMetadata.ts @@ -1,7 +1,7 @@ import { ComputeBudgetProgram, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; +import { ConditionalVaultClient } from "@metadaoproject/programs/conditional_vault/v0.4"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.4"; const provider = anchor.AnchorProvider.env(); const autocrat: AutocratClient = AutocratClient.createClient({ provider }); diff --git a/scripts/v0.5/assignPermissionlessAccount.ts b/scripts/v0.5/assignPermissionlessAccount.ts index 183d2f8c7..3d1b81144 100644 --- a/scripts/v0.5/assignPermissionlessAccount.ts +++ b/scripts/v0.5/assignPermissionlessAccount.ts @@ -1,7 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import { SystemProgram, Transaction } from "@solana/web3.js"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.5"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.5"; async function main() { const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.5/claimAllLaunch.ts b/scripts/v0.5/claimAllLaunch.ts index cd4c44f44..76253c06f 100644 --- a/scripts/v0.5/claimAllLaunch.ts +++ b/scripts/v0.5/claimAllLaunch.ts @@ -5,8 +5,8 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.4"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.4"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.4"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.4"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.5/executeProposal.ts b/scripts/v0.5/executeProposal.ts index 7c97b9452..279482691 100644 --- a/scripts/v0.5/executeProposal.ts +++ b/scripts/v0.5/executeProposal.ts @@ -2,8 +2,8 @@ import * as anchor from "@coral-xyz/anchor"; import { PERMISSIONLESS_ACCOUNT, DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, -} from "@metadaoproject/futarchy"; -import { AutocratClient } from "@metadaoproject/futarchy/autocrat/v0.5"; +} from "@metadaoproject/programs"; +import { AutocratClient } from "@metadaoproject/programs/autocrat/v0.5"; import { Keypair, PublicKey, diff --git a/scripts/v0.5/finalizeLaunch.ts b/scripts/v0.5/finalizeLaunch.ts index 3b2c41fa5..a57989731 100644 --- a/scripts/v0.5/finalizeLaunch.ts +++ b/scripts/v0.5/finalizeLaunch.ts @@ -6,7 +6,7 @@ import { VersionedTransaction, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.5"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.5"; import dotenv from "dotenv"; import { createLookupTableForTransaction } from "../utils/utils.js"; diff --git a/scripts/v0.5/initializeDao.ts b/scripts/v0.5/initializeDao.ts index 196e358e5..1a6bba95b 100644 --- a/scripts/v0.5/initializeDao.ts +++ b/scripts/v0.5/initializeDao.ts @@ -4,11 +4,11 @@ import { MAINNET_USDC, SQUADS_PROGRAM_CONFIG_TREASURY, DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { AutocratClient, getDaoAddr, -} from "@metadaoproject/futarchy/autocrat/v0.5"; +} from "@metadaoproject/programs/autocrat/v0.5"; import { Keypair, PublicKey, diff --git a/scripts/v0.5/initializeLaunch.ts b/scripts/v0.5/initializeLaunch.ts index 416c37a1a..374ac8afc 100644 --- a/scripts/v0.5/initializeLaunch.ts +++ b/scripts/v0.5/initializeLaunch.ts @@ -4,7 +4,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.5"; +} from "@metadaoproject/programs/launchpad/v0.5"; import { BN } from "bn.js"; import { USDC } from "../consts.js"; import { diff --git a/scripts/v0.5/initializeProposal.ts b/scripts/v0.5/initializeProposal.ts index 4847ac794..9c9bce875 100644 --- a/scripts/v0.5/initializeProposal.ts +++ b/scripts/v0.5/initializeProposal.ts @@ -1,13 +1,13 @@ -import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; -import { AmmClient } from "@metadaoproject/futarchy/amm/v0.5"; +import { ConditionalVaultClient } from "@metadaoproject/programs/conditional_vault/v0.4"; +import { AmmClient } from "@metadaoproject/programs/amm/v0.5"; import { AutocratClient, getProposalAddr, -} from "@metadaoproject/futarchy/autocrat/v0.5"; +} from "@metadaoproject/programs/autocrat/v0.5"; import { AUTOCRAT_V0_5_PROGRAM_ID, InstructionUtils, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { LAMPORTS_PER_SOL, Message, diff --git a/scripts/v0.5/migrateMeta.ts b/scripts/v0.5/migrateMeta.ts index 4066493c2..086b0cc8f 100644 --- a/scripts/v0.5/migrateMeta.ts +++ b/scripts/v0.5/migrateMeta.ts @@ -22,11 +22,11 @@ import { MAINNET_USDC, DEVNET_USDC, USDC_DECIMALS, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { AutocratClient, getDaoAddr, -} from "@metadaoproject/futarchy/autocrat/v0.5"; +} from "@metadaoproject/programs/autocrat/v0.5"; import { BN } from "bn.js"; import { assert } from "chai"; import * as multisig from "@sqds/multisig"; diff --git a/scripts/v0.5/recoverProposalFunds.ts b/scripts/v0.5/recoverProposalFunds.ts index 15aa4df07..705662680 100644 --- a/scripts/v0.5/recoverProposalFunds.ts +++ b/scripts/v0.5/recoverProposalFunds.ts @@ -1,10 +1,10 @@ -import { AUTOCRAT_V0_5_PROGRAM_ID } from "@metadaoproject/futarchy"; +import { AUTOCRAT_V0_5_PROGRAM_ID } from "@metadaoproject/programs"; import { AutocratClient, getProposalAddr, -} from "@metadaoproject/futarchy/autocrat/v0.5"; -import { AmmClient } from "@metadaoproject/futarchy/amm/v0.5"; -import { ConditionalVaultClient } from "@metadaoproject/futarchy/conditional_vault/v0.4"; +} from "@metadaoproject/programs/autocrat/v0.5"; +import { AmmClient } from "@metadaoproject/programs/amm/v0.5"; +import { ConditionalVaultClient } from "@metadaoproject/programs/conditional_vault/v0.4"; import { PublicKey } from "@solana/web3.js"; import { BN } from "bn.js"; import * as anchor from "@coral-xyz/anchor"; diff --git a/scripts/v0.5/squads/executeProposal.ts b/scripts/v0.5/squads/executeProposal.ts index 1173d2b30..8aa768bfb 100644 --- a/scripts/v0.5/squads/executeProposal.ts +++ b/scripts/v0.5/squads/executeProposal.ts @@ -1,7 +1,7 @@ import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs/"; import { getSquadsPdasFromDao } from "../../utils/squads.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.5/squads/initalizeTransferProposal.ts b/scripts/v0.5/squads/initalizeTransferProposal.ts index 2013cecb1..f8c7af72d 100644 --- a/scripts/v0.5/squads/initalizeTransferProposal.ts +++ b/scripts/v0.5/squads/initalizeTransferProposal.ts @@ -1,7 +1,7 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { createTransferInstruction, getAssociatedTokenAddressSync, diff --git a/scripts/v0.5/squads/removeSpendingLimit.ts b/scripts/v0.5/squads/removeSpendingLimit.ts index 24a234621..1f9558d15 100644 --- a/scripts/v0.5/squads/removeSpendingLimit.ts +++ b/scripts/v0.5/squads/removeSpendingLimit.ts @@ -1,7 +1,7 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { getSquadsPdasFromDao } from "../../utils/squads.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.5/squads/updateSpendingLimit.ts b/scripts/v0.5/squads/updateSpendingLimit.ts index 51ceaa320..b5cd59bf8 100644 --- a/scripts/v0.5/squads/updateSpendingLimit.ts +++ b/scripts/v0.5/squads/updateSpendingLimit.ts @@ -2,7 +2,7 @@ import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; import { getAssociatedTokenAddress } from "@solana/spl-token"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { getSquadsPdasFromDao } from "../../utils/squads.js"; import { USDC } from "../../consts.js"; diff --git a/scripts/v0.5/startLaunch.ts b/scripts/v0.5/startLaunch.ts index c243ac915..6deb23e21 100644 --- a/scripts/v0.5/startLaunch.ts +++ b/scripts/v0.5/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.5"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.5"; import dotenv from "dotenv"; diff --git a/scripts/v0.6/burnPerformancePackage.ts b/scripts/v0.6/burnPerformancePackage.ts index f20514aeb..597970fa5 100644 --- a/scripts/v0.6/burnPerformancePackage.ts +++ b/scripts/v0.6/burnPerformancePackage.ts @@ -1,10 +1,10 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { PriceBasedPerformancePackageClient } from "@metadaoproject/futarchy/price_based_performance_package/v0.6"; +import { PriceBasedPerformancePackageClient } from "@metadaoproject/programs/price_based_performance_package/v0.6"; import { METADAO_MULTISIG_VAULT, PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; // Set the performance package address before running the script diff --git a/scripts/v0.6/claimAllLaunch.ts b/scripts/v0.6/claimAllLaunch.ts index 9cd004924..4865d04b3 100644 --- a/scripts/v0.6/claimAllLaunch.ts +++ b/scripts/v0.6/claimAllLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.6"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.6/collectMeteoraDammFees.ts b/scripts/v0.6/collectMeteoraDammFees.ts index 5fe4d8b8e..a04755f1a 100644 --- a/scripts/v0.6/collectMeteoraDammFees.ts +++ b/scripts/v0.6/collectMeteoraDammFees.ts @@ -4,8 +4,8 @@ import { CONDITIONAL_VAULT_V0_4_PROGRAM_ID, FUTARCHY_V0_6_PROGRAM_ID, LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG as V0_6_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +} from "@metadaoproject/programs"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.6/createDao.ts b/scripts/v0.6/createDao.ts index 692cfc6c8..d474c69dd 100644 --- a/scripts/v0.6/createDao.ts +++ b/scripts/v0.6/createDao.ts @@ -2,14 +2,14 @@ import * as anchor from "@coral-xyz/anchor"; import { FutarchyClient, getDaoAddr, -} from "@metadaoproject/futarchy/futarchy/v0.6"; +} from "@metadaoproject/programs/futarchy/v0.6"; import { MAINNET_USDC, SQUADS_PROGRAM_CONFIG_TREASURY, DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY, DEVNET_USDC, PriceMath, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/dumpDaos.ts b/scripts/v0.6/dumpDaos.ts index c295c527d..6bc54e479 100644 --- a/scripts/v0.6/dumpDaos.ts +++ b/scripts/v0.6/dumpDaos.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.6/dumpDaosProposals.ts b/scripts/v0.6/dumpDaosProposals.ts index d393e1304..a2c5e1b19 100644 --- a/scripts/v0.6/dumpDaosProposals.ts +++ b/scripts/v0.6/dumpDaosProposals.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.6/executeGeneralProposal.ts b/scripts/v0.6/executeGeneralProposal.ts index 8e3dc1277..1abd10285 100644 --- a/scripts/v0.6/executeGeneralProposal.ts +++ b/scripts/v0.6/executeGeneralProposal.ts @@ -1,8 +1,8 @@ import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; diff --git a/scripts/v0.6/executeProposal.ts b/scripts/v0.6/executeProposal.ts index b618b8866..b46ab5e96 100644 --- a/scripts/v0.6/executeProposal.ts +++ b/scripts/v0.6/executeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { PublicKey, Transaction } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; diff --git a/scripts/v0.6/finalizeLaunch.ts b/scripts/v0.6/finalizeLaunch.ts index eef078fd0..a28d4cac9 100644 --- a/scripts/v0.6/finalizeLaunch.ts +++ b/scripts/v0.6/finalizeLaunch.ts @@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { LaunchpadClient, getLaunchAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, TransactionMessage, diff --git a/scripts/v0.6/finalizeProposal.ts b/scripts/v0.6/finalizeProposal.ts index 6780f2bdc..46f7ffa42 100644 --- a/scripts/v0.6/finalizeProposal.ts +++ b/scripts/v0.6/finalizeProposal.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { PublicKey, Transaction } from "@solana/web3.js"; import { BN } from "@coral-xyz/anchor"; diff --git a/scripts/v0.6/initializeDao.ts b/scripts/v0.6/initializeDao.ts index 6b0a4699c..715047315 100644 --- a/scripts/v0.6/initializeDao.ts +++ b/scripts/v0.6/initializeDao.ts @@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { FutarchyClient, getDaoAddr, -} from "@metadaoproject/futarchy/futarchy/v0.6"; +} from "@metadaoproject/programs/futarchy/v0.6"; import { Keypair, PublicKey, @@ -12,7 +12,7 @@ import { } from "@solana/web3.js"; import BN from "bn.js"; import * as multisig from "@sqds/multisig"; -import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "@metadaoproject/futarchy"; +import { DEVNET_SQUADS_PROGRAM_CONFIG_TREASURY } from "@metadaoproject/programs"; import * as token from "@solana/spl-token"; // DAO DETAILS diff --git a/scripts/v0.6/launch.ts b/scripts/v0.6/launch.ts index 18087c179..9feaa7b84 100644 --- a/scripts/v0.6/launch.ts +++ b/scripts/v0.6/launch.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/launchLoyal.ts b/scripts/v0.6/launchLoyal.ts index d8241b9e6..ce3777d4f 100644 --- a/scripts/v0.6/launchLoyal.ts +++ b/scripts/v0.6/launchLoyal.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/launchPaystream.ts b/scripts/v0.6/launchPaystream.ts index ea3225dfc..0c17ea44b 100644 --- a/scripts/v0.6/launchPaystream.ts +++ b/scripts/v0.6/launchPaystream.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/launchSOLO.ts b/scripts/v0.6/launchSOLO.ts index 3c51e899d..9240d83d6 100644 --- a/scripts/v0.6/launchSOLO.ts +++ b/scripts/v0.6/launchSOLO.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/launchZKLSOL.ts b/scripts/v0.6/launchZKLSOL.ts index d83ca76cd..352bae72a 100644 --- a/scripts/v0.6/launchZKLSOL.ts +++ b/scripts/v0.6/launchZKLSOL.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/migrateDaos.ts b/scripts/v0.6/migrateDaos.ts index 9c99ebd43..ce578031b 100644 --- a/scripts/v0.6/migrateDaos.ts +++ b/scripts/v0.6/migrateDaos.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.6/provideLiquidity.ts b/scripts/v0.6/provideLiquidity.ts index 3c66eb860..2e340302a 100644 --- a/scripts/v0.6/provideLiquidity.ts +++ b/scripts/v0.6/provideLiquidity.ts @@ -1,6 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; -import { MAINNET_USDC, DEVNET_USDC } from "@metadaoproject/futarchy"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; +import { MAINNET_USDC, DEVNET_USDC } from "@metadaoproject/programs"; import { PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.6/returnFunds.ts b/scripts/v0.6/returnFunds.ts index adaaa6624..73cf3968d 100644 --- a/scripts/v0.6/returnFunds.ts +++ b/scripts/v0.6/returnFunds.ts @@ -1,7 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; -import { MAINNET_USDC, METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.6"; +import { MAINNET_USDC, METADAO_MULTISIG_VAULT } from "@metadaoproject/programs"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { BN } from "bn.js"; diff --git a/scripts/v0.7/burnPerformancePackage.ts b/scripts/v0.7/burnPerformancePackage.ts index d65ca4cc0..f813d991b 100644 --- a/scripts/v0.7/burnPerformancePackage.ts +++ b/scripts/v0.7/burnPerformancePackage.ts @@ -4,7 +4,7 @@ import { PRICE_BASED_PERFORMANCE_PACKAGE_PROGRAM_ID, PriceBasedPerformancePackageClient, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; // Set the performance package address before running the script diff --git a/scripts/v0.7/claimAllLaunch.ts b/scripts/v0.7/claimAllLaunch.ts index 004843d3c..de8d5c30c 100644 --- a/scripts/v0.7/claimAllLaunch.ts +++ b/scripts/v0.7/claimAllLaunch.ts @@ -5,7 +5,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; dotenv.config(); diff --git a/scripts/v0.7/claimLaunchAdditionalTokens.ts b/scripts/v0.7/claimLaunchAdditionalTokens.ts index 5036f55d4..e9f3cd87b 100644 --- a/scripts/v0.7/claimLaunchAdditionalTokens.ts +++ b/scripts/v0.7/claimLaunchAdditionalTokens.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.7/closeLaunch.ts b/scripts/v0.7/closeLaunch.ts index e06eece6e..3ed7730a7 100644 --- a/scripts/v0.7/closeLaunch.ts +++ b/scripts/v0.7/closeLaunch.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const provider = anchor.AnchorProvider.env(); diff --git a/scripts/v0.7/collectAllFees.ts b/scripts/v0.7/collectAllFees.ts index 7513e8907..82704c1f8 100644 --- a/scripts/v0.7/collectAllFees.ts +++ b/scripts/v0.7/collectAllFees.ts @@ -1,13 +1,13 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { BidWallClient } from "@metadaoproject/futarchy/bid_wall/v0.7"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { BidWallClient } from "@metadaoproject/programs/bid_wall/v0.7"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, CONDITIONAL_VAULT_V0_4_PROGRAM_ID, FUTARCHY_V0_6_PROGRAM_ID, BID_WALL_V0_7_PROGRAM_ID, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey } from "@solana/web3.js"; import { getAssociatedTokenAddressSync, diff --git a/scripts/v0.7/collectFees.ts b/scripts/v0.7/collectFees.ts index 4534b41f0..f185ff0e0 100644 --- a/scripts/v0.7/collectFees.ts +++ b/scripts/v0.7/collectFees.ts @@ -1,11 +1,11 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { CONDITIONAL_VAULT_V0_4_PROGRAM_ID, FUTARCHY_V0_6_PROGRAM_ID, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey, TransactionMessage } from "@solana/web3.js"; // Set the DAO address before running the script diff --git a/scripts/v0.7/collectMeteoraDammFees.ts b/scripts/v0.7/collectMeteoraDammFees.ts index bbea3d3c6..2049a3bcd 100644 --- a/scripts/v0.7/collectMeteoraDammFees.ts +++ b/scripts/v0.7/collectMeteoraDammFees.ts @@ -4,8 +4,8 @@ import { CONDITIONAL_VAULT_V0_4_PROGRAM_ID, FUTARCHY_V0_6_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +} from "@metadaoproject/programs"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { PublicKey } from "@solana/web3.js"; diff --git a/scripts/v0.7/completeLaunch.ts b/scripts/v0.7/completeLaunch.ts index 13a549ecc..677c4c2d7 100644 --- a/scripts/v0.7/completeLaunch.ts +++ b/scripts/v0.7/completeLaunch.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey, TransactionMessage, diff --git a/scripts/v0.7/dumpDaos.ts b/scripts/v0.7/dumpDaos.ts index 976005dbc..44c697b1a 100644 --- a/scripts/v0.7/dumpDaos.ts +++ b/scripts/v0.7/dumpDaos.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/dumpLaunches.ts b/scripts/v0.7/dumpLaunches.ts index e2485d801..49ccaed04 100644 --- a/scripts/v0.7/dumpLaunches.ts +++ b/scripts/v0.7/dumpLaunches.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/dumpLaunchesAndFundingRecords.ts b/scripts/v0.7/dumpLaunchesAndFundingRecords.ts index 7ba6b723b..68f7b8675 100644 --- a/scripts/v0.7/dumpLaunchesAndFundingRecords.ts +++ b/scripts/v0.7/dumpLaunchesAndFundingRecords.ts @@ -1,6 +1,6 @@ import { PublicKey } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; import * as fs from "fs"; import * as path from "path"; diff --git a/scripts/v0.7/extendLaunch.ts b/scripts/v0.7/extendLaunch.ts index 5e764cc06..f22e8310f 100644 --- a/scripts/v0.7/extendLaunch.ts +++ b/scripts/v0.7/extendLaunch.ts @@ -1,7 +1,7 @@ import * as anchor from "@coral-xyz/anchor"; import * as multisig from "@sqds/multisig"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; -import { METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; +import { METADAO_MULTISIG_VAULT } from "@metadaoproject/programs"; import { PublicKey, Transaction, TransactionMessage } from "@solana/web3.js"; // Set the launch address before running the script diff --git a/scripts/v0.7/hurupay/setupLaunch.ts b/scripts/v0.7/hurupay/setupLaunch.ts index 921b325d7..001ea793b 100644 --- a/scripts/v0.7/hurupay/setupLaunch.ts +++ b/scripts/v0.7/hurupay/setupLaunch.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.7"; +} from "@metadaoproject/programs/launchpad/v0.7"; import { ComputeBudgetProgram, PublicKey, diff --git a/scripts/v0.7/initializePerformancePackage.ts b/scripts/v0.7/initializePerformancePackage.ts index 20c726aee..74dda58af 100644 --- a/scripts/v0.7/initializePerformancePackage.ts +++ b/scripts/v0.7/initializePerformancePackage.ts @@ -1,5 +1,5 @@ import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey } from "@solana/web3.js"; const LAUNCH_TO_COMPLETE: PublicKey | undefined = new PublicKey( diff --git a/scripts/v0.7/launchP2P.ts b/scripts/v0.7/launchP2P.ts index 4ce60c972..b93ba510b 100644 --- a/scripts/v0.7/launchP2P.ts +++ b/scripts/v0.7/launchP2P.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.7"; +} from "@metadaoproject/programs/launchpad/v0.7"; import { ComputeBudgetProgram, PublicKey, diff --git a/scripts/v0.7/launchRNGR.ts b/scripts/v0.7/launchRNGR.ts index a59b172ed..129779085 100644 --- a/scripts/v0.7/launchRNGR.ts +++ b/scripts/v0.7/launchRNGR.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.7"; +} from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.7/launchTemplate.ts b/scripts/v0.7/launchTemplate.ts index bcd59e57e..2c2193f0c 100644 --- a/scripts/v0.7/launchTemplate.ts +++ b/scripts/v0.7/launchTemplate.ts @@ -3,7 +3,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.7"; +} from "@metadaoproject/programs/launchpad/v0.7"; import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import * as token from "@solana/spl-token"; diff --git a/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts b/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts index 02136ec70..ca0611622 100644 --- a/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts +++ b/scripts/v0.7/pointsBased/approveWithPointsWeightedPhase.ts @@ -8,7 +8,7 @@ import { PublicKey, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; import fs from "fs"; import path from "path"; diff --git a/scripts/v0.7/removeProposal.ts b/scripts/v0.7/removeProposal.ts index df59b513c..7adfd6b35 100644 --- a/scripts/v0.7/removeProposal.ts +++ b/scripts/v0.7/removeProposal.ts @@ -1,9 +1,9 @@ import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import { FUTARCHY_V0_6_PROGRAM_ID, CONDITIONAL_VAULT_V0_4_PROGRAM_ID, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey } from "@solana/web3.js"; // Set the proposal address before running the script diff --git a/scripts/v0.7/resizeDaos.ts b/scripts/v0.7/resizeDaos.ts index e0974b042..d11ceb4f3 100644 --- a/scripts/v0.7/resizeDaos.ts +++ b/scripts/v0.7/resizeDaos.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { FutarchyClient } from "@metadaoproject/futarchy/futarchy/v0.6"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/resizeLaunches.ts b/scripts/v0.7/resizeLaunches.ts index 583289f54..38cf0d841 100644 --- a/scripts/v0.7/resizeLaunches.ts +++ b/scripts/v0.7/resizeLaunches.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/resizeLaunchesAndFundingRecords.ts b/scripts/v0.7/resizeLaunchesAndFundingRecords.ts index f239e7130..e6582afc7 100644 --- a/scripts/v0.7/resizeLaunchesAndFundingRecords.ts +++ b/scripts/v0.7/resizeLaunchesAndFundingRecords.ts @@ -6,7 +6,7 @@ import { TransactionMessage, } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; import bs58 from "bs58"; diff --git a/scripts/v0.7/startLaunch.ts b/scripts/v0.7/startLaunch.ts index 229f0dafa..9ebf9dd61 100644 --- a/scripts/v0.7/startLaunch.ts +++ b/scripts/v0.7/startLaunch.ts @@ -1,6 +1,6 @@ import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; import * as anchor from "@coral-xyz/anchor"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.7"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.7"; import dotenv from "dotenv"; diff --git a/sdk/README.md b/sdk/README.md new file mode 100644 index 000000000..231d84760 --- /dev/null +++ b/sdk/README.md @@ -0,0 +1,90 @@ +# @metadaoproject/programs + +TypeScript SDK for the [MetaDAO Futarchy Protocol](https://github.com/metaDAOproject/programs) — a suite of Solana programs for market-driven governance, conditional markets, and token launches. + +## Installation + +```bash +yarn add @metadaoproject/programs +# or +npm install @metadaoproject/programs +# or +bun add @metadaoproject/programs +``` + +## Layout + +The SDK is organized by program. Each program lives in its own module and is internally split into versioned subpaths (`v0.3`, `v0.4`, ...). The top-level module re-exports the **latest** version. + +``` +@metadaoproject/programs +├── amm (re-exports v0.5) +├── autocrat (re-exports v0.5) +├── bid_wall (re-exports v0.7) +├── conditional_vault (re-exports v0.4) +├── futarchy (re-exports v0.6) +├── launchpad (re-exports v0.7, also exposes v0.6 events) +├── liquidation (re-exports v0.7) +├── mint_governor (re-exports v0.7) +├── performance_package_v2 (re-exports v0.7) +├── price_based_performance_package (re-exports v0.6) +└── shared_liquidity_manager (re-exports v0.5) +``` + +Each versioned subpath exports: + +- A `Client` class (e.g. `FutarchyClient`, `LaunchpadClient`, `ConditionalVaultClient`) — the main entry point for building instructions and fetching accounts. +- PDA derivation helpers (`getDaoAddr`, `getProposalAddr`, `getLaunchAddr`, ...). +- Generated Anchor types (accounts, args, IDL). + +The package root also exports shared utilities: program IDs and constants (`MAINNET_USDC`, `SQUADS_PROGRAM_ID`, ...), top-level PDA helpers (`getEventAuthorityAddr`, `getMetadataAddr`), and price math (`AmmMath`). + +## Usage + +### Default (latest version) imports + +```ts +import { + FutarchyClient, + LaunchpadClient, + MAINNET_USDC, +} from "@metadaoproject/programs"; +``` + +### Per-program imports + +```ts +import { FutarchyClient } from "@metadaoproject/programs/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad"; +``` + +### Pinning to a specific version + +```ts +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; +import { ConditionalVaultClient } from "@metadaoproject/programs/conditional_vault/v0.4"; +``` + +### Creating a client + +All clients follow the same construction pattern via a static `createClient` factory and accept an Anchor `AnchorProvider`. Program IDs default to mainnet; pass overrides for devnet or local testing. + +```ts +import { AnchorProvider } from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy"; + +const provider = AnchorProvider.env(); +const futarchy = FutarchyClient.createClient({ provider }); + +const dao = await futarchy.fetchDao(daoAddress); +``` + +## Versioning + +Programs are versioned independently (e.g. futarchy is at v0.6 while launchpad is at v0.7). Older versions remain available under their versioned subpaths so historical accounts can still be read and integrations can migrate at their own pace. New code should use the default (latest) imports. + +See [the main repo README](https://github.com/metaDAOproject/programs/blob/develop/README.md) for the on-chain program IDs deployed to mainnet. + +## License + +BSL-1.0 \ No newline at end of file diff --git a/sdk/package.json b/sdk/package.json index 137a8b4de..8d7bd47a4 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { - "name": "@metadaoproject/futarchy", - "version": "0.8.0-alpha.0", + "name": "@metadaoproject/programs", + "version": "0.1.0-alpha.0", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/tests/bidWall/main.test.ts b/tests/bidWall/main.test.ts index 2a329e308..d288af7d7 100644 --- a/tests/bidWall/main.test.ts +++ b/tests/bidWall/main.test.ts @@ -7,7 +7,7 @@ import { PublicKey } from "@solana/web3.js"; import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; export default function suite() { before(async function () { diff --git a/tests/bidWall/unit/cancelBidWall.test.ts b/tests/bidWall/unit/cancelBidWall.test.ts index 6cc434d9f..25705adb6 100644 --- a/tests/bidWall/unit/cancelBidWall.test.ts +++ b/tests/bidWall/unit/cancelBidWall.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/bidWall/unit/closeBidWall.test.ts b/tests/bidWall/unit/closeBidWall.test.ts index b064aba73..81ebbb718 100644 --- a/tests/bidWall/unit/closeBidWall.test.ts +++ b/tests/bidWall/unit/closeBidWall.test.ts @@ -14,7 +14,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/collectFees.test.ts b/tests/bidWall/unit/collectFees.test.ts index b71f8e26a..6a2e0a7c9 100644 --- a/tests/bidWall/unit/collectFees.test.ts +++ b/tests/bidWall/unit/collectFees.test.ts @@ -13,7 +13,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync, diff --git a/tests/bidWall/unit/initializeBidWall.test.ts b/tests/bidWall/unit/initializeBidWall.test.ts index 761e3ab92..bdd212eaa 100644 --- a/tests/bidWall/unit/initializeBidWall.test.ts +++ b/tests/bidWall/unit/initializeBidWall.test.ts @@ -12,7 +12,7 @@ import { MAINNET_USDC, getBidWallAddr, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/unit/sellTokens.test.ts b/tests/bidWall/unit/sellTokens.test.ts index 1c3f6d5c1..2e47265a1 100644 --- a/tests/bidWall/unit/sellTokens.test.ts +++ b/tests/bidWall/unit/sellTokens.test.ts @@ -12,7 +12,7 @@ import { BidWallClient, MAINNET_USDC, getBidWallAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/bidWall/utils.ts b/tests/bidWall/utils.ts index b0b7dcbf4..fe2f8ce47 100644 --- a/tests/bidWall/utils.ts +++ b/tests/bidWall/utils.ts @@ -5,7 +5,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts index a848a3180..6ae01d2fe 100644 --- a/tests/conditionalVault/integration/binaryPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/binaryPredictionMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts index eba8424cf..ecb79398b 100644 --- a/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts +++ b/tests/conditionalVault/integration/multiOptionPredictionMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/integration/scalarGrantMarket.test.ts b/tests/conditionalVault/integration/scalarGrantMarket.test.ts index 373d0055b..9e81bcb84 100644 --- a/tests/conditionalVault/integration/scalarGrantMarket.test.ts +++ b/tests/conditionalVault/integration/scalarGrantMarket.test.ts @@ -1,4 +1,4 @@ -import { ConditionalVaultClient, sha256 } from "@metadaoproject/futarchy"; +import { ConditionalVaultClient, sha256 } from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; diff --git a/tests/conditionalVault/unit.ts b/tests/conditionalVault/unit.ts index 9a2a1aeb0..f016a4c05 100644 --- a/tests/conditionalVault/unit.ts +++ b/tests/conditionalVault/unit.ts @@ -33,7 +33,7 @@ import { getQuestionAddr, getVaultAddr, sha256, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; export type VaultProgram = anchor.Program; export type PublicKey = anchor.web3.PublicKey; diff --git a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts index 794470265..870cb6ec0 100644 --- a/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts +++ b/tests/conditionalVault/unit/addMetadataToConditionalTokens.test.ts @@ -3,7 +3,7 @@ import { ConditionalVaultClient, getConditionalTokenMintAddr, getMetadataAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeConditionalVault.test.ts b/tests/conditionalVault/unit/initializeConditionalVault.test.ts index c173305eb..5587801c6 100644 --- a/tests/conditionalVault/unit/initializeConditionalVault.test.ts +++ b/tests/conditionalVault/unit/initializeConditionalVault.test.ts @@ -3,7 +3,7 @@ import { getVaultAddr, getConditionalTokenMintAddr, sha256, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { createMint, getMint } from "spl-token-bankrun"; diff --git a/tests/conditionalVault/unit/initializeQuestion.test.ts b/tests/conditionalVault/unit/initializeQuestion.test.ts index 79116a9bb..62aa304dc 100644 --- a/tests/conditionalVault/unit/initializeQuestion.test.ts +++ b/tests/conditionalVault/unit/initializeQuestion.test.ts @@ -2,12 +2,12 @@ import { sha256, ConditionalVaultClient, getQuestionAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; // const { ConditionalVaultClient, getQuestionAddr } = futarchy; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; -// import { getQuestionAddr } from "@metadaoproject/futarchy/dist/v0.4"; +// import { getQuestionAddr } from "@metadaoproject/programs/dist/v0.4"; export default function suite() { let vaultClient: ConditionalVaultClient; diff --git a/tests/conditionalVault/unit/mergeTokens.test.ts b/tests/conditionalVault/unit/mergeTokens.test.ts index 0adc5ee73..fd54c5796 100644 --- a/tests/conditionalVault/unit/mergeTokens.test.ts +++ b/tests/conditionalVault/unit/mergeTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/redeemTokens.test.ts b/tests/conditionalVault/unit/redeemTokens.test.ts index b95a4e56e..15576522a 100644 --- a/tests/conditionalVault/unit/redeemTokens.test.ts +++ b/tests/conditionalVault/unit/redeemTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { diff --git a/tests/conditionalVault/unit/resolveQuestion.test.ts b/tests/conditionalVault/unit/resolveQuestion.test.ts index 7f45bd16a..677fb735c 100644 --- a/tests/conditionalVault/unit/resolveQuestion.test.ts +++ b/tests/conditionalVault/unit/resolveQuestion.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/conditionalVault/unit/splitTokens.test.ts b/tests/conditionalVault/unit/splitTokens.test.ts index 749b39b4c..28160329c 100644 --- a/tests/conditionalVault/unit/splitTokens.test.ts +++ b/tests/conditionalVault/unit/splitTokens.test.ts @@ -1,4 +1,4 @@ -import { sha256, ConditionalVaultClient } from "@metadaoproject/futarchy"; +import { sha256, ConditionalVaultClient } from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { getMint } from "spl-token-bankrun"; diff --git a/tests/futarchy/integration/fullProposal.test.ts b/tests/futarchy/integration/fullProposal.test.ts index e2de48a65..9c065a80b 100644 --- a/tests/futarchy/integration/fullProposal.test.ts +++ b/tests/futarchy/integration/fullProposal.test.ts @@ -1,6 +1,6 @@ // @ts-nocheck // TODO: fix this test and remove the @ts-nocheck -import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { ComputeBudgetProgram, SystemProgram, diff --git a/tests/futarchy/integration/futarchyAmm.test.ts b/tests/futarchy/integration/futarchyAmm.test.ts index a8a50defc..b74c7ede8 100644 --- a/tests/futarchy/integration/futarchyAmm.test.ts +++ b/tests/futarchy/integration/futarchyAmm.test.ts @@ -2,7 +2,7 @@ import { PERMISSIONLESS_ACCOUNT, PriceMath, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/integration/proposalBatchTx.test.ts b/tests/futarchy/integration/proposalBatchTx.test.ts index 520cdc230..ffae04507 100644 --- a/tests/futarchy/integration/proposalBatchTx.test.ts +++ b/tests/futarchy/integration/proposalBatchTx.test.ts @@ -1,6 +1,6 @@ // @ts-nocheck // TODO: fix this test and remove the @ts-nocheck -import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { getDaoAddr, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { ComputeBudgetProgram, SystemProgram, diff --git a/tests/futarchy/main.test.ts b/tests/futarchy/main.test.ts index 918f58123..ee37f0ec5 100644 --- a/tests/futarchy/main.test.ts +++ b/tests/futarchy/main.test.ts @@ -26,7 +26,7 @@ import { PublicKey } from "@solana/web3.js"; import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; export default function suite() { before(async function () { diff --git a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts index 994554678..6c4138553 100644 --- a/tests/futarchy/unit/adminApproveMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminApproveMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/adminCancelProposal.test.ts b/tests/futarchy/unit/adminCancelProposal.test.ts index 6d03d11d6..cea663183 100644 --- a/tests/futarchy/unit/adminCancelProposal.test.ts +++ b/tests/futarchy/unit/adminCancelProposal.test.ts @@ -3,7 +3,7 @@ import { CONDITIONAL_VAULT_V0_4_PROGRAM_ID, SQUADS_PROGRAM_ID, getEventAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts index 9e1d8fc57..55b744f69 100644 --- a/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts +++ b/tests/futarchy/unit/adminExecuteMultisigProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/adminRemoveProposal.test.ts b/tests/futarchy/unit/adminRemoveProposal.test.ts index 567736efc..565313bf9 100644 --- a/tests/futarchy/unit/adminRemoveProposal.test.ts +++ b/tests/futarchy/unit/adminRemoveProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/collectFees.test.ts b/tests/futarchy/unit/collectFees.test.ts index fa1e3ecec..c893e6e7c 100644 --- a/tests/futarchy/unit/collectFees.test.ts +++ b/tests/futarchy/unit/collectFees.test.ts @@ -12,7 +12,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import BN from "bn.js"; import { assert } from "chai"; -import { METADAO_MULTISIG_VAULT } from "@metadaoproject/futarchy"; +import { METADAO_MULTISIG_VAULT } from "@metadaoproject/programs"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; export default function suite() { diff --git a/tests/futarchy/unit/collectMeteoraDammFees.test.ts b/tests/futarchy/unit/collectMeteoraDammFees.test.ts index 02ece1ed7..70adb3cf3 100644 --- a/tests/futarchy/unit/collectMeteoraDammFees.test.ts +++ b/tests/futarchy/unit/collectMeteoraDammFees.test.ts @@ -14,7 +14,7 @@ import { MAINNET_USDC, PERMISSIONLESS_ACCOUNT, METADAO_MULTISIG_VAULT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../../launchpad_v7/utils.js"; import { createLookupTableForTransaction } from "../../utils.js"; diff --git a/tests/futarchy/unit/conditionalSwap.test.ts b/tests/futarchy/unit/conditionalSwap.test.ts index 3b00d1f13..f83f11fba 100644 --- a/tests/futarchy/unit/conditionalSwap.test.ts +++ b/tests/futarchy/unit/conditionalSwap.test.ts @@ -11,7 +11,7 @@ import { import { expectError, setupBasicDao } from "../../utils.js"; import { BN } from "bn.js"; import { assert } from "chai"; -import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT } from "@metadaoproject/programs"; import { MEMO_PROGRAM_ID } from "@solana/spl-memo"; import { ComputeBudget } from "litesvm"; diff --git a/tests/futarchy/unit/executeSpendingLimitChange.test.ts b/tests/futarchy/unit/executeSpendingLimitChange.test.ts index f1bc094a2..da68fc85e 100644 --- a/tests/futarchy/unit/executeSpendingLimitChange.test.ts +++ b/tests/futarchy/unit/executeSpendingLimitChange.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts index 1eedf946e..b3c50f0a0 100644 --- a/tests/futarchy/unit/finalizeOptimisticProposal.test.ts +++ b/tests/futarchy/unit/finalizeOptimisticProposal.test.ts @@ -3,7 +3,7 @@ import { PriceMath, getDaoAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/finalizeProposal.test.ts b/tests/futarchy/unit/finalizeProposal.test.ts index 9f7a5e96d..cf2ea57d4 100644 --- a/tests/futarchy/unit/finalizeProposal.test.ts +++ b/tests/futarchy/unit/finalizeProposal.test.ts @@ -1,4 +1,4 @@ -import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/futarchy"; +import { PERMISSIONLESS_ACCOUNT, PriceMath } from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initializeDao.test.ts b/tests/futarchy/unit/initializeDao.test.ts index 0eb7a5b9b..110c3faae 100644 --- a/tests/futarchy/unit/initializeDao.test.ts +++ b/tests/futarchy/unit/initializeDao.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { expectError } from "../../utils.js"; diff --git a/tests/futarchy/unit/initializeProposal.test.ts b/tests/futarchy/unit/initializeProposal.test.ts index 615c39022..ec3bea394 100644 --- a/tests/futarchy/unit/initializeProposal.test.ts +++ b/tests/futarchy/unit/initializeProposal.test.ts @@ -2,7 +2,7 @@ import { getDaoAddr, PERMISSIONLESS_ACCOUNT, PriceMath, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts index 03ccb889b..db4dd15a0 100644 --- a/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts +++ b/tests/futarchy/unit/initiateVaultSpendOptimisticProposal.test.ts @@ -4,7 +4,7 @@ import { SQUADS_PROGRAM_ID, getDaoAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/launchProposal.test.ts b/tests/futarchy/unit/launchProposal.test.ts index 9aee0cd8c..a2a06198f 100644 --- a/tests/futarchy/unit/launchProposal.test.ts +++ b/tests/futarchy/unit/launchProposal.test.ts @@ -3,7 +3,7 @@ import { PriceMath, getDaoAddr, getProposalAddrV2, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, Keypair, diff --git a/tests/futarchy/unit/provideLiquidity.test.ts b/tests/futarchy/unit/provideLiquidity.test.ts index 2079811f6..006092d7b 100644 --- a/tests/futarchy/unit/provideLiquidity.test.ts +++ b/tests/futarchy/unit/provideLiquidity.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { FUTARCHY_V0_6_PROGRAM_ID } from "@metadaoproject/futarchy"; +import { FUTARCHY_V0_6_PROGRAM_ID } from "@metadaoproject/programs"; import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, diff --git a/tests/futarchy/unit/unstakeFromProposal.test.ts b/tests/futarchy/unit/unstakeFromProposal.test.ts index 818cbe3a6..96a31a728 100644 --- a/tests/futarchy/unit/unstakeFromProposal.test.ts +++ b/tests/futarchy/unit/unstakeFromProposal.test.ts @@ -1,7 +1,7 @@ import { InstructionUtils, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { ComputeBudgetProgram, PublicKey, diff --git a/tests/futarchy/unit/updateDao.test.ts b/tests/futarchy/unit/updateDao.test.ts index 047a4b1a2..50b8fc00e 100644 --- a/tests/futarchy/unit/updateDao.test.ts +++ b/tests/futarchy/unit/updateDao.test.ts @@ -15,7 +15,7 @@ import { PriceMath, MAINNET_USDC, sha256, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; import { setOptimisticGovernanceEnabled } from "../../utils.js"; diff --git a/tests/integration/fullLaunch.test.ts b/tests/integration/fullLaunch.test.ts index 6c47a1057..4c756b6a5 100644 --- a/tests/integration/fullLaunch.test.ts +++ b/tests/integration/fullLaunch.test.ts @@ -12,7 +12,7 @@ import { LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad/utils.js"; import { createLookupTableForTransaction } from "../utils.js"; diff --git a/tests/integration/fullLaunch_v7.test.ts b/tests/integration/fullLaunch_v7.test.ts index d8f671526..5687c10f7 100644 --- a/tests/integration/fullLaunch_v7.test.ts +++ b/tests/integration/fullLaunch_v7.test.ts @@ -13,7 +13,7 @@ import { LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, PERMISSIONLESS_ACCOUNT, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../launchpad_v7/utils.js"; import { createLookupTableForTransaction, expectError } from "../utils.js"; diff --git a/tests/integration/mintAndSwap.test.ts b/tests/integration/mintAndSwap.test.ts index 08435eed3..486268cc4 100644 --- a/tests/integration/mintAndSwap.test.ts +++ b/tests/integration/mintAndSwap.test.ts @@ -2,7 +2,7 @@ import { ConditionalVaultClient, FutarchyClient, InstructionUtils, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { PublicKey, Transaction } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; diff --git a/tests/launchpad/main.test.ts b/tests/launchpad/main.test.ts index df542acd6..0406819d2 100644 --- a/tests/launchpad/main.test.ts +++ b/tests/launchpad/main.test.ts @@ -11,7 +11,7 @@ import { LAUNCHPAD_V0_6_PROGRAM_ID, LAUNCHPAD_V0_6_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; // TODO add a many-outcome integration test diff --git a/tests/launchpad/unit/claim.test.ts b/tests/launchpad/unit/claim.test.ts index aa0595dc9..e85963fad 100644 --- a/tests/launchpad/unit/claim.test.ts +++ b/tests/launchpad/unit/claim.test.ts @@ -8,8 +8,8 @@ import { assert } from "chai"; import { getFundingRecordAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/closeLaunch.test.ts b/tests/launchpad/unit/closeLaunch.test.ts index 6447eb5aa..e7484d846 100644 --- a/tests/launchpad/unit/closeLaunch.test.ts +++ b/tests/launchpad/unit/closeLaunch.test.ts @@ -1,7 +1,7 @@ import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; -import { MAINNET_USDC } from "@metadaoproject/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.6"; +import { MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/completeLaunch.test.ts b/tests/launchpad/unit/completeLaunch.test.ts index e1ae2ead8..1f3de5428 100644 --- a/tests/launchpad/unit/completeLaunch.test.ts +++ b/tests/launchpad/unit/completeLaunch.test.ts @@ -9,12 +9,12 @@ import { FutarchyClient, getMetadataAddr, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { getLiquidityPoolAddr, getRaydiumCpmmLpMintAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad/unit/fund.test.ts b/tests/launchpad/unit/fund.test.ts index 6e8ae1b94..f94641f9f 100644 --- a/tests/launchpad/unit/fund.test.ts +++ b/tests/launchpad/unit/fund.test.ts @@ -3,8 +3,8 @@ import { assert } from "chai"; import { getFundingRecordAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.6"; -import { MAINNET_USDC } from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs/launchpad/v0.6"; +import { MAINNET_USDC } from "@metadaoproject/programs"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad/unit/initializeLaunch.test.ts b/tests/launchpad/unit/initializeLaunch.test.ts index 28662e43e..6ed91c34a 100644 --- a/tests/launchpad/unit/initializeLaunch.test.ts +++ b/tests/launchpad/unit/initializeLaunch.test.ts @@ -9,7 +9,7 @@ import { getLaunchAddr, getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; @@ -18,7 +18,7 @@ import { getMetadataAddr, MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad/unit/refund.test.ts b/tests/launchpad/unit/refund.test.ts index 34414a435..25c2c7cac 100644 --- a/tests/launchpad/unit/refund.test.ts +++ b/tests/launchpad/unit/refund.test.ts @@ -5,8 +5,8 @@ import { VersionedTransaction, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad/unit/returnFunds.test.ts b/tests/launchpad/unit/returnFunds.test.ts index 7c9bea630..dfa22f157 100644 --- a/tests/launchpad/unit/returnFunds.test.ts +++ b/tests/launchpad/unit/returnFunds.test.ts @@ -3,8 +3,8 @@ import { assert } from "chai"; import { getLaunchSignerAddr, LaunchpadClient, -} from "@metadaoproject/futarchy/launchpad/v0.6"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs/launchpad/v0.6"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { createAssociatedTokenAccountIdempotentInstruction, diff --git a/tests/launchpad/unit/startLaunch.test.ts b/tests/launchpad/unit/startLaunch.test.ts index 13e017e8b..36de4c74a 100644 --- a/tests/launchpad/unit/startLaunch.test.ts +++ b/tests/launchpad/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient } from "@metadaoproject/futarchy/launchpad/v0.6"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.6"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +import { FutarchyClient, MAINNET_USDC } from "@metadaoproject/programs"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad/utils.ts b/tests/launchpad/utils.ts index 5e7cd4048..e5e523513 100644 --- a/tests/launchpad/utils.ts +++ b/tests/launchpad/utils.ts @@ -5,7 +5,7 @@ import { LaunchpadClient, getLaunchAddr, getLaunchSignerAddr, -} from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs/launchpad/v0.6"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/launchpad_v7/main.test.ts b/tests/launchpad_v7/main.test.ts index 415b6645f..3bf079920 100644 --- a/tests/launchpad_v7/main.test.ts +++ b/tests/launchpad_v7/main.test.ts @@ -14,7 +14,7 @@ import { LAUNCHPAD_V0_7_PROGRAM_ID, LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; // TODO add a many-outcome integration test diff --git a/tests/launchpad_v7/unit/claim.test.ts b/tests/launchpad_v7/unit/claim.test.ts index 66be40c69..6041b28c7 100644 --- a/tests/launchpad_v7/unit/claim.test.ts +++ b/tests/launchpad_v7/unit/claim.test.ts @@ -11,7 +11,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import BN from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts index 9a3cd3929..2ce6a359d 100644 --- a/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts +++ b/tests/launchpad_v7/unit/claimAdditionalTokenAllocation.test.ts @@ -11,7 +11,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/closeLaunch.test.ts b/tests/launchpad_v7/unit/closeLaunch.test.ts index bcea0585c..58ad4cf1e 100644 --- a/tests/launchpad_v7/unit/closeLaunch.test.ts +++ b/tests/launchpad_v7/unit/closeLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/completeLaunch.test.ts b/tests/launchpad_v7/unit/completeLaunch.test.ts index fa950e615..3805b85c3 100644 --- a/tests/launchpad_v7/unit/completeLaunch.test.ts +++ b/tests/launchpad_v7/unit/completeLaunch.test.ts @@ -11,7 +11,7 @@ import { getMetadataAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/extendLaunch.test.ts b/tests/launchpad_v7/unit/extendLaunch.test.ts index d8b2b46a6..4a893c077 100644 --- a/tests/launchpad_v7/unit/extendLaunch.test.ts +++ b/tests/launchpad_v7/unit/extendLaunch.test.ts @@ -5,7 +5,7 @@ import { Signer, } from "@solana/web3.js"; import { assert } from "chai"; -import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/futarchy"; +import { LaunchpadClient, MAINNET_USDC } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/fund.test.ts b/tests/launchpad_v7/unit/fund.test.ts index 400c286ed..de60a8a46 100644 --- a/tests/launchpad_v7/unit/fund.test.ts +++ b/tests/launchpad_v7/unit/fund.test.ts @@ -9,7 +9,7 @@ import { getFundingRecordAddr, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { getAccount } from "spl-token-bankrun"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; diff --git a/tests/launchpad_v7/unit/initializeLaunch.test.ts b/tests/launchpad_v7/unit/initializeLaunch.test.ts index d0b4942a4..61d309f50 100644 --- a/tests/launchpad_v7/unit/initializeLaunch.test.ts +++ b/tests/launchpad_v7/unit/initializeLaunch.test.ts @@ -12,14 +12,14 @@ import { getLaunchSignerAddr, getMetadataAddr, LaunchpadClient, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import * as token from "@solana/spl-token"; import { MAINNET_USDC, MPL_TOKEN_METADATA_PROGRAM_ID, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { initializeMintWithSeeds } from "../utils.js"; export default function suite() { diff --git a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts index a6dc354b0..f030585c6 100644 --- a/tests/launchpad_v7/unit/initializePerformancePackage.test.ts +++ b/tests/launchpad_v7/unit/initializePerformancePackage.test.ts @@ -13,7 +13,7 @@ import { LaunchpadClient, MAINNET_USDC, PriceBasedPerformancePackageClient, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { deserializeMetadata } from "@metaplex-foundation/mpl-token-metadata"; import { diff --git a/tests/launchpad_v7/unit/refund.test.ts b/tests/launchpad_v7/unit/refund.test.ts index 5126d3bab..e27389604 100644 --- a/tests/launchpad_v7/unit/refund.test.ts +++ b/tests/launchpad_v7/unit/refund.test.ts @@ -10,7 +10,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { initializeMintWithSeeds } from "../utils.js"; diff --git a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts index be2f8d52d..2f1dc186d 100644 --- a/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts +++ b/tests/launchpad_v7/unit/setFundingRecordApproval.test.ts @@ -9,7 +9,7 @@ import { FutarchyClient, LaunchpadClient, MAINNET_USDC, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; import { createLookupTableForTransaction, expectError } from "../../utils.js"; diff --git a/tests/launchpad_v7/unit/startLaunch.test.ts b/tests/launchpad_v7/unit/startLaunch.test.ts index d849ef6c5..8e958e908 100644 --- a/tests/launchpad_v7/unit/startLaunch.test.ts +++ b/tests/launchpad_v7/unit/startLaunch.test.ts @@ -1,10 +1,10 @@ import { Keypair, PublicKey, Signer } from "@solana/web3.js"; import { assert } from "chai"; -import { FutarchyClient, LaunchpadClient } from "@metadaoproject/futarchy"; +import { FutarchyClient, LaunchpadClient } from "@metadaoproject/programs"; import { BN } from "bn.js"; import { initializeMintWithSeeds } from "../utils.js"; -import { MAINNET_USDC } from "@metadaoproject/futarchy"; +import { MAINNET_USDC } from "@metadaoproject/programs"; export default function suite() { let futarchyClient: FutarchyClient; diff --git a/tests/launchpad_v7/utils.ts b/tests/launchpad_v7/utils.ts index 2fcb984d5..3d3af5af3 100644 --- a/tests/launchpad_v7/utils.ts +++ b/tests/launchpad_v7/utils.ts @@ -1,8 +1,8 @@ import { PublicKey, Signer, SystemProgram, Transaction } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { BanksClient } from "solana-bankrun"; -import { LaunchpadClient } from "@metadaoproject/futarchy"; -import { getLaunchAddr, getLaunchSignerAddr } from "@metadaoproject/futarchy"; +import { LaunchpadClient } from "@metadaoproject/programs"; +import { getLaunchAddr, getLaunchSignerAddr } from "@metadaoproject/programs"; export async function initializeMintWithSeeds( banksClient: BanksClient, diff --git a/tests/liquidation/main.test.ts b/tests/liquidation/main.test.ts index 1ca2fca86..2d717d775 100644 --- a/tests/liquidation/main.test.ts +++ b/tests/liquidation/main.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { BankrunProvider } from "anchor-bankrun"; import initializeLiquidation from "./unit/initializeLiquidation.test.js"; import setRefundRecord from "./unit/setRefundRecord.test.js"; diff --git a/tests/liquidation/unit/activateLiquidation.test.ts b/tests/liquidation/unit/activateLiquidation.test.ts index 1bce84268..d099bc168 100644 --- a/tests/liquidation/unit/activateLiquidation.test.ts +++ b/tests/liquidation/unit/activateLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/initializeLiquidation.test.ts b/tests/liquidation/unit/initializeLiquidation.test.ts index d28d40c88..c594f223b 100644 --- a/tests/liquidation/unit/initializeLiquidation.test.ts +++ b/tests/liquidation/unit/initializeLiquidation.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { Keypair } from "@solana/web3.js"; import { assert } from "chai"; import * as token from "@solana/spl-token"; diff --git a/tests/liquidation/unit/refund.test.ts b/tests/liquidation/unit/refund.test.ts index 0d57b9f9c..d53303734 100644 --- a/tests/liquidation/unit/refund.test.ts +++ b/tests/liquidation/unit/refund.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { Keypair, PublicKey, diff --git a/tests/liquidation/unit/setRefundRecord.test.ts b/tests/liquidation/unit/setRefundRecord.test.ts index 5235239c0..89bc8a876 100644 --- a/tests/liquidation/unit/setRefundRecord.test.ts +++ b/tests/liquidation/unit/setRefundRecord.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { Keypair, PublicKey } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/unit/withdrawRemainingQuote.test.ts b/tests/liquidation/unit/withdrawRemainingQuote.test.ts index 93f10d27f..e4138d300 100644 --- a/tests/liquidation/unit/withdrawRemainingQuote.test.ts +++ b/tests/liquidation/unit/withdrawRemainingQuote.test.ts @@ -1,4 +1,4 @@ -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js"; import { assert } from "chai"; import { expectError } from "../../utils.js"; diff --git a/tests/liquidation/utils.ts b/tests/liquidation/utils.ts index 981352315..7eb28ae81 100644 --- a/tests/liquidation/utils.ts +++ b/tests/liquidation/utils.ts @@ -4,7 +4,7 @@ import { ComputeBudgetProgram, SystemProgram, } from "@solana/web3.js"; -import { LiquidationClient } from "@metadaoproject/futarchy"; +import { LiquidationClient } from "@metadaoproject/programs"; import BN from "bn.js"; export async function setupLiquidation(ctx: Mocha.Context): Promise<{ diff --git a/tests/main.test.ts b/tests/main.test.ts index 040fa7b63..3e5a879b1 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -39,8 +39,8 @@ import { LiquidationClient, LOW_FEE_RAYDIUM_CONFIG, sha256, -} from "@metadaoproject/futarchy"; -import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/futarchy/launchpad/v0.6"; +} from "@metadaoproject/programs"; +import { LaunchpadClient as LaunchpadClientV6 } from "@metadaoproject/programs/launchpad/v0.6"; import { PublicKey, diff --git a/tests/mintGovernor/main.test.ts b/tests/mintGovernor/main.test.ts index 9c5394121..1c18af131 100644 --- a/tests/mintGovernor/main.test.ts +++ b/tests/mintGovernor/main.test.ts @@ -6,7 +6,7 @@ import removeMintAuthority from "./unit/removeMintAuthority.test.js"; import mintTokens from "./unit/mintTokens.test.js"; import updateMintGovernorAdmin from "./unit/updateMintGovernorAdmin.test.js"; import reclaimAuthority from "./unit/reclaimAuthority.test.js"; -import { MintGovernorClient } from "@metadaoproject/futarchy"; +import { MintGovernorClient } from "@metadaoproject/programs"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/mintGovernor/unit/addMintAuthority.test.ts b/tests/mintGovernor/unit/addMintAuthority.test.ts index b26b62202..259d4a297 100644 --- a/tests/mintGovernor/unit/addMintAuthority.test.ts +++ b/tests/mintGovernor/unit/addMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/initializeMintGovernor.test.ts b/tests/mintGovernor/unit/initializeMintGovernor.test.ts index ab5ccb690..2adab25f4 100644 --- a/tests/mintGovernor/unit/initializeMintGovernor.test.ts +++ b/tests/mintGovernor/unit/initializeMintGovernor.test.ts @@ -3,7 +3,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { createMintWithAuthority } from "../utils.js"; export default function suite() { diff --git a/tests/mintGovernor/unit/mintTokens.test.ts b/tests/mintGovernor/unit/mintTokens.test.ts index df596d1f8..5eafa6f91 100644 --- a/tests/mintGovernor/unit/mintTokens.test.ts +++ b/tests/mintGovernor/unit/mintTokens.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintWithGovernor, createMintAndGovernor, diff --git a/tests/mintGovernor/unit/reclaimAuthority.test.ts b/tests/mintGovernor/unit/reclaimAuthority.test.ts index f845bb56d..7d187808e 100644 --- a/tests/mintGovernor/unit/reclaimAuthority.test.ts +++ b/tests/mintGovernor/unit/reclaimAuthority.test.ts @@ -5,7 +5,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintWithGovernor, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/removeMintAuthority.test.ts b/tests/mintGovernor/unit/removeMintAuthority.test.ts index 6b965112d..d03d6e00e 100644 --- a/tests/mintGovernor/unit/removeMintAuthority.test.ts +++ b/tests/mintGovernor/unit/removeMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts index dc4ffccc2..2fde6e709 100644 --- a/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts +++ b/tests/mintGovernor/unit/transferAuthorityToGovernor.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import * as token from "@solana/spl-token"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy"; +import { MintGovernorClient } from "@metadaoproject/programs"; import { createMintWithAuthority, createMintAndGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintAuthority.test.ts b/tests/mintGovernor/unit/updateMintAuthority.test.ts index 67fbcdbbd..40ad78884 100644 --- a/tests/mintGovernor/unit/updateMintAuthority.test.ts +++ b/tests/mintGovernor/unit/updateMintAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, getMintAuthorityAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts index 1af8fd1bd..0202055a8 100644 --- a/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts +++ b/tests/mintGovernor/unit/updateMintGovernorAdmin.test.ts @@ -1,7 +1,7 @@ import { Keypair, PublicKey } from "@solana/web3.js"; import BN from "bn.js"; import { assert } from "chai"; -import { MintGovernorClient } from "@metadaoproject/futarchy"; +import { MintGovernorClient } from "@metadaoproject/programs"; import { setupMintWithGovernor } from "../utils.js"; import { expectError } from "../../utils.js"; diff --git a/tests/mintGovernor/utils.ts b/tests/mintGovernor/utils.ts index 0292ba662..a732db38a 100644 --- a/tests/mintGovernor/utils.ts +++ b/tests/mintGovernor/utils.ts @@ -9,7 +9,7 @@ import { BanksClient } from "solana-bankrun"; import { MintGovernorClient, getMintGovernorAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; /** * Creates a mint with the payer as the mint authority diff --git a/tests/performancePackageV2/main.test.ts b/tests/performancePackageV2/main.test.ts index be6e4d601..e6e30a9e4 100644 --- a/tests/performancePackageV2/main.test.ts +++ b/tests/performancePackageV2/main.test.ts @@ -8,7 +8,7 @@ import closePerformancePackage from "./unit/closePerformancePackage.test.js"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { BankrunProvider } from "anchor-bankrun"; export default function suite() { diff --git a/tests/performancePackageV2/unit/changeAuthority.test.ts b/tests/performancePackageV2/unit/changeAuthority.test.ts index 155936537..6357b4b3b 100644 --- a/tests/performancePackageV2/unit/changeAuthority.test.ts +++ b/tests/performancePackageV2/unit/changeAuthority.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/closePerformancePackage.test.ts b/tests/performancePackageV2/unit/closePerformancePackage.test.ts index 11cc5279f..25f4b9ecc 100644 --- a/tests/performancePackageV2/unit/closePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/closePerformancePackage.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/completeUnlock.test.ts b/tests/performancePackageV2/unit/completeUnlock.test.ts index 03fec4be1..1109dc15c 100644 --- a/tests/performancePackageV2/unit/completeUnlock.test.ts +++ b/tests/performancePackageV2/unit/completeUnlock.test.ts @@ -11,7 +11,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, setupMintGovernorWithAuthority, diff --git a/tests/performancePackageV2/unit/executeChange.test.ts b/tests/performancePackageV2/unit/executeChange.test.ts index 1929f7461..b5bb6d78c 100644 --- a/tests/performancePackageV2/unit/executeChange.test.ts +++ b/tests/performancePackageV2/unit/executeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts index ac8348696..a59a2e0a5 100644 --- a/tests/performancePackageV2/unit/initializePerformancePackage.test.ts +++ b/tests/performancePackageV2/unit/initializePerformancePackage.test.ts @@ -5,7 +5,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupMintGovernorWithAuthority, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/proposeChange.test.ts b/tests/performancePackageV2/unit/proposeChange.test.ts index cc2ab6f49..52d761581 100644 --- a/tests/performancePackageV2/unit/proposeChange.test.ts +++ b/tests/performancePackageV2/unit/proposeChange.test.ts @@ -4,7 +4,7 @@ import { assert } from "chai"; import { MintGovernorClient, PerformancePackageV2Client, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/unit/startUnlock.test.ts b/tests/performancePackageV2/unit/startUnlock.test.ts index 5a6eae2b5..98ecc35e1 100644 --- a/tests/performancePackageV2/unit/startUnlock.test.ts +++ b/tests/performancePackageV2/unit/startUnlock.test.ts @@ -5,7 +5,7 @@ import { MintGovernorClient, PerformancePackageV2Client, getPerformancePackageV2Addr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { setupPerformancePackageV2, createCliffLinearReward, diff --git a/tests/performancePackageV2/utils.ts b/tests/performancePackageV2/utils.ts index dec18500f..c9ab04597 100644 --- a/tests/performancePackageV2/utils.ts +++ b/tests/performancePackageV2/utils.ts @@ -16,11 +16,11 @@ import { getPerformancePackageV2Addr, PriceMath, getDaoAddr, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import type { PerformancePackageV2OracleReader, PerformancePackageV2RewardFunction, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; /** * Creates a mint with the specified authority diff --git a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts index 87ff44596..73a0af2b5 100644 --- a/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/burnPerformancePackage.test.ts @@ -7,7 +7,7 @@ import { import { assert } from "chai"; import { mintTo, getAccount } from "spl-token-bankrun"; import BN from "bn.js"; -import { getPerformancePackageAddr, Tranche } from "@metadaoproject/futarchy"; +import { getPerformancePackageAddr, Tranche } from "@metadaoproject/programs"; import { expectError } from "../../utils.js"; import { getAssociatedTokenAddress } from "@solana/spl-token"; diff --git a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts index 2b5f0b8a9..fb5c4416d 100644 --- a/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/completeUnlock.test.ts @@ -8,7 +8,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy"; +import { getPerformancePackageAddr } from "@metadaoproject/programs"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts index 0fda760d7..bf559e515 100644 --- a/tests/priceBasedPerformancePackage/unit/executeChange.test.ts +++ b/tests/priceBasedPerformancePackage/unit/executeChange.test.ts @@ -7,7 +7,7 @@ import { import { assert } from "chai"; import BN from "bn.js"; import { expectError } from "../../utils.js"; -import { getChangeRequestAddr } from "@metadaoproject/futarchy"; +import { getChangeRequestAddr } from "@metadaoproject/programs"; export default function () { let createKey: Keypair; diff --git a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts index f21b1eedb..a88207fdd 100644 --- a/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts +++ b/tests/priceBasedPerformancePackage/unit/initializePerformancePackage.test.ts @@ -11,7 +11,7 @@ import { getPerformancePackageAddr, InitializePerformancePackageParams, Tranche, -} from "@metadaoproject/futarchy"; +} from "@metadaoproject/programs"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts index cb634242d..5cac0ff20 100644 --- a/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts +++ b/tests/priceBasedPerformancePackage/unit/startUnlock.test.ts @@ -10,7 +10,7 @@ import { import { assert } from "chai"; import * as token from "@solana/spl-token"; import BN from "bn.js"; -import { getPerformancePackageAddr } from "@metadaoproject/futarchy"; +import { getPerformancePackageAddr } from "@metadaoproject/programs"; import { expectError } from "../../utils.js"; export default function () { diff --git a/tests/utils.ts b/tests/utils.ts index 6c9e66b31..26a197040 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -10,7 +10,7 @@ import { Transaction, } from "@solana/web3.js"; import { TestContext } from "./main.test.js"; -import { getDaoAddr, PriceMath } from "@metadaoproject/futarchy"; +import { getDaoAddr, PriceMath } from "@metadaoproject/programs"; export const TEN_SECONDS_IN_SLOTS = 25n; export const ONE_MINUTE_IN_SLOTS = TEN_SECONDS_IN_SLOTS * 6n; diff --git a/yarn.lock b/yarn.lock index 32b96873a..90504df33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -974,8 +974,8 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" -"@metadaoproject/futarchy@./sdk": - version "0.8.0-alpha.0" +"@metadaoproject/programs@./sdk": + version "0.1.0-alpha.0" dependencies: "@coral-xyz/anchor" "^0.29.0" "@metaplex-foundation/umi" "^0.9.2" From 01ae38ea295e9f95e7cab0682eb0476779aa56ce Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 29 Apr 2026 23:12:21 +0200 Subject: [PATCH 096/100] remove unused dependencies --- sdk/package.json | 7 +- sdk/yarn.lock | 1591 +--------------------------------------------- yarn.lock | 151 +---- 3 files changed, 22 insertions(+), 1727 deletions(-) diff --git a/sdk/package.json b/sdk/package.json index 8d7bd47a4..996779c06 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -43,16 +43,11 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.29.0", - "@metaplex-foundation/umi": "^0.9.2", - "@metaplex-foundation/umi-bundle-defaults": "^0.9.2", - "@metaplex-foundation/umi-uploader-bundlr": "^0.9.2", "@noble/hashes": "^1.4.0", "@solana/spl-token": "^0.3.7", "@solana/web3.js": "^1.76.0", "@sqds/multisig": "^2.1.4", - "bn.js": "^5.2.1", - "decimal.js": "^10.4.3", - "esbuild": "^0.17.15" + "bn.js": "^5.2.1" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/sdk/yarn.lock b/sdk/yarn.lock index bf1c0f358..2dde4ad19 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -7,31 +7,6 @@ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326" integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ== -"@bundlr-network/client@^0.8.8": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@bundlr-network/client/-/client-0.8.9.tgz#58e969a5d80f8d25d212d46bb7a060730a3c1736" - integrity sha512-SJ7BAt/KhONeFQ0+nbqrw2DUWrsev6y6cmlXt+3x7fPCkw7OJwudtxV/h2nBteZd65NXjqw8yzkmLiLfZ7CCRA== - dependencies: - "@solana/wallet-adapter-base" "^0.9.2" - "@solana/web3.js" "^1.36.0" - "@supercharge/promise-pool" "^2.1.0" - algosdk "^1.13.1" - arbundles "^0.6.21" - arweave "^1.11.4" - async-retry "^1.3.3" - axios "^0.25.0" - base64url "^3.0.1" - bignumber.js "^9.0.1" - bs58 "^4.0.1" - commander "^8.2.0" - csv "^6.0.5" - ethers "^5.5.1" - inquirer "^8.2.0" - js-sha256 "^0.9.0" - mime-types "^2.1.34" - near-api-js "^0.44.2" - near-seed-phrase "^0.2.0" - "@coral-xyz/anchor@^0.29.0": version "0.29.0" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" @@ -60,466 +35,6 @@ bn.js "^5.1.2" buffer-layout "^1.2.0" -"@esbuild/android-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" - integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== - -"@esbuild/android-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" - integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== - -"@esbuild/android-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" - integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== - -"@esbuild/darwin-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" - integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== - -"@esbuild/darwin-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" - integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== - -"@esbuild/freebsd-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" - integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== - -"@esbuild/freebsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" - integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== - -"@esbuild/linux-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" - integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== - -"@esbuild/linux-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" - integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== - -"@esbuild/linux-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" - integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== - -"@esbuild/linux-loong64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" - integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== - -"@esbuild/linux-mips64el@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" - integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== - -"@esbuild/linux-ppc64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" - integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== - -"@esbuild/linux-riscv64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" - integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== - -"@esbuild/linux-s390x@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" - integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== - -"@esbuild/linux-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" - integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== - -"@esbuild/netbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" - integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== - -"@esbuild/openbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" - integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== - -"@esbuild/sunos-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" - integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== - -"@esbuild/win32-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" - integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== - -"@esbuild/win32-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" - integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== - -"@esbuild/win32-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" - integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== - -"@ethersproject/abi@5.8.0", "@ethersproject/abi@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.8.0.tgz#e79bb51940ac35fe6f3262d7fe2cdb25ad5f07d9" - integrity sha512-b9YS/43ObplgyV6SlyQsG53/vkSal0MNA1fskSC4mbnCMi8R+NkcH8K9FPYNESf6jUefBUniE4SOKms0E/KK1Q== - dependencies: - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/abstract-provider@5.8.0", "@ethersproject/abstract-provider@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.8.0.tgz#7581f9be601afa1d02b95d26b9d9840926a35b0c" - integrity sha512-wC9SFcmh4UK0oKuLJQItoQdzS/qZ51EJegK6EmAWlh+OptpQ/npECOR3QqECd8iGHC0RJb4WKbVdSfif4ammrg== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/networks" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/web" "^5.8.0" - -"@ethersproject/abstract-signer@5.8.0", "@ethersproject/abstract-signer@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.8.0.tgz#8d7417e95e4094c1797a9762e6789c7356db0754" - integrity sha512-N0XhZTswXcmIZQdYtUnd79VJzvEwXQw6PK0dTl9VoYrEBxxCPXqS0Eod7q5TNKRxe1/5WUMuR0u0nqTF/avdCA== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - -"@ethersproject/address@5.8.0", "@ethersproject/address@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.8.0.tgz#3007a2c352eee566ad745dca1dbbebdb50a6a983" - integrity sha512-GhH/abcC46LJwshoN+uBNoKVFPxUuZm6dA257z0vZkKmU1+t8xTn8oK7B9qrj8W2rFRMch4gbJl6PmVxjxBEBA== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - -"@ethersproject/base64@5.8.0", "@ethersproject/base64@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.8.0.tgz#61c669c648f6e6aad002c228465d52ac93ee83eb" - integrity sha512-lN0oIwfkYj9LbPx4xEkie6rAMJtySbpOAFXSDVQaBnAzYfB4X2Qr+FXJGxMoc3Bxp2Sm8OwvzMrywxyw0gLjIQ== - dependencies: - "@ethersproject/bytes" "^5.8.0" - -"@ethersproject/basex@5.8.0", "@ethersproject/basex@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.8.0.tgz#1d279a90c4be84d1c1139114a1f844869e57d03a" - integrity sha512-PIgTszMlDRmNwW9nhS6iqtVfdTAKosA7llYXNmGPw4YAI1PUyMv28988wAb41/gHF/WqGdoLv0erHaRcHRKW2Q== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - -"@ethersproject/bignumber@5.8.0", "@ethersproject/bignumber@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.8.0.tgz#c381d178f9eeb370923d389284efa19f69efa5d7" - integrity sha512-ZyaT24bHaSeJon2tGPKIiHszWjD/54Sz8t57Toch475lCLljC6MgPmxk7Gtzz+ddNN5LuHea9qhAe0x3D+uYPA== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - bn.js "^5.2.1" - -"@ethersproject/bytes@5.8.0", "@ethersproject/bytes@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.8.0.tgz#9074820e1cac7507a34372cadeb035461463be34" - integrity sha512-vTkeohgJVCPVHu5c25XWaWQOZ4v+DkGoC42/TS2ond+PARCxTJvgTFUNDZovyQ/uAQ4EcpqqowKydcdmRKjg7A== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/constants@5.8.0", "@ethersproject/constants@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.8.0.tgz#12f31c2f4317b113a4c19de94e50933648c90704" - integrity sha512-wigX4lrf5Vu+axVTIvNsuL6YrV4O5AXl5ubcURKMEME5TnWBouUh0CDTWxZ2GpnRn1kcCgE7l8O5+VbV9QTTcg== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - -"@ethersproject/contracts@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.8.0.tgz#243a38a2e4aa3e757215ea64e276f8a8c9d8ed73" - integrity sha512-0eFjGz9GtuAi6MZwhb4uvUM216F38xiuR0yYCjKJpNfSEy4HUM8hvqqBj9Jmm0IUz8l0xKEhWwLIhPgxNY0yvQ== - dependencies: - "@ethersproject/abi" "^5.8.0" - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - -"@ethersproject/hash@5.8.0", "@ethersproject/hash@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.8.0.tgz#b8893d4629b7f8462a90102572f8cd65a0192b4c" - integrity sha512-ac/lBcTbEWW/VGJij0CNSw/wPcw9bSRgCB0AIBz8CvED/jfvDoV9hsIIiWfvWmFEi8RcXtlNwp2jv6ozWOsooA== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/base64" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/hdnode@5.8.0", "@ethersproject/hdnode@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.8.0.tgz#a51ae2a50bcd48ef6fd108c64cbae5e6ff34a761" - integrity sha512-4bK1VF6E83/3/Im0ERnnUeWOY3P1BZml4ZD3wcH8Ys0/d1h1xaFt6Zc+Dh9zXf9TapGro0T4wvO71UTCp3/uoA== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/basex" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/pbkdf2" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/wordlists" "^5.8.0" - -"@ethersproject/json-wallets@5.8.0", "@ethersproject/json-wallets@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/json-wallets/-/json-wallets-5.8.0.tgz#d18de0a4cf0f185f232eb3c17d5e0744d97eb8c9" - integrity sha512-HxblNck8FVUtNxS3VTEYJAcwiKYsBIF77W15HufqlBF9gGfhmYOJtYZp8fSDZtn9y5EaXTE87zDwzxRoTFk11w== - dependencies: - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hdnode" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/pbkdf2" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - aes-js "3.0.0" - scrypt-js "3.0.1" - -"@ethersproject/keccak256@5.8.0", "@ethersproject/keccak256@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.8.0.tgz#d2123a379567faf2d75d2aaea074ffd4df349e6a" - integrity sha512-A1pkKLZSz8pDaQ1ftutZoaN46I6+jvuqugx5KYNeQOPqq+JZ0Txm7dlWesCHB5cndJSu5vP2VKptKf7cksERng== - dependencies: - "@ethersproject/bytes" "^5.8.0" - js-sha3 "0.8.0" - -"@ethersproject/logger@5.8.0", "@ethersproject/logger@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.8.0.tgz#f0232968a4f87d29623a0481690a2732662713d6" - integrity sha512-Qe6knGmY+zPPWTC+wQrpitodgBfH7XoceCGL5bJVejmH+yCS3R8jJm8iiWuvWbG76RUmyEG53oqv6GMVWqunjA== - -"@ethersproject/networks@5.8.0", "@ethersproject/networks@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.8.0.tgz#8b4517a3139380cba9fb00b63ffad0a979671fde" - integrity sha512-egPJh3aPVAzbHwq8DD7Po53J4OUSsA1MjQp8Vf/OZPav5rlmWUaFLiq8cvQiGK0Z5K6LYzm29+VA/p4RL1FzNg== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/pbkdf2@5.8.0", "@ethersproject/pbkdf2@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.8.0.tgz#cd2621130e5dd51f6a0172e63a6e4a0c0a0ec37e" - integrity sha512-wuHiv97BrzCmfEaPbUFpMjlVg/IDkZThp9Ri88BpjRleg4iePJaj2SW8AIyE8cXn5V1tuAaMj6lzvsGJkGWskg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - -"@ethersproject/properties@5.8.0", "@ethersproject/properties@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.8.0.tgz#405a8affb6311a49a91dabd96aeeae24f477020e" - integrity sha512-PYuiEoQ+FMaZZNGrStmN7+lWjlsoufGIHdww7454FIaGdbe/p5rnaCXTr5MtBYl3NkeoVhHZuyzChPeGeKIpQw== - dependencies: - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/providers@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.8.0.tgz#6c2ae354f7f96ee150439f7de06236928bc04cb4" - integrity sha512-3Il3oTzEx3o6kzcg9ZzbE+oCZYyY+3Zh83sKkn4s1DZfTUjIegHnN2Cm0kbn9YFy45FDVcuCLLONhU7ny0SsCw== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/base64" "^5.8.0" - "@ethersproject/basex" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/networks" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/web" "^5.8.0" - bech32 "1.1.4" - ws "8.18.0" - -"@ethersproject/random@5.8.0", "@ethersproject/random@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.8.0.tgz#1bced04d49449f37c6437c701735a1a022f0057a" - integrity sha512-E4I5TDl7SVqyg4/kkA/qTfuLWAQGXmSOgYyO01So8hLfwgKvYK5snIlzxJMk72IFdG/7oh8yuSqY2KX7MMwg+A== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/rlp@5.8.0", "@ethersproject/rlp@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.8.0.tgz#5a0d49f61bc53e051532a5179472779141451de5" - integrity sha512-LqZgAznqDbiEunaUvykH2JAoXTT9NV0Atqk8rQN9nx9SEgThA/WMx5DnW8a9FOufo//6FZOCHZ+XiClzgbqV9Q== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/sha2@5.8.0", "@ethersproject/sha2@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.8.0.tgz#8954a613bb78dac9b46829c0a95de561ef74e5e1" - integrity sha512-dDOUrXr9wF/YFltgTBYS0tKslPEKr6AekjqDW2dbn1L1xmjGR+9GiKu4ajxovnrDbwxAKdHjW8jNcwfz8PAz4A== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - hash.js "1.1.7" - -"@ethersproject/signing-key@5.8.0", "@ethersproject/signing-key@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.8.0.tgz#9797e02c717b68239c6349394ea85febf8893119" - integrity sha512-LrPW2ZxoigFi6U6aVkFN/fa9Yx/+4AtIUe4/HACTvKJdhm0eeb107EVCIQcrLZkxaSIgc/eCrX8Q1GtbH+9n3w== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - bn.js "^5.2.1" - elliptic "6.6.1" - hash.js "1.1.7" - -"@ethersproject/solidity@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.8.0.tgz#429bb9fcf5521307a9448d7358c26b93695379b9" - integrity sha512-4CxFeCgmIWamOHwYN9d+QWGxye9qQLilpgTU0XhYs1OahkclF+ewO+3V1U0mvpiuQxm5EHHmv8f7ClVII8EHsA== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/sha2" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/strings@5.8.0", "@ethersproject/strings@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.8.0.tgz#ad79fafbf0bd272d9765603215ac74fd7953908f" - integrity sha512-qWEAk0MAvl0LszjdfnZ2uC8xbR2wdv4cDabyHiBh3Cldq/T8dPH3V4BbBsAYJUeonwD+8afVXld274Ls+Y1xXg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/transactions@5.8.0", "@ethersproject/transactions@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.8.0.tgz#1e518822403abc99def5a043d1c6f6fe0007e46b" - integrity sha512-UglxSDjByHG0TuU17bDfCemZ3AnKO2vYrL5/2n2oXvKzvb7Cz+W9gOWXKARjp2URVwcWlQlPOEQyAviKwT4AHg== - dependencies: - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/rlp" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - -"@ethersproject/units@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.8.0.tgz#c12f34ba7c3a2de0e9fa0ed0ee32f3e46c5c2c6a" - integrity sha512-lxq0CAnc5kMGIiWW4Mr041VT8IhNM+Pn5T3haO74XZWFulk7wH1Gv64HqE96hT4a7iiNMdOCFEBgaxWuk8ETKQ== - dependencies: - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/constants" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - -"@ethersproject/wallet@5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.8.0.tgz#49c300d10872e6986d953e8310dc33d440da8127" - integrity sha512-G+jnzmgg6UxurVKRKvw27h0kvG75YKXZKdlLYmAHeF32TGUzHkOFd7Zn6QHOTYRFWnfjtSSFjBowKo7vfrXzPA== - dependencies: - "@ethersproject/abstract-provider" "^5.8.0" - "@ethersproject/abstract-signer" "^5.8.0" - "@ethersproject/address" "^5.8.0" - "@ethersproject/bignumber" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/hdnode" "^5.8.0" - "@ethersproject/json-wallets" "^5.8.0" - "@ethersproject/keccak256" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/random" "^5.8.0" - "@ethersproject/signing-key" "^5.8.0" - "@ethersproject/transactions" "^5.8.0" - "@ethersproject/wordlists" "^5.8.0" - -"@ethersproject/web@5.8.0", "@ethersproject/web@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.8.0.tgz#3e54badc0013b7a801463a7008a87988efce8a37" - integrity sha512-j7+Ksi/9KfGviws6Qtf9Q7KCqRhpwrYKQPs+JBA/rKVFF/yaWLHJEH3zfVP2plVu+eys0d2DlFmhoQJayFewcw== - dependencies: - "@ethersproject/base64" "^5.8.0" - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@ethersproject/wordlists@5.8.0", "@ethersproject/wordlists@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.8.0.tgz#7a5654ee8d1bb1f4dbe43f91d217356d650ad821" - integrity sha512-2df9bbXicZws2Sb5S6ET493uJ0Z84Fjr3pC4tu/qlnZERibZCeUVuqdtt+7Tv9xxhUxHoIekIA7avrKUWHrezg== - dependencies: - "@ethersproject/bytes" "^5.8.0" - "@ethersproject/hash" "^5.8.0" - "@ethersproject/logger" "^5.8.0" - "@ethersproject/properties" "^5.8.0" - "@ethersproject/strings" "^5.8.0" - -"@inquirer/external-editor@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@inquirer/external-editor/-/external-editor-1.0.3.tgz#c23988291ee676290fdab3fd306e64010a6d13b8" - integrity sha512-RWbSrDiYmO4LbejWY7ttpxczuwQyZLBUyygsA9Nsv95hpzUWwnNTVQmAq3xuh7vNwCp07UTmE5i11XAEExx4RA== - dependencies: - chardet "^2.1.1" - iconv-lite "^0.7.0" - "@metaplex-foundation/beet-solana@0.4.0": version "0.4.0" resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.0.tgz#52891e78674aaa54e0031f1bca5bfbc40de12e8d" @@ -554,166 +69,18 @@ resolved "https://registry.yarnpkg.com/@metaplex-foundation/cusper/-/cusper-0.0.2.tgz#dc2032a452d6c269e25f016aa4dd63600e2af975" integrity sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA== -"@metaplex-foundation/umi-bundle-defaults@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-bundle-defaults/-/umi-bundle-defaults-0.9.2.tgz#f8e296b1a0ecb3a6511dbaca4131bc9263071cfc" - integrity sha512-kV3tfvgvRjVP1p9OFOtH+ibOtN9omVJSwKr0We4/9r45e5LTj+32su0V/rixZUkG1EZzzOYBsxhtIE0kIw/Hrw== - dependencies: - "@metaplex-foundation/umi-downloader-http" "^0.9.2" - "@metaplex-foundation/umi-eddsa-web3js" "^0.9.2" - "@metaplex-foundation/umi-http-fetch" "^0.9.2" - "@metaplex-foundation/umi-program-repository" "^0.9.2" - "@metaplex-foundation/umi-rpc-chunk-get-accounts" "^0.9.2" - "@metaplex-foundation/umi-rpc-web3js" "^0.9.2" - "@metaplex-foundation/umi-serializer-data-view" "^0.9.2" - "@metaplex-foundation/umi-transaction-factory-web3js" "^0.9.2" - -"@metaplex-foundation/umi-downloader-http@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-downloader-http/-/umi-downloader-http-0.9.2.tgz#df84b11df9141854ca1cf7c6c8374658e67de767" - integrity sha512-tzPT9hBwenzTzAQg07rmsrqZfgguAXELbcJrsYMoASp5VqWFXYIP00g94KET6XLjWUXH4P1J2zoa6hGennPXHA== - -"@metaplex-foundation/umi-eddsa-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-eddsa-web3js/-/umi-eddsa-web3js-0.9.2.tgz#92225595137c5585dae63b148786ab77fcb6d625" - integrity sha512-hhPCxXbYIp4BC4z9gK78sXpWLkNSrfv4ndhF5ruAkdIp7GcRVYKj0QnOUO6lGYGiIkNlw20yoTwOe1CT//OfTQ== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - "@noble/curves" "^1.0.0" - -"@metaplex-foundation/umi-http-fetch@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-http-fetch/-/umi-http-fetch-0.9.2.tgz#e233ec34b789ed5257168b97d72fc9b039155046" - integrity sha512-YCZuBu24T9ZzEDe4+w12LEZm/fO9pkyViZufGgASC5NX93814Lvf6Ssjn/hZzjfA7CvZbvLFbmujc6CV3Q/m9Q== - dependencies: - node-fetch "^2.6.7" - -"@metaplex-foundation/umi-options@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-options/-/umi-options-0.8.9.tgz#9c9e269d9eee7d055ad6831dcb30a30127dcb0c5" - integrity sha512-jSQ61sZMPSAk/TXn8v8fPqtz3x8d0/blVZXLLbpVbo2/T5XobiI6/MfmlUosAjAUaQl6bHRF8aIIqZEFkJiy4A== - -"@metaplex-foundation/umi-program-repository@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-program-repository/-/umi-program-repository-0.9.2.tgz#53fce2bf506bb97fdb6a53e2118f8d1dd28fd0b5" - integrity sha512-g3+FPqXEmYsBa8eETtUE2gb2Oe3mqac0z3/Ur1TvAg5TtIy3mzRzOy/nza+sgzejnfcxcVg835rmpBaxpBnjDA== - -"@metaplex-foundation/umi-public-keys@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-public-keys/-/umi-public-keys-0.8.9.tgz#ca7a927c924ed8e28d0f8bb3dc0f2adc1f9011ec" - integrity sha512-CxMzN7dgVGOq9OcNCJe2casKUpJ3RmTVoOvDFyeoTQuK+vkZ1YSSahbqC1iGuHEtKTLSjtWjKvUU6O7zWFTw3Q== - dependencies: - "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" - -"@metaplex-foundation/umi-rpc-chunk-get-accounts@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-chunk-get-accounts/-/umi-rpc-chunk-get-accounts-0.9.2.tgz#f93bd43d4c65cdfdb0a68145a837fb6b13e0e832" - integrity sha512-YRwVf6xH0jPBAUgMhEPi+UbjioAeqTXmjsN2TnmQCPAmHbrHrMRj0rlWYwFLWAgkmoxazYrXP9lqOFRrfOGAEA== - -"@metaplex-foundation/umi-rpc-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-rpc-web3js/-/umi-rpc-web3js-0.9.2.tgz#b00a4cc1a9bd5d930164d1ba43f816107655c0d9" - integrity sha512-MqcsBz8B4wGl6jxsf2Jo/rAEpYReU9VCSR15QSjhvADHMmdFxCIZCCAgE+gDE2Vuanfl437VhOcP3g5Uw8C16Q== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - -"@metaplex-foundation/umi-serializer-data-view@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializer-data-view/-/umi-serializer-data-view-0.9.2.tgz#a05d88e7120b839e3acba35f7b4e12fe8be2becc" - integrity sha512-5vGptadJxUxvUcyrwFZxXlEc6Q7AYySBesizCtrBFUY8w8PnF2vzmS45CP1MLySEATNH6T9mD4Rs0tLb87iQyA== - -"@metaplex-foundation/umi-serializers-core@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-core/-/umi-serializers-core-0.8.9.tgz#cd5ae763a59e54dd01f1284f4a6bf4e78e4aab9c" - integrity sha512-WT82tkiYJ0Qmscp7uTj1Hz6aWQPETwaKLAENAUN5DeWghkuBKtuxyBKVvEOuoXerJSdhiAk0e8DWA4cxcTTQ/w== - -"@metaplex-foundation/umi-serializers-encodings@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-encodings/-/umi-serializers-encodings-0.8.9.tgz#0f02605ee3e6fbeac1abc4fb267a7cc96ecb4410" - integrity sha512-N3VWLDTJ0bzzMKcJDL08U3FaqRmwlN79FyE4BHj6bbAaJ9LEHjDQ9RJijZyWqTm0jE7I750fU7Ow5EZL38Xi6Q== - dependencies: - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - -"@metaplex-foundation/umi-serializers-numbers@^0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers-numbers/-/umi-serializers-numbers-0.8.9.tgz#28c10367f6aebac0276ec1bce81d0d8db54b05de" - integrity sha512-NtBf1fnVNQJHFQjLFzRu2i9GGnigb9hOm/Gfrk628d0q0tRJB7BOM3bs5C61VAs7kJs4yd+pDNVAERJkknQ7Lg== - dependencies: - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - -"@metaplex-foundation/umi-serializers@^0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-serializers/-/umi-serializers-0.9.0.tgz#af6d03a3bf821bf73b7b3450bb8df0407f2f69d6" - integrity sha512-hAOW9Djl4w4ioKeR4erDZl5IG4iJdP0xA19ZomdaCbMhYAAmG/FEs5khh0uT2mq53/MnzWcXSUPoO8WBN4Q+Vg== - dependencies: - "@metaplex-foundation/umi-options" "^0.8.9" - "@metaplex-foundation/umi-public-keys" "^0.8.9" - "@metaplex-foundation/umi-serializers-core" "^0.8.9" - "@metaplex-foundation/umi-serializers-encodings" "^0.8.9" - "@metaplex-foundation/umi-serializers-numbers" "^0.8.9" - -"@metaplex-foundation/umi-transaction-factory-web3js@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-transaction-factory-web3js/-/umi-transaction-factory-web3js-0.9.2.tgz#294c3ca996897bb95b993b808fb9252bd085db15" - integrity sha512-fR1Kf21uylMFd1Smkltmj4jTNxhqSWf416owsJ+T+cvJi2VCOcOwq/3UFzOrpz78fA0RhsajKYKj0HYsRnQI1g== - dependencies: - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - -"@metaplex-foundation/umi-uploader-bundlr@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-uploader-bundlr/-/umi-uploader-bundlr-0.9.2.tgz#0d832816a32970cac9f412a0b0a8234415ab8534" - integrity sha512-wmixKqWyEO0lRB2GNvm5XOwi3jEyCtPZ6Oqds6sY5YHYdrn1Cqgd1TcdAuu7+DuojcNFErTjWsaQ1F9QR502QQ== - dependencies: - "@bundlr-network/client" "^0.8.8" - "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" - bignumber.js "^9.0.2" - buffer "^6.0.3" - -"@metaplex-foundation/umi-web3js-adapters@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-web3js-adapters/-/umi-web3js-adapters-0.9.2.tgz#1e0ebb4e3c31e8bead27892b20204292ad6955c5" - integrity sha512-RQqUTtHYY9fmEMnq7s3Hiv/81flGaoI0ZVVoafnFVaQLnxU6QBKxtboRZHk43XtD9CiFh5f9izrMJX7iK7KlOA== - dependencies: - buffer "^6.0.3" - -"@metaplex-foundation/umi@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi/-/umi-0.9.2.tgz#6460bff91d2ac7745842eda1ee6a28fba4d2ffb2" - integrity sha512-9i4Acm4pruQfJcpRrc2EauPBwkfDN0I9QTvJyZocIlKgoZwD6A6wH0PViH1AjOVG5CQCd1YI3tJd5XjYE1ElBw== - dependencies: - "@metaplex-foundation/umi-options" "^0.8.9" - "@metaplex-foundation/umi-public-keys" "^0.8.9" - "@metaplex-foundation/umi-serializers" "^0.9.0" - -"@noble/curves@^1.0.0", "@noble/curves@^1.4.2": +"@noble/curves@^1.4.2": version "1.9.7" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951" integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw== dependencies: "@noble/hashes" "1.8.0" -"@noble/ed25519@^1.6.1": - version "1.7.5" - resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.5.tgz#94df8bdb9fec9c4644a56007eecb57b0e9fbd0d7" - integrity sha512-xuS0nwRMQBvSxDa7UxMb61xTiH3MxTgUfhyPUALVIe0FlOAz4sjELwyDRyUvqeEYfRSG9qNjFIycqLZppg4RSA== - "@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0": version "1.8.0" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a" integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A== -"@randlabs/communication-bridge@1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3" - integrity sha512-CzS0U8IFfXNK7QaJFE4pjbxDGfPjbXBEsEaCn9FN15F+ouSAEUQkva3Gl66hrkBZOGexKFEWMwUHIDKpZ2hfVg== - -"@randlabs/myalgo-connect@^1.1.2": - version "1.4.2" - resolved "https://registry.yarnpkg.com/@randlabs/myalgo-connect/-/myalgo-connect-1.4.2.tgz#ce3ad97b3889ea21da75852187511d3f6be0fa05" - integrity sha512-K9hEyUi7G8tqOp7kWIALJLVbGCByhilcy6123WfcorxWwiE1sbQupPyIU5f3YdQK6wMjBsyTWiLW52ZBMp7sXA== - dependencies: - "@randlabs/communication-bridge" "1.0.1" - "@solana/buffer-layout-utils@^0.2.0": version "0.2.0" resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" @@ -834,25 +201,7 @@ "@solana/spl-token-metadata" "^0.1.2" buffer "^6.0.3" -"@solana/wallet-adapter-base@^0.9.2": - version "0.9.27" - resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.27.tgz#f76463db172ac1d7d1f5aa064800363777731dfd" - integrity sha512-kXjeNfNFVs/NE9GPmysBRKQ/nf+foSaq3kfVSeMcO/iVgigyRmB551OjU3WyAolLG/1jeEfKLqF9fKwMCRkUqg== - dependencies: - "@solana/wallet-standard-features" "^1.3.0" - "@wallet-standard/base" "^1.1.0" - "@wallet-standard/features" "^1.1.0" - eventemitter3 "^5.0.1" - -"@solana/wallet-standard-features@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-features/-/wallet-standard-features-1.3.0.tgz#c489eca9d0c78f97084b4af6ca8ad8c1ca197de5" - integrity sha512-ZhpZtD+4VArf6RPitsVExvgkF+nGghd1rzPjd97GmBximpnt1rsUxMOEyoIEuH3XBxPyNB6Us7ha7RHWQR+abg== - dependencies: - "@wallet-standard/base" "^1.1.0" - "@wallet-standard/features" "^1.1.0" - -"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.70.3", "@solana/web3.js@^1.76.0": +"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.70.3", "@solana/web3.js@^1.76.0": version "1.98.4" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== @@ -889,11 +238,6 @@ buffer "6.0.3" invariant "2.2.4" -"@supercharge/promise-pool@^2.1.0": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@supercharge/promise-pool/-/promise-pool-2.4.0.tgz#6050eea8c2d7f92ddd4ddc582ee328b15c034ad3" - integrity sha512-O9CMipBlq5OObdt1uKJGIzm9cdjpPWfj+a+Zw9EgWKxaMNHKC7EU7X9taj3H0EGQNLOSq2jAcOa3EzxlfHsD6w== - "@swc/helpers@^0.5.11": version "0.5.17" resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.17.tgz#5a7be95ac0f0bf186e7e6e890e7a6f6cda6ce971" @@ -937,11 +281,6 @@ dependencies: undici-types "~7.16.0" -"@types/node@11.11.6": - version "11.11.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" - integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== - "@types/node@^12.12.54": version "12.20.55" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" @@ -971,23 +310,6 @@ resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== -"@wallet-standard/base@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wallet-standard/base/-/base-1.1.0.tgz#214093c0597a1e724ee6dbacd84191dfec62bb33" - integrity sha512-DJDQhjKmSNVLKWItoKThJS+CsJQjR9AOBOirBVT1F9YpRyC9oYHE+ZnSf8y8bxUphtKqdQMPVQ2mHohYdRvDVQ== - -"@wallet-standard/features@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wallet-standard/features/-/features-1.1.0.tgz#f256d7b18940c8d134f66164330db358a8f5200e" - integrity sha512-hiEivWNztx73s+7iLxsuD1sOJ28xtRix58W7Xnz4XzzA/pF0+aicnWgjOdA10doVDEDZdUuZCIIqG96SFNlDUg== - dependencies: - "@wallet-standard/base" "^1.1.0" - -aes-js@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" - integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== - agentkeepalive@^4.5.0: version "4.6.0" resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.6.0.tgz#35f73e94b3f40bf65f105219c623ad19c136ea6a" @@ -995,39 +317,11 @@ agentkeepalive@^4.5.0: dependencies: humanize-ms "^1.2.1" -algo-msgpack-with-bigint@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz#38bb717220525b3ff42232eefdcd9efb9ad405d6" - integrity sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ== - -algosdk@^1.13.1: - version "1.24.1" - resolved "https://registry.yarnpkg.com/algosdk/-/algosdk-1.24.1.tgz#afc4102457ae0c38a32de6b84f4d713aedfc9e89" - integrity sha512-9moZxdqeJ6GdE4N6fA/GlUP4LrbLZMYcYkt141J4Ss68OfEgH9qW0wBuZ3ZOKEx/xjc5bg7mLP2Gjg7nwrkmww== - dependencies: - algo-msgpack-with-bigint "^2.1.1" - buffer "^6.0.2" - cross-fetch "^3.1.5" - hi-base32 "^0.5.1" - js-sha256 "^0.9.0" - js-sha3 "^0.8.0" - js-sha512 "^0.8.0" - json-bigint "^1.0.0" - tweetnacl "^1.0.3" - vlq "^2.0.4" - ansi-colors@4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== -ansi-escapes@^4.2.1: - version "4.3.2" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" - integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== - dependencies: - type-fest "^0.21.3" - ansi-regex@=5.0.1, ansi-regex@^4.1.0, ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -1053,35 +347,6 @@ anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" -arbundles@^0.6.21: - version "0.6.23" - resolved "https://registry.yarnpkg.com/arbundles/-/arbundles-0.6.23.tgz#c00cda953df67fa65d4297486237cc8e0c072c47" - integrity sha512-+gr93F3fivN+6dhiImT6BQNaXz4oECPn2GYjCZjS2yEoq7hM78FRvVp6kQyjEdhnuBFQr/q4oS/nkjnQlHdj9Q== - dependencies: - "@noble/ed25519" "^1.6.1" - "@randlabs/myalgo-connect" "^1.1.2" - "@solana/wallet-adapter-base" "^0.9.2" - algosdk "^1.13.1" - arweave "^1.11.4" - arweave-stream-tx "^1.1.0" - avsc "https://github.com/Irys-xyz/avsc#csp-fixes" - axios "^0.21.3" - base64url "^3.0.1" - bs58 "^4.0.1" - ethers "^5.5.1" - keccak "^3.0.2" - multistream "^4.1.0" - process "^0.11.10" - secp256k1 "^4.0.2" - tmp-promise "^3.0.2" - -arconnect@^0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/arconnect/-/arconnect-0.4.2.tgz#83de7638fb46183e82d7ec7efb5594c5f7cdc806" - integrity sha512-Jkpd4QL3TVqnd3U683gzXmZUVqBUy17DdJDuL/3D9rkysLgX6ymJ2e+sR+xyZF5Rh42CBqDXWNMmCjBXeP7Gbw== - dependencies: - arweave "^1.10.13" - argparse@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" @@ -1092,33 +357,6 @@ arrify@^1.0.0: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== -arweave-stream-tx@^1.1.0: - version "1.2.2" - resolved "https://registry.yarnpkg.com/arweave-stream-tx/-/arweave-stream-tx-1.2.2.tgz#2d5c66554301baacd02586a152fbb198b422112f" - integrity sha512-bNt9rj0hbAEzoUZEF2s6WJbIz8nasZlZpxIw03Xm8fzb9gRiiZlZGW3lxQLjfc9Z0VRUWDzwtqoYeEoB/JDToQ== - dependencies: - exponential-backoff "^3.1.0" - -arweave@^1.10.13, arweave@^1.11.4: - version "1.15.7" - resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.15.7.tgz#d09265d128e93a471203649de083ba7fec52cb29" - integrity sha512-F+Y4iWU1qea9IsKQ/YNmLsY4DHQVsaJBuhEbFxQn9cfGHOmtXE+bwo14oY8xqymsqSNf/e1PeIfLk7G7qN/hVA== - dependencies: - arconnect "^0.4.2" - asn1.js "^5.4.1" - base64-js "^1.5.1" - bignumber.js "^9.0.2" - -asn1.js@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - assert@^2.0.0, assert@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.1.0.tgz#6d92a238d05dc02e7427c881fb8be81c8448b2dd" @@ -1135,13 +373,6 @@ assertion-error@^1.1.0: resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== -async-retry@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" - integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== - dependencies: - retry "0.13.1" - available-typed-arrays@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846" @@ -1149,24 +380,6 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" -"avsc@https://github.com/Irys-xyz/avsc#csp-fixes": - version "5.4.7" - resolved "https://github.com/Irys-xyz/avsc#a730cc8018b79e114b6a3381bbb57760a24c6cef" - -axios@^0.21.3: - version "0.21.4" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" - integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== - dependencies: - follow-redirects "^1.14.0" - -axios@^0.25.0: - version "0.25.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a" - integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g== - dependencies: - follow-redirects "^1.14.7" - backslash@=0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/backslash/-/backslash-0.2.0.tgz#6c3c1fce7e7e714ccfc10fd74f0f73410677375f" @@ -1189,21 +402,11 @@ base-x@^4.0.0: resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.1.tgz#817fb7b57143c501f649805cb247617ad016a885" integrity sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw== -base64-js@^1.3.1, base64-js@^1.5.1: +base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -base64url@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" - integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== - -bech32@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" - integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== - bigint-buffer@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" @@ -1211,7 +414,7 @@ bigint-buffer@^1.1.5: dependencies: bindings "^1.3.0" -bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.0.2: +bignumber.js@^9.0.1: version "9.3.1" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.3.1.tgz#759c5aaddf2ffdc4f154f7b493e1c8770f88c4d7" integrity sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ== @@ -1228,57 +431,11 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bip39-light@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/bip39-light/-/bip39-light-1.0.7.tgz#06a72f251b89389a136d3f177f29b03342adc5ba" - integrity sha512-WDTmLRQUsiioBdTs9BmSEmkJza+8xfJmptsNJjxnoq3EydSa/ZBXT6rm66KoT3PJIRYMnhSKNR7S9YL1l7R40Q== - dependencies: - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - -bip39@3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" - integrity sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ== - dependencies: - "@types/node" "11.11.6" - create-hash "^1.1.0" - pbkdf2 "^3.0.9" - randombytes "^2.0.1" - -bl@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" - integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== - dependencies: - buffer "^5.5.0" - inherits "^2.0.4" - readable-stream "^3.4.0" - -bn.js@5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - -bn.js@^4.0.0, bn.js@^4.11.9: - version "4.12.2" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.2.tgz#3d8fed6796c24e177737f7cc5172ee04ef39ec99" - integrity sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw== - bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: version "5.2.2" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.2.tgz#82c09f9ebbb17107cd72cb7fd39bd1f9d0aaa566" integrity sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw== -borsh@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.6.0.tgz#a7c9eeca6a31ca9e0607cb49f329cb659eb791e1" - integrity sha512-sl5k89ViqsThXQpYa9XDtz1sBl3l1lI313cFUY1HKr+wvMILnb+58xpkqTNrYbelh99dY7K8usxoCusQmqix9Q== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - borsh@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" @@ -1303,11 +460,6 @@ braces@~3.0.2: dependencies: fill-range "^7.1.1" -brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== - browser-stdout@1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" @@ -1337,7 +489,7 @@ buffer-layout@^1.2.0, buffer-layout@^1.2.2: resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== -buffer@6.0.3, buffer@^6.0.2, buffer@^6.0.3, buffer@~6.0.3: +buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== @@ -1345,14 +497,6 @@ buffer@6.0.3, buffer@^6.0.2, buffer@^6.0.3, buffer@~6.0.3: base64-js "^1.3.1" ieee754 "^1.2.1" -buffer@^5.5.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - bufferutil@^4.0.1: version "4.0.9" resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.9.tgz#6e81739ad48a95cad45a279588e13e95e24a800a" @@ -1391,11 +535,6 @@ camelcase@^6.0.0, camelcase@^6.3.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -capability@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/capability/-/capability-0.2.5.tgz#51ad87353f1936ffd77f2f21c74633a4dea88801" - integrity sha512-rsJZYVCgXd08sPqwmaIqjAd5SUTfonV0z/gDJ8D6cN8wQphky1kkAYEqQ+hmDxTw7UihvBfjUVUSY+DBEe44jg== - chai@^4.3.4: version "4.5.0" resolved "https://registry.yarnpkg.com/chai/-/chai-4.5.0.tgz#707e49923afdd9b13a8b0b47d33d732d13812fd8" @@ -1416,7 +555,7 @@ chalk-template@=0.4.0: dependencies: chalk "^4.1.2" -chalk@=4.1.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@^5.3.0, chalk@^5.4.1: +chalk@=4.1.2, chalk@^4.1.0, chalk@^4.1.2, chalk@^5.3.0, chalk@^5.4.1: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1424,11 +563,6 @@ chalk@=4.1.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2, chalk@^5.3.0, chalk@^5.4 ansi-styles "^4.1.0" supports-color "^7.1.0" -chardet@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-2.1.1.tgz#5c75593704a642f71ee53717df234031e65373c8" - integrity sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ== - check-error@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.3.tgz#a6502e4312a7ee969f646e83bb3ddd56281bd694" @@ -1451,32 +585,6 @@ chokidar@3.5.3: optionalDependencies: fsevents "~2.3.2" -cipher-base@^1.0.1, cipher-base@^1.0.3: - version "1.0.7" - resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.7.tgz#bd094bfef42634ccfd9e13b9fc73274997111e39" - integrity sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA== - dependencies: - inherits "^2.0.4" - safe-buffer "^5.2.1" - to-buffer "^1.2.2" - -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - -cli-spinners@^2.5.0: - version "2.9.2" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41" - integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg== - -cli-width@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" - integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== - cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -1486,11 +594,6 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" -clone@^1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== - color-convert@=2.0.1, color-convert@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" @@ -1533,44 +636,11 @@ commander@^2.20.3: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^8.2.0: - version "8.3.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" - integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== - concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -core-util-is@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" - integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== - -create-hash@^1.1.0, create-hash@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" - integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== - dependencies: - cipher-base "^1.0.1" - inherits "^2.0.1" - md5.js "^1.3.4" - ripemd160 "^2.0.1" - sha.js "^2.4.0" - -create-hmac@1.1.7, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - cross-fetch@^3.1.5: version "3.2.0" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.2.0.tgz#34e9192f53bc757d6614304d9e5e6fb4edb782e3" @@ -1583,31 +653,6 @@ crypto-hash@^1.3.0: resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== -csv-generate@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/csv-generate/-/csv-generate-4.5.0.tgz#5fbbb89bd9f8ce705871c9baf02e1d4bb4000fb3" - integrity sha512-aQr/vmOKyBSBHNwYhAoXw1+kUsPnMSwmYgpNoo36rIXoG1ecWILnvPGZeQ6oUjzrWknZAD3+jfpqYOBAl4x15A== - -csv-parse@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-6.1.0.tgz#c642ec5b7fc57c1f477a07d179beb5ff0dfd5ed0" - integrity sha512-CEE+jwpgLn+MmtCpVcPtiCZpVtB6Z2OKPTr34pycYYoL7sxdOkXDdQ4lRiw6ioC0q6BLqhc6cKweCVvral8yhw== - -csv-stringify@^6.6.0: - version "6.6.0" - resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-6.6.0.tgz#d384859cfb71d0a4a73c5bcc36a4daf5440cb033" - integrity sha512-YW32lKOmIBgbxtu3g5SaiqWNwa/9ISQt2EcgOq0+RAIFufFp9is6tqNnKahqE5kuKvrnYAzs28r+s6pXJR8Vcw== - -csv@^6.0.5: - version "6.4.1" - resolved "https://registry.yarnpkg.com/csv/-/csv-6.4.1.tgz#c9a62130c025f8adb2a85a75d4c2608612995822" - integrity sha512-ajGosmTGnTwYyGl8STqZDu7R6LkDf3xL39XiOmliV/GufQeVUxHzTKIm4NOBCwmEuujK7B6isxs4Uqt9GcRCvA== - dependencies: - csv-generate "^4.5.0" - csv-parse "^6.1.0" - csv-stringify "^6.6.0" - stream-transform "^3.4.0" - debug@4.3.3, debug@=4.4.1, debug@^4.3.3, debug@^4.3.4: version "4.4.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" @@ -1620,11 +665,6 @@ decamelize@^4.0.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -decimal.js@^10.4.3: - version "10.6.0" - resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.6.0.tgz#e649a43e3ab953a72192ff5983865e509f37ed9a" - integrity sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg== - deep-eql@^4.1.3: version "4.1.4" resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.4.tgz#d0d3912865911bb8fac5afb4e3acfa6a28dc72b7" @@ -1632,13 +672,6 @@ deep-eql@^4.1.3: dependencies: type-detect "^4.0.0" -defaults@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" - integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== - dependencies: - clone "^1.0.2" - define-data-property@^1.0.1, define-data-property@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" @@ -1662,16 +695,6 @@ delay@^5.0.0: resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== -depd@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== - diff@5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" @@ -1699,19 +722,6 @@ dunder-proto@^1.0.1: es-errors "^1.3.0" gopd "^1.2.0" -elliptic@6.6.1, elliptic@^6.5.7: - version "6.6.1" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" - integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -1724,15 +734,6 @@ error-ex@=1.3.2: dependencies: is-arrayish "^0.2.1" -error-polyfill@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/error-polyfill/-/error-polyfill-0.1.3.tgz#df848b61ad8834f7a5db69a70b9913df86721d15" - integrity sha512-XHJk60ufE+TG/ydwp4lilOog549iiQF2OAPhkk9DdiYWMrltz5yhDz/xnKuenNwP7gy3dsibssO5QpVhkrSzzg== - dependencies: - capability "^0.2.5" - o3 "^1.0.3" - u3 "^0.1.1" - es-define-property@^1.0.0, es-define-property@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" @@ -1762,34 +763,6 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" -esbuild@^0.17.15: - version "0.17.19" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" - integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== - optionalDependencies: - "@esbuild/android-arm" "0.17.19" - "@esbuild/android-arm64" "0.17.19" - "@esbuild/android-x64" "0.17.19" - "@esbuild/darwin-arm64" "0.17.19" - "@esbuild/darwin-x64" "0.17.19" - "@esbuild/freebsd-arm64" "0.17.19" - "@esbuild/freebsd-x64" "0.17.19" - "@esbuild/linux-arm" "0.17.19" - "@esbuild/linux-arm64" "0.17.19" - "@esbuild/linux-ia32" "0.17.19" - "@esbuild/linux-loong64" "0.17.19" - "@esbuild/linux-mips64el" "0.17.19" - "@esbuild/linux-ppc64" "0.17.19" - "@esbuild/linux-riscv64" "0.17.19" - "@esbuild/linux-s390x" "0.17.19" - "@esbuild/linux-x64" "0.17.19" - "@esbuild/netbsd-x64" "0.17.19" - "@esbuild/openbsd-x64" "0.17.19" - "@esbuild/sunos-x64" "0.17.19" - "@esbuild/win32-arm64" "0.17.19" - "@esbuild/win32-ia32" "0.17.19" - "@esbuild/win32-x64" "0.17.19" - escalade@^3.1.1: version "3.2.0" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" @@ -1800,47 +773,6 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== - -ethers@^5.5.1: - version "5.8.0" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.8.0.tgz#97858dc4d4c74afce83ea7562fe9493cedb4d377" - integrity sha512-DUq+7fHrCg1aPDFCHx6UIPb3nmt2XMpM7Y/g2gLhsl3lIBqeAfOJIl1qEvRf2uq3BiKxmh6Fh5pfp2ieyek7Kg== - dependencies: - "@ethersproject/abi" "5.8.0" - "@ethersproject/abstract-provider" "5.8.0" - "@ethersproject/abstract-signer" "5.8.0" - "@ethersproject/address" "5.8.0" - "@ethersproject/base64" "5.8.0" - "@ethersproject/basex" "5.8.0" - "@ethersproject/bignumber" "5.8.0" - "@ethersproject/bytes" "5.8.0" - "@ethersproject/constants" "5.8.0" - "@ethersproject/contracts" "5.8.0" - "@ethersproject/hash" "5.8.0" - "@ethersproject/hdnode" "5.8.0" - "@ethersproject/json-wallets" "5.8.0" - "@ethersproject/keccak256" "5.8.0" - "@ethersproject/logger" "5.8.0" - "@ethersproject/networks" "5.8.0" - "@ethersproject/pbkdf2" "5.8.0" - "@ethersproject/properties" "5.8.0" - "@ethersproject/providers" "5.8.0" - "@ethersproject/random" "5.8.0" - "@ethersproject/rlp" "5.8.0" - "@ethersproject/sha2" "5.8.0" - "@ethersproject/signing-key" "5.8.0" - "@ethersproject/solidity" "5.8.0" - "@ethersproject/strings" "5.8.0" - "@ethersproject/transactions" "5.8.0" - "@ethersproject/units" "5.8.0" - "@ethersproject/wallet" "5.8.0" - "@ethersproject/web" "5.8.0" - "@ethersproject/wordlists" "5.8.0" - eventemitter3@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" @@ -1851,11 +783,6 @@ eventemitter3@^5.0.1: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== -exponential-backoff@^3.1.0: - version "3.1.3" - resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.3.tgz#51cf92c1c0493c766053f9d3abee4434c244d2f6" - integrity sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA== - eyes@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" @@ -1866,13 +793,6 @@ fast-stable-stringify@^1.0.0: resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - file-uri-to-path@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" @@ -1898,11 +818,6 @@ flat@^5.0.2: resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== -follow-redirects@^1.14.0, follow-redirects@^1.14.7: - version "1.15.11" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340" - integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ== - for-each@^0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.5.tgz#d650688027826920feeb0af747ee7b9421a41d47" @@ -2024,24 +939,6 @@ has-tostringtag@^1.0.2: dependencies: has-symbols "^1.0.3" -hash-base@^3.0.0, hash-base@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.2.tgz#79d72def7611c3f6e3c3b5730652638001b10a74" - integrity sha512-Bb33KbowVTIj5s7Ked1OsqHUeCpz//tPwR+E2zJgJKo9Z5XolZ9b6bdUgjmYlwnWhoOQKoTd1TYToZGn5mAYOg== - dependencies: - inherits "^2.0.4" - readable-stream "^2.3.8" - safe-buffer "^5.2.1" - to-buffer "^1.2.1" - -hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - hasown@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" @@ -2054,31 +951,6 @@ he@1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -hi-base32@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/hi-base32/-/hi-base32-0.5.1.tgz#1279f2ddae2673219ea5870c2121d2a33132857e" - integrity sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA== - -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - -http-errors@^1.7.2: - version "1.8.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.8.1.tgz#7c3f28577cbc8a207388455dbd62295ed07bd68c" - integrity sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g== - dependencies: - depd "~1.1.2" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.1" - humanize-ms@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" @@ -2086,14 +958,7 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -iconv-lite@^0.7.0: - version "0.7.1" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.7.1.tgz#d4af1d2092f2bb05aab6296e5e7cd286d2f15432" - integrity sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw== - dependencies: - safer-buffer ">= 2.1.2 < 3.0.0" - -ieee754@^1.1.13, ieee754@^1.2.1: +ieee754@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== @@ -2106,32 +971,11 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: +inherits@2, inherits@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -inquirer@^8.2.0: - version "8.2.7" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-8.2.7.tgz#62f6b931a9b7f8735dc42db927316d8fb6f71de8" - integrity sha512-UjOaSel/iddGZJ5xP/Eixh6dY1XghiBw4XK13rCCIJcJfyhhoul/7KhLLUGtebEj6GDYM6Vnx/mVsjx2L/mFIA== - dependencies: - "@inquirer/external-editor" "^1.0.0" - ansi-escapes "^4.2.1" - chalk "^4.1.1" - cli-cursor "^3.1.0" - cli-width "^3.0.0" - figures "^3.0.0" - lodash "^4.17.21" - mute-stream "0.0.8" - ora "^5.4.1" - run-async "^2.4.0" - rxjs "^7.5.5" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - wrap-ansi "^6.0.1" - invariant@2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" @@ -2197,11 +1041,6 @@ is-glob@^4.0.1, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" -is-interactive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e" - integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w== - is-nan@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" @@ -2230,7 +1069,7 @@ is-regex@^1.2.1: has-tostringtag "^1.0.2" hasown "^2.0.2" -is-typed-array@^1.1.14, is-typed-array@^1.1.3: +is-typed-array@^1.1.3: version "1.1.15" resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.15.tgz#4bfb4a45b61cee83a5a46fba778e4e8d59c0ce0b" integrity sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ== @@ -2242,16 +1081,6 @@ is-unicode-supported@^0.1.0: resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== -isarray@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" - integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -2280,21 +1109,6 @@ jayson@^4.1.1: uuid "^8.3.2" ws "^7.5.10" -js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - -js-sha3@0.8.0, js-sha3@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" - integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== - -js-sha512@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4" - integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ== - "js-tokens@^3.0.0 || ^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -2307,13 +1121,6 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" -json-bigint@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" - integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== - dependencies: - bignumber.js "^9.0.0" - json-stringify-safe@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" @@ -2326,15 +1133,6 @@ json5@^1.0.2: dependencies: minimist "^1.2.0" -keccak@^3.0.2: - version "3.0.4" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" - integrity sha512-3vKuW0jV8J3XNTzvfyicFR5qvxrSAGl7KIhvgOu5cmWwM7tZRj3fMbj/pfIf4be7aznbc+prBWGjywox/g2Y6Q== - dependencies: - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - readable-stream "^3.6.0" - locate-path@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" @@ -2342,12 +1140,7 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - -log-symbols@4.1.0, log-symbols@^4.1.0: +log-symbols@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== @@ -2386,42 +1179,6 @@ math-intrinsics@^1.1.0: resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== -md5.js@^1.3.4: - version "1.3.5" - resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" - integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== - dependencies: - hash-base "^3.0.0" - inherits "^2.0.1" - safe-buffer "^5.1.2" - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.34: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -mimic-fn@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" - integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== - -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" - integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== - -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== - minimatch@4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" @@ -2483,65 +1240,11 @@ ms@2.1.3, ms@^2.0.0, ms@^2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -multistream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8" - integrity sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw== - dependencies: - once "^1.4.0" - readable-stream "^3.6.0" - -mustache@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" - integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== - -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - nanoid@3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -near-api-js@^0.44.2: - version "0.44.2" - resolved "https://registry.yarnpkg.com/near-api-js/-/near-api-js-0.44.2.tgz#e451f68f2c56bd885c7b918db5818a3e6e9423d0" - integrity sha512-eMnc4V+geggapEUa3nU2p8HSHn/njtloI4P2mceHQWO8vDE1NGpnAw8FuTBrLmXSgIv9m6oocgFc9t3VNf5zwg== - dependencies: - bn.js "5.2.0" - borsh "^0.6.0" - bs58 "^4.0.0" - depd "^2.0.0" - error-polyfill "^0.1.3" - http-errors "^1.7.2" - js-sha256 "^0.9.0" - mustache "^4.0.0" - node-fetch "^2.6.1" - text-encoding-utf-8 "^1.0.2" - tweetnacl "^1.0.1" - -near-hd-key@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/near-hd-key/-/near-hd-key-1.2.1.tgz#f508ff15436cf8a439b543220f3cc72188a46756" - integrity sha512-SIrthcL5Wc0sps+2e1xGj3zceEa68TgNZDLuCx0daxmfTP7sFTB3/mtE2pYhlFsCxWoMn+JfID5E1NlzvvbRJg== - dependencies: - bip39 "3.0.2" - create-hmac "1.1.7" - tweetnacl "1.0.3" - -near-seed-phrase@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/near-seed-phrase/-/near-seed-phrase-0.2.1.tgz#7d5b54d5e836d295f10b0bdfdae9086443651d20" - integrity sha512-feMuums+kVL3LSuPcP4ld07xHCb2mu6z48SGfP3W+8tl1Qm5xIcjiQzY2IDPBvFgajRDxWSb8GzsRHoInazByw== - dependencies: - bip39-light "^1.0.7" - bs58 "^4.0.1" - near-hd-key "^1.2.1" - tweetnacl "^1.0.2" - no-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" @@ -2550,24 +1253,14 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-addon-api@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" - integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== - -node-addon-api@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" - integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== - -node-fetch@^2.6.1, node-fetch@^2.6.7, node-fetch@^2.7.0: +node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== dependencies: whatwg-url "^5.0.0" -node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: +node-gyp-build@^4.3.0: version "4.8.4" resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.4.tgz#8a70ee85464ae52327772a90d66c6077a900cfc8" integrity sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ== @@ -2577,13 +1270,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -o3@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/o3/-/o3-1.0.3.tgz#192ce877a882dfa6751f0412a865fafb2da1dac0" - integrity sha512-f+4n+vC6s4ysy7YO7O2gslWZBUu8Qj2i2OUJOvjRxQva7jVjYjB29jrr9NCjmxZQR0gzrOcv1RnqoYOeMs5VRQ== - dependencies: - capability "^0.2.5" - object-is@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.6.tgz#1a6a53aed2dd8f7e6775ff870bea58545956ab07" @@ -2609,35 +1295,13 @@ object.assign@^4.1.4: has-symbols "^1.1.0" object-keys "^1.1.1" -once@^1.3.0, once@^1.4.0: +once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" -onetime@^5.1.0: - version "5.1.2" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" - integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== - dependencies: - mimic-fn "^2.1.0" - -ora@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18" - integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ== - dependencies: - bl "^4.1.0" - chalk "^4.1.0" - cli-cursor "^3.1.0" - cli-spinners "^2.5.0" - is-interactive "^1.0.0" - is-unicode-supported "^0.1.0" - log-symbols "^4.1.0" - strip-ansi "^6.0.0" - wcwidth "^1.0.1" - p-limit@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" @@ -2672,18 +1336,6 @@ pathval@^1.1.1: resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== -pbkdf2@^3.0.9: - version "3.1.5" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.5.tgz#444a59d7a259a95536c56e80c89de31cc01ed366" - integrity sha512-Q3CG/cYvCO1ye4QKkuH7EXxs3VC/rI1/trd+qX2+PolbaKG0H+bgcZzrTt96mMyRtejk+JMCiLUn3y29W8qmFQ== - dependencies: - create-hash "^1.2.0" - create-hmac "^1.1.7" - ripemd160 "^2.0.3" - safe-buffer "^5.2.1" - sha.js "^2.4.12" - to-buffer "^1.2.1" - picomatch@^2.0.4, picomatch@^2.2.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" @@ -2699,45 +1351,13 @@ prettier@3.6.2: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393" integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ== -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== - -randombytes@^2.0.1, randombytes@^2.1.0: +randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== dependencies: safe-buffer "^5.1.0" -readable-stream@^2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" - integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -readable-stream@^3.4.0, readable-stream@^3.6.0: - version "3.6.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" - integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -2750,27 +1370,6 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - -retry@0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - -ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.3.tgz#9be54e4ba5e3559c8eee06a25cd7648bbccdf5a8" - integrity sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA== - dependencies: - hash-base "^3.1.2" - inherits "^2.0.4" - rpc-websockets@^9.0.2: version "9.3.2" resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.3.2.tgz#26b4d7ebaf8e53422528619a3c314e83590d85bf" @@ -2787,28 +1386,11 @@ rpc-websockets@^9.0.2: bufferutil "^4.0.1" utf-8-validate "^5.0.2" -run-async@^2.4.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" - integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== - -rxjs@^7.5.5: - version "7.8.2" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.2.tgz#955bc473ed8af11a002a2be52071bf475638607b" - integrity sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA== - dependencies: - tslib "^2.1.0" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - safe-regex-test@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz#7f87dfb67a3150782eaaf18583ff5d1711ac10c1" @@ -2818,25 +1400,6 @@ safe-regex-test@^1.1.0: es-errors "^1.3.0" is-regex "^1.2.1" -"safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -scrypt-js@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" - integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== - -secp256k1@^4.0.2: - version "4.0.4" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.4.tgz#58f0bfe1830fe777d9ca1ffc7574962a8189f8ab" - integrity sha512-6JfvwvjUOn8F/jUoBY2Q1v5WY5XS+rj8qSe0v8Y4ezH4InLgTEeOOPQsRll9OV429Pvo6BCHGavIyJfr3TAhsw== - dependencies: - elliptic "^6.5.7" - node-addon-api "^5.0.0" - node-gyp-build "^4.2.0" - serialize-javascript@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" @@ -2856,25 +1419,6 @@ set-function-length@^1.2.2: gopd "^1.0.1" has-property-descriptors "^1.0.2" -setprototypeof@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" - integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== - -sha.js@^2.4.0, sha.js@^2.4.12, sha.js@^2.4.8: - version "2.4.12" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.12.tgz#eb8b568bf383dfd1867a32c3f2b74eb52bdbf23f" - integrity sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w== - dependencies: - inherits "^2.0.4" - safe-buffer "^5.2.1" - to-buffer "^1.2.0" - -signal-exit@^3.0.2: - version "3.0.7" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" - integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== - simple-swizzle@=0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" @@ -2958,11 +1502,6 @@ spl-token-bankrun@0.2.3: "@solana/spl-token" "^0.3.8" solana-bankrun "^0.2.0" -"statuses@>= 1.5.0 < 2": - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== - stream-chain@^2.2.5: version "2.2.5" resolved "https://registry.yarnpkg.com/stream-chain/-/stream-chain-2.2.5.tgz#b30967e8f14ee033c5b9a19bbe8a2cba90ba0d09" @@ -2975,11 +1514,6 @@ stream-json@^1.9.1: dependencies: stream-chain "^2.2.5" -stream-transform@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/stream-transform/-/stream-transform-3.4.0.tgz#38d562fbdad38c3b6cda959ad36751014bb26e18" - integrity sha512-QO3OGhKyeIV8p6eRQdG+W6WounFw519zk690hHCNfhgfP9bylVS+NTXsuBc7n+RsGn31UgFPGrWYIgoAbArKEw== - string-width@^4.1.0, string-width@^4.2.0: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -2989,20 +1523,6 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - strip-ansi@=6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -3050,32 +1570,6 @@ text-encoding-utf-8@^1.0.2: resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== -through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== - -tmp-promise@^3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.3.tgz#60a1a1cc98c988674fcbfd23b6e3367bdeac4ce7" - integrity sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ== - dependencies: - tmp "^0.2.0" - -tmp@^0.2.0: - version "0.2.5" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8" - integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow== - -to-buffer@^1.2.0, to-buffer@^1.2.1, to-buffer@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.2.2.tgz#ffe59ef7522ada0a2d1cb5dfe03bb8abc3cdc133" - integrity sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw== - dependencies: - isarray "^2.0.5" - safe-buffer "^5.2.1" - typed-array-buffer "^1.0.3" - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -3083,11 +1577,6 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -toidentifier@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" - integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== - toml@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" @@ -3131,45 +1620,21 @@ tsconfig-paths@^3.5.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@^2.0.3, tslib@^2.1.0, tslib@^2.8.0: +tslib@^2.0.3, tslib@^2.8.0: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== -tweetnacl@1.0.3, tweetnacl@^1.0.1, tweetnacl@^1.0.2, tweetnacl@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - type-detect@^4.0.0, type-detect@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.1.0.tgz#deb2453e8f08dcae7ae98c626b13dddb0155906c" integrity sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw== -type-fest@^0.21.3: - version "0.21.3" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" - integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== - -typed-array-buffer@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536" - integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw== - dependencies: - call-bound "^1.0.3" - es-errors "^1.3.0" - is-typed-array "^1.1.14" - typescript@5.9.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== -u3@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/u3/-/u3-0.1.1.tgz#5f52044f42ee76cd8de33148829e14528494b73b" - integrity sha512-+J5D5ir763y+Am/QY6hXNRlwljIeRMZMGs0cT6qqZVVzzT3X3nFPXVyPOFRMOR4kupB0T8JnCdpWdp6Q/iXn3w== - undici-types@~7.16.0: version "7.16.0" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" @@ -3182,11 +1647,6 @@ utf-8-validate@^5.0.2: dependencies: node-gyp-build "^4.3.0" -util-deprecate@^1.0.1, util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== - util@^0.12.5: version "0.12.5" resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" @@ -3203,18 +1663,6 @@ uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== -vlq@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/vlq/-/vlq-2.0.4.tgz#6057b85729245b9829e3cc7755f95b228d4fe041" - integrity sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA== - -wcwidth@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== - dependencies: - defaults "^1.0.3" - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" @@ -3253,7 +1701,7 @@ workerpool@6.2.0: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== -wrap-ansi@=7.0.0, wrap-ansi@^6.0.1, wrap-ansi@^7.0.0: +wrap-ansi@=7.0.0, wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -3267,11 +1715,6 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -ws@8.18.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" - integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== - ws@^7.5.10: version "7.5.10" resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" diff --git a/yarn.lock b/yarn.lock index 90504df33..e5a48204a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -138,161 +138,81 @@ resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.11.tgz#2ae33300598132cc4cf580dbbb28d30fed3c5c49" integrity sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg== -"@esbuild/android-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" - integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== - "@esbuild/android-arm64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.25.11.tgz#927708b3db5d739d6cb7709136924cc81bec9b03" integrity sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ== -"@esbuild/android-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" - integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== - "@esbuild/android-arm@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.25.11.tgz#571f94e7f4068957ec4c2cfb907deae3d01b55ae" integrity sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg== -"@esbuild/android-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" - integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== - "@esbuild/android-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.25.11.tgz#8a3bf5cae6c560c7ececa3150b2bde76e0fb81e6" integrity sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g== -"@esbuild/darwin-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" - integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== - "@esbuild/darwin-arm64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.11.tgz#0a678c4ac4bf8717e67481e1a797e6c152f93c84" integrity sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w== -"@esbuild/darwin-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" - integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== - "@esbuild/darwin-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.25.11.tgz#70f5e925a30c8309f1294d407a5e5e002e0315fe" integrity sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ== -"@esbuild/freebsd-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" - integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== - "@esbuild/freebsd-arm64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.11.tgz#4ec1db687c5b2b78b44148025da9632397553e8a" integrity sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA== -"@esbuild/freebsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" - integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== - "@esbuild/freebsd-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.11.tgz#4c81abd1b142f1e9acfef8c5153d438ca53f44bb" integrity sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw== -"@esbuild/linux-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" - integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== - "@esbuild/linux-arm64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.25.11.tgz#69517a111acfc2b93aa0fb5eaeb834c0202ccda5" integrity sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA== -"@esbuild/linux-arm@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" - integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== - "@esbuild/linux-arm@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.25.11.tgz#58dac26eae2dba0fac5405052b9002dac088d38f" integrity sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw== -"@esbuild/linux-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" - integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== - "@esbuild/linux-ia32@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.25.11.tgz#b89d4efe9bdad46ba944f0f3b8ddd40834268c2b" integrity sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw== -"@esbuild/linux-loong64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" - integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== - "@esbuild/linux-loong64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.25.11.tgz#11f603cb60ad14392c3f5c94d64b3cc8b630fbeb" integrity sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw== -"@esbuild/linux-mips64el@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" - integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== - "@esbuild/linux-mips64el@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.11.tgz#b7d447ff0676b8ab247d69dac40a5cf08e5eeaf5" integrity sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ== -"@esbuild/linux-ppc64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" - integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== - "@esbuild/linux-ppc64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.11.tgz#b3a28ed7cc252a61b07ff7c8fd8a984ffd3a2f74" integrity sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw== -"@esbuild/linux-riscv64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" - integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== - "@esbuild/linux-riscv64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.11.tgz#ce75b08f7d871a75edcf4d2125f50b21dc9dc273" integrity sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww== -"@esbuild/linux-s390x@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" - integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== - "@esbuild/linux-s390x@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.25.11.tgz#cd08f6c73b6b6ff9ccdaabbd3ff6ad3dca99c263" integrity sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw== -"@esbuild/linux-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" - integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== - "@esbuild/linux-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.25.11.tgz#3c3718af31a95d8946ebd3c32bb1e699bdf74910" @@ -303,11 +223,6 @@ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.11.tgz#b4c767082401e3a4e8595fe53c47cd7f097c8077" integrity sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg== -"@esbuild/netbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" - integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== - "@esbuild/netbsd-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.11.tgz#f2a930458ed2941d1f11ebc34b9c7d61f7a4d034" @@ -318,11 +233,6 @@ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.11.tgz#b4ae93c75aec48bc1e8a0154957a05f0641f2dad" integrity sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg== -"@esbuild/openbsd-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" - integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== - "@esbuild/openbsd-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.11.tgz#b42863959c8dcf9b01581522e40012d2c70045e2" @@ -333,41 +243,21 @@ resolved "https://registry.yarnpkg.com/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.11.tgz#b2e717141c8fdf6bddd4010f0912e6b39e1640f1" integrity sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ== -"@esbuild/sunos-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" - integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== - "@esbuild/sunos-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.25.11.tgz#9fbea1febe8778927804828883ec0f6dd80eb244" integrity sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA== -"@esbuild/win32-arm64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" - integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== - "@esbuild/win32-arm64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.25.11.tgz#501539cedb24468336073383989a7323005a8935" integrity sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q== -"@esbuild/win32-ia32@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" - integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== - "@esbuild/win32-ia32@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.25.11.tgz#8ac7229aa82cef8f16ffb58f1176a973a7a15343" integrity sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA== -"@esbuild/win32-x64@0.17.19": - version "0.17.19" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" - integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== - "@esbuild/win32-x64@0.25.11": version "0.25.11" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.11.tgz#5ecda6f3fe138b7e456f4e429edde33c823f392f" @@ -978,16 +868,11 @@ version "0.1.0-alpha.0" dependencies: "@coral-xyz/anchor" "^0.29.0" - "@metaplex-foundation/umi" "^0.9.2" - "@metaplex-foundation/umi-bundle-defaults" "^0.9.2" - "@metaplex-foundation/umi-uploader-bundlr" "^0.9.2" "@noble/hashes" "^1.4.0" "@solana/spl-token" "^0.3.7" "@solana/web3.js" "^1.76.0" "@sqds/multisig" "^2.1.4" bn.js "^5.2.1" - decimal.js "^10.4.3" - esbuild "^0.17.15" "@metaplex-foundation/beet-solana@0.4.0": version "0.4.0" @@ -1035,7 +920,7 @@ resolved "https://registry.yarnpkg.com/@metaplex-foundation/mpl-toolbox/-/mpl-toolbox-0.10.0.tgz#c7d2f27259e69ab86cc4b7dd55b7bfef11bbed13" integrity sha512-84KD1L5cFyw5xnntHwL4uPwfcrkKSiwuDeypiVr92qCUFuF3ZENa2zlFVPu+pQcjTlod2LmEX3MhBmNjRMpdKg== -"@metaplex-foundation/umi-bundle-defaults@^0.9.1", "@metaplex-foundation/umi-bundle-defaults@^0.9.2": +"@metaplex-foundation/umi-bundle-defaults@^0.9.1": version "0.9.2" resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-bundle-defaults/-/umi-bundle-defaults-0.9.2.tgz#f8e296b1a0ecb3a6511dbaca4131bc9263071cfc" integrity sha512-kV3tfvgvRjVP1p9OFOtH+ibOtN9omVJSwKr0We4/9r45e5LTj+32su0V/rixZUkG1EZzzOYBsxhtIE0kIw/Hrw== @@ -1147,7 +1032,7 @@ dependencies: "@metaplex-foundation/umi-web3js-adapters" "^0.9.2" -"@metaplex-foundation/umi-uploader-bundlr@^0.9.1", "@metaplex-foundation/umi-uploader-bundlr@^0.9.2": +"@metaplex-foundation/umi-uploader-bundlr@^0.9.1": version "0.9.2" resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi-uploader-bundlr/-/umi-uploader-bundlr-0.9.2.tgz#0d832816a32970cac9f412a0b0a8234415ab8534" integrity sha512-wmixKqWyEO0lRB2GNvm5XOwi3jEyCtPZ6Oqds6sY5YHYdrn1Cqgd1TcdAuu7+DuojcNFErTjWsaQ1F9QR502QQ== @@ -1171,7 +1056,7 @@ dependencies: buffer "^6.0.3" -"@metaplex-foundation/umi@^0.9.1", "@metaplex-foundation/umi@^0.9.2": +"@metaplex-foundation/umi@^0.9.1": version "0.9.2" resolved "https://registry.yarnpkg.com/@metaplex-foundation/umi/-/umi-0.9.2.tgz#6460bff91d2ac7745842eda1ee6a28fba4d2ffb2" integrity sha512-9i4Acm4pruQfJcpRrc2EauPBwkfDN0I9QTvJyZocIlKgoZwD6A6wH0PViH1AjOVG5CQCd1YI3tJd5XjYE1ElBw== @@ -2494,7 +2379,7 @@ decamelize@^4.0.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -decimal.js@^10.4.2, decimal.js@^10.4.3: +decimal.js@^10.4.2: version "10.6.0" resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.6.0.tgz#e649a43e3ab953a72192ff5983865e509f37ed9a" integrity sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg== @@ -2654,34 +2539,6 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" -esbuild@^0.17.15: - version "0.17.19" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" - integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== - optionalDependencies: - "@esbuild/android-arm" "0.17.19" - "@esbuild/android-arm64" "0.17.19" - "@esbuild/android-x64" "0.17.19" - "@esbuild/darwin-arm64" "0.17.19" - "@esbuild/darwin-x64" "0.17.19" - "@esbuild/freebsd-arm64" "0.17.19" - "@esbuild/freebsd-x64" "0.17.19" - "@esbuild/linux-arm" "0.17.19" - "@esbuild/linux-arm64" "0.17.19" - "@esbuild/linux-ia32" "0.17.19" - "@esbuild/linux-loong64" "0.17.19" - "@esbuild/linux-mips64el" "0.17.19" - "@esbuild/linux-ppc64" "0.17.19" - "@esbuild/linux-riscv64" "0.17.19" - "@esbuild/linux-s390x" "0.17.19" - "@esbuild/linux-x64" "0.17.19" - "@esbuild/netbsd-x64" "0.17.19" - "@esbuild/openbsd-x64" "0.17.19" - "@esbuild/sunos-x64" "0.17.19" - "@esbuild/win32-arm64" "0.17.19" - "@esbuild/win32-ia32" "0.17.19" - "@esbuild/win32-x64" "0.17.19" - esbuild@~0.25.0: version "0.25.11" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.25.11.tgz#0f31b82f335652580f75ef6897bba81962d9ae3d" From 93be94a38586db83a6625ddacbdd5142bbfa33dd Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 29 Apr 2026 23:17:45 +0200 Subject: [PATCH 097/100] update sdk package version --- sdk/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/package.json b/sdk/package.json index 996779c06..dfa0ec17a 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@metadaoproject/programs", - "version": "0.1.0-alpha.0", + "version": "0.1.0-alpha.1", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/yarn.lock b/yarn.lock index e5a48204a..374642413 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.0" + version "0.1.0-alpha.1" dependencies: "@coral-xyz/anchor" "^0.29.0" "@noble/hashes" "^1.4.0" From 7b0f009c3e6c7419d616a4e5e28972e75426b955 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 29 Apr 2026 23:56:38 +0200 Subject: [PATCH 098/100] remove unused files --- sdk/src/v0.7/types/launchpad_v8.ts | 3767 --------------------------- sdk/src/v0.7/types/v08_launchpad.ts | 123 - 2 files changed, 3890 deletions(-) delete mode 100644 sdk/src/v0.7/types/launchpad_v8.ts delete mode 100644 sdk/src/v0.7/types/v08_launchpad.ts diff --git a/sdk/src/v0.7/types/launchpad_v8.ts b/sdk/src/v0.7/types/launchpad_v8.ts deleted file mode 100644 index 42cbef700..000000000 --- a/sdk/src/v0.7/types/launchpad_v8.ts +++ /dev/null @@ -1,3767 +0,0 @@ -export type LaunchpadV8 = { - version: "0.8.0"; - name: "launchpad_v8"; - instructions: [ - { - name: "initializeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "quoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseVault"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - isOptional: true; - }, - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "mintGovernorProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "rent"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "InitializeLaunchArgs"; - }; - }, - ]; - }, - { - name: "startLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "fund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: true; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - ]; - }, - { - name: "closeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "setFundingRecordApproval"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "approvedAmount"; - type: "u64"; - }, - ]; - }, - { - name: "settleLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "launchAuthority"; - isMut: false; - isSigner: true; - isOptional: true; - }, - { - name: "tokenMetadata"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "treasuryQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: true; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "daoOwnedLpPosition"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "futarchyAmmQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "dao"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: true; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "spendingLimit"; - isMut: true; - isSigner: false; - }, - { - name: "bidWall"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallQuoteTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "feeRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "staticAccounts"; - accounts: [ - { - name: "futarchyProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenMetadataProgram"; - isMut: false; - isSigner: false; - }, - { - name: "futarchyEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgramConfigTreasury"; - isMut: true; - isSigner: false; - }, - { - name: "bidWallProgram"; - isMut: false; - isSigner: false; - }, - { - name: "bidWallEventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "meteoraAccounts"; - accounts: [ - { - name: "dammV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "config"; - isMut: false; - isSigner: false; - }, - { - name: "token2022Program"; - isMut: false; - isSigner: false; - }, - { - name: "positionNftAccount"; - isMut: true; - isSigner: false; - }, - { - name: "pool"; - isMut: true; - isSigner: false; - }, - { - name: "position"; - isMut: true; - isSigner: false; - }, - { - name: "positionNftMint"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "quoteMint"; - isMut: false; - isSigner: false; - }, - { - name: "tokenAVault"; - isMut: true; - isSigner: false; - }, - { - name: "tokenBVault"; - isMut: true; - isSigner: false; - }, - { - name: "poolCreatorAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "poolAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "dammV2EventAuthority"; - isMut: false; - isSigner: false; - }, - ]; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claim"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "refund"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "fundingRecord"; - isMut: true; - isSigner: false; - }, - { - name: "launchQuoteVault"; - isMut: true; - isSigner: false; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "funder"; - isMut: false; - isSigner: false; - }, - { - name: "funderQuoteAccount"; - isMut: true; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "claimAdditionalTokenAllocation"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "launchBaseVault"; - isMut: true; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipient"; - isMut: false; - isSigner: false; - }, - { - name: "additionalTokensRecipientTokenAccount"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "associatedTokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "finalizeLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "payer"; - isMut: true; - isSigner: true; - }, - { - name: "launchSigner"; - isMut: false; - isSigner: false; - }, - { - name: "baseMint"; - isMut: false; - isSigner: false; - }, - { - name: "dao"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisig"; - isMut: false; - isSigner: false; - }, - { - name: "squadsMultisigVault"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackageGrantee"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernor"; - isMut: true; - isSigner: false; - }, - { - name: "ppMintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "daoMintAuthority"; - isMut: true; - isSigner: false; - }, - { - name: "performancePackage"; - isMut: true; - isSigner: false; - }, - { - name: "systemProgram"; - isMut: false; - isSigner: false; - }, - { - name: "tokenProgram"; - isMut: false; - isSigner: false; - }, - { - name: "squadsProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorProgram"; - isMut: false; - isSigner: false; - }, - { - name: "mintGovernorEventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackageV2Program"; - isMut: false; - isSigner: false; - }, - { - name: "performancePackageV2EventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: []; - }, - { - name: "extendLaunch"; - accounts: [ - { - name: "launch"; - isMut: true; - isSigner: false; - }, - { - name: "admin"; - isMut: false; - isSigner: true; - }, - { - name: "eventAuthority"; - isMut: false; - isSigner: false; - }, - { - name: "program"; - isMut: false; - isSigner: false; - }, - ]; - args: [ - { - name: "args"; - type: { - defined: "ExtendLaunchArgs"; - }; - }, - ]; - }, - ]; - accounts: [ - { - name: "fundingRecord"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "funder"; - docs: ["The funder."]; - type: "publicKey"; - }, - { - name: "launch"; - docs: ["The launch."]; - type: "publicKey"; - }, - { - name: "committedAmount"; - docs: ["The amount of USDC that has been committed by the funder."]; - type: "u64"; - }, - { - name: "isTokensClaimed"; - docs: ["Whether the tokens have been claimed."]; - type: "bool"; - }, - { - name: "isUsdcRefunded"; - docs: ["Whether the USDC has been refunded."]; - type: "bool"; - }, - { - name: "approvedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ]; - type: "u64"; - }, - { - name: "committedAmountAccumulator"; - docs: [ - "Running integral of committed_amount over time (committed_amount * seconds).", - ]; - type: "u128"; - }, - { - name: "lastAccumulatorUpdate"; - docs: ["Unix timestamp of the last accumulator update."]; - type: "i64"; - }, - ]; - }; - }, - { - name: "launch"; - type: { - kind: "struct"; - fields: [ - { - name: "pdaBump"; - docs: ["The PDA bump."]; - type: "u8"; - }, - { - name: "minimumRaiseAmount"; - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ]; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - docs: [ - "The wallets that have access to the monthly spending limit.", - ]; - type: { - vec: "publicKey"; - }; - }, - { - name: "launchAuthority"; - docs: ["The account that can start the launch."]; - type: "publicKey"; - }, - { - name: "launchSigner"; - docs: ["The launch signer address."]; - type: "publicKey"; - }, - { - name: "launchSignerPdaBump"; - docs: ["The PDA bump for the launch signer."]; - type: "u8"; - }, - { - name: "launchQuoteVault"; - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ]; - type: "publicKey"; - }, - { - name: "launchBaseVault"; - docs: ["The token vault, used to send tokens to the AMM."]; - type: "publicKey"; - }, - { - name: "baseMint"; - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ]; - type: "publicKey"; - }, - { - name: "quoteMint"; - docs: ["The USDC mint."]; - type: "publicKey"; - }, - { - name: "unixTimestampStarted"; - docs: ["The unix timestamp when the launch was started."]; - type: { - option: "i64"; - }; - }, - { - name: "unixTimestampClosed"; - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ]; - type: { - option: "i64"; - }; - }, - { - name: "totalCommittedAmount"; - docs: ["The amount of USDC that has been committed by the users."]; - type: "u64"; - }, - { - name: "state"; - docs: ["The state of the launch."]; - type: { - defined: "LaunchState"; - }; - }, - { - name: "seqNum"; - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ]; - type: "u64"; - }, - { - name: "secondsForLaunch"; - docs: ["The number of seconds that the launch will be live for."]; - type: "u32"; - }, - { - name: "dao"; - docs: ["The DAO, if the launch is complete."]; - type: { - option: "publicKey"; - }; - }, - { - name: "daoVault"; - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "performancePackageGrantee"; - docs: [ - "The address that will receive the performance package tokens.", - ]; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ]; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ]; - type: "u8"; - }, - { - name: "teamAddress"; - docs: ["The initial address used to sponsor team proposals."]; - type: "publicKey"; - }, - { - name: "totalApprovedAmount"; - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ]; - type: "u64"; - }, - { - name: "additionalTokensAmount"; - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ]; - type: "u64"; - }, - { - name: "additionalTokensRecipient"; - docs: [ - "The token account that will receive the additional tokens.", - ]; - type: { - option: "publicKey"; - }; - }, - { - name: "additionalTokensClaimed"; - docs: ["Are the additional tokens claimed."]; - type: "bool"; - }, - { - name: "unixTimestampCompleted"; - docs: ["The unix timestamp when the launch was completed."]; - type: { - option: "i64"; - }; - }, - { - name: "isFinalized"; - docs: ["Whether the launch has been finalized."]; - type: "bool"; - }, - { - name: "accumulatorActivationDelaySeconds"; - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ]; - type: "u32"; - }, - { - name: "hasBidWall"; - docs: ["Whether the launch has a bid wall."]; - type: "bool"; - }, - { - name: "mintGovernor"; - docs: ["The MintGovernor PDA that owns the SPL mint authority."]; - type: "publicKey"; - }, - ]; - }; - }, - ]; - types: [ - { - name: "CommonFields"; - type: { - kind: "struct"; - fields: [ - { - name: "slot"; - type: "u64"; - }, - { - name: "unixTimestamp"; - type: "i64"; - }, - { - name: "launchSeqNum"; - type: "u64"; - }, - ]; - }; - }, - { - name: "ExtendLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "durationSeconds"; - type: "u32"; - }, - ]; - }; - }, - { - name: "InitializeLaunchArgs"; - type: { - kind: "struct"; - fields: [ - { - name: "minimumRaiseAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - }, - { - name: "secondsForLaunch"; - type: "u32"; - }, - { - name: "tokenName"; - type: "string"; - }, - { - name: "tokenSymbol"; - type: "string"; - }, - { - name: "tokenUri"; - type: "string"; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - }, - { - name: "teamAddress"; - type: "publicKey"; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - }, - { - name: "accumulatorActivationDelaySeconds"; - type: "u32"; - }, - { - name: "hasBidWall"; - type: "bool"; - }, - ]; - }; - }, - { - name: "LaunchState"; - type: { - kind: "enum"; - variants: [ - { - name: "Initialized"; - }, - { - name: "Live"; - }, - { - name: "Closed"; - }, - { - name: "Complete"; - }, - { - name: "Refunding"; - }, - ]; - }; - }, - ]; - events: [ - { - name: "LaunchInitializedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "minimumRaiseAmount"; - type: "u64"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "launchSigner"; - type: "publicKey"; - index: false; - }, - { - name: "launchSignerPdaBump"; - type: "u8"; - index: false; - }, - { - name: "launchUsdcVault"; - type: "publicKey"; - index: false; - }, - { - name: "launchTokenVault"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageGrantee"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackageTokenAmount"; - type: "u64"; - index: false; - }, - { - name: "monthsUntilInsidersCanUnlock"; - type: "u8"; - index: false; - }, - { - name: "monthlySpendingLimitAmount"; - type: "u64"; - index: false; - }, - { - name: "monthlySpendingLimitMembers"; - type: { - vec: "publicKey"; - }; - index: false; - }, - { - name: "baseMint"; - type: "publicKey"; - index: false; - }, - { - name: "quoteMint"; - type: "publicKey"; - index: false; - }, - { - name: "pdaBump"; - type: "u8"; - index: false; - }, - { - name: "secondsForLaunch"; - type: "u32"; - index: false; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - index: false; - }, - { - name: "additionalTokensRecipient"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "accumulatorActivationDelaySeconds"; - type: "u32"; - index: false; - }, - { - name: "hasBidWall"; - type: "bool"; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchStartedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "launchAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "slotStarted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "amount"; - type: "u64"; - index: false; - }, - { - name: "totalCommittedByFunder"; - type: "u64"; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "committedAmountAccumulator"; - type: "u128"; - index: false; - }, - ]; - }, - { - name: "FundingRecordApprovalSetEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "approvedAmount"; - type: "u64"; - index: false; - }, - { - name: "totalApproved"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchSettledEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "finalState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - { - name: "totalCommitted"; - type: "u64"; - index: false; - }, - { - name: "dao"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "daoTreasury"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "totalApprovedAmount"; - type: "u64"; - index: false; - }, - { - name: "bidWall"; - type: { - option: "publicKey"; - }; - index: false; - }, - { - name: "bidWallAmount"; - type: "u64"; - index: false; - }, - { - name: "tokensMinted"; - type: "u64"; - index: false; - }, - ]; - }, - { - name: "LaunchFinalizedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "performancePackage"; - type: "publicKey"; - index: false; - }, - { - name: "mintGovernor"; - type: "publicKey"; - index: false; - }, - { - name: "mintGovernorNewAdmin"; - type: "publicKey"; - index: false; - }, - { - name: "ppMintAuthority"; - type: "publicKey"; - index: false; - }, - { - name: "daoMintAuthority"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchRefundedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "usdcRefunded"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchClaimEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "funder"; - type: "publicKey"; - index: false; - }, - { - name: "tokensClaimed"; - type: "u64"; - index: false; - }, - { - name: "fundingRecord"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchCloseEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "newState"; - type: { - defined: "LaunchState"; - }; - index: false; - }, - ]; - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "additionalTokensAmount"; - type: "u64"; - index: false; - }, - { - name: "additionalTokensRecipient"; - type: "publicKey"; - index: false; - }, - ]; - }, - { - name: "LaunchExtendedEvent"; - fields: [ - { - name: "common"; - type: { - defined: "CommonFields"; - }; - index: false; - }, - { - name: "launch"; - type: "publicKey"; - index: false; - }, - { - name: "oldSecondsForLaunch"; - type: "u32"; - index: false; - }, - { - name: "newSecondsForLaunch"; - type: "u32"; - index: false; - }, - ]; - }, - ]; - errors: [ - { - code: 6000; - name: "InvalidAmount"; - msg: "Invalid amount"; - }, - { - code: 6001; - name: "SupplyNonZero"; - msg: "Supply must be zero"; - }, - { - code: 6002; - name: "InvalidSecondsForLaunch"; - msg: "Launch period must be between 1 hour and 2 weeks"; - }, - { - code: 6003; - name: "InsufficientFunds"; - msg: "Insufficient funds"; - }, - { - code: 6004; - name: "InvalidLaunchState"; - msg: "Invalid launch state"; - }, - { - code: 6005; - name: "LaunchPeriodNotOver"; - msg: "Launch period not over"; - }, - { - code: 6006; - name: "LaunchExpired"; - msg: "Launch is complete, no more funding allowed"; - }, - { - code: 6007; - name: "LaunchNotRefunding"; - msg: "Refund not available"; - }, - { - code: 6008; - name: "LaunchNotInitialized"; - msg: "Launch must be initialized to be started"; - }, - { - code: 6009; - name: "FreezeAuthoritySet"; - msg: "Freeze authority can't be set on launchpad tokens"; - }, - { - code: 6010; - name: "InvalidMonthlySpendingLimit"; - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0"; - }, - { - code: 6011; - name: "InvalidMonthlySpendingLimitMembers"; - msg: "There can only be at most 10 monthly spending limit members"; - }, - { - code: 6012; - name: "InvalidPerformancePackageTokenAmount"; - msg: "Invalid performance package token amount"; - }, - { - code: 6013; - name: "InvalidPerformancePackageMinUnlockTime"; - msg: "Insiders must wait at least 12 months before unlocking"; - }, - { - code: 6014; - name: "LaunchAuthorityNotSet"; - msg: "Launch authority must be set to complete the launch until 2 days after closing"; - }, - { - code: 6015; - name: "FinalRaiseAmountTooLow"; - msg: "The final amount raised must be >= the minimum raise amount"; - }, - { - code: 6016; - name: "TokensAlreadyClaimed"; - msg: "Tokens already claimed"; - }, - { - code: 6017; - name: "MoneyAlreadyRefunded"; - msg: "USDC already refunded"; - }, - { - code: 6018; - name: "InvariantViolated"; - msg: "Invariant violated"; - }, - { - code: 6019; - name: "LaunchNotLive"; - msg: "Launch must be live to be closed"; - }, - { - code: 6020; - name: "InvalidMinimumRaiseAmount"; - msg: "Minimum raise amount too low for liquidity"; - }, - { - code: 6021; - name: "FinalRaiseAmountAlreadySet"; - msg: "Final raise amount already set"; - }, - { - code: 6022; - name: "TotalApprovedAmountTooLow"; - msg: "Total approved amount too low"; - }, - { - code: 6023; - name: "InvalidAdditionalTokensRecipient"; - msg: "Additional tokens recipient must be set when amount > 0"; - }, - { - code: 6024; - name: "NoAdditionalTokensRecipientSet"; - msg: "No additional tokens recipient set"; - }, - { - code: 6025; - name: "AdditionalTokensAlreadyClaimed"; - msg: "Additional tokens already claimed"; - }, - { - code: 6026; - name: "FundingRecordApprovalPeriodOver"; - msg: "Funding record approval period is over"; - }, - { - code: 6027; - name: "PerformancePackageAlreadyInitialized"; - msg: "Performance package already initialized"; - }, - { - code: 6028; - name: "InvalidDao"; - msg: "Invalid DAO"; - }, - { - code: 6029; - name: "InvalidAccumulatorActivationDelaySeconds"; - msg: "Accumulator activation delay must be less than the launch duration"; - }, - { - code: 6030; - name: "ExtendDurationExceedsMax"; - msg: "Extend duration would exceed maximum allowed launch duration"; - }, - { - code: 6031; - name: "InvalidMintAuthority"; - msg: "Mint authority does not match expected"; - }, - { - code: 6032; - name: "InvalidMeteoraAccount"; - msg: "Invalid Meteora account"; - }, - ]; -}; - -export const IDL: LaunchpadV8 = { - version: "0.8.0", - name: "launchpad_v8", - instructions: [ - { - name: "initializeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "quoteVault", - isMut: true, - isSigner: false, - }, - { - name: "baseVault", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - isOptional: true, - }, - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "mintGovernorProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "rent", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "InitializeLaunchArgs", - }, - }, - ], - }, - { - name: "startLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "fund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: true, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "amount", - type: "u64", - }, - ], - }, - { - name: "closeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "setFundingRecordApproval", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "approvedAmount", - type: "u64", - }, - ], - }, - { - name: "settleLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "launchAuthority", - isMut: false, - isSigner: true, - isOptional: true, - }, - { - name: "tokenMetadata", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "treasuryQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: true, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "daoOwnedLpPosition", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "futarchyAmmQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "dao", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: true, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "spendingLimit", - isMut: true, - isSigner: false, - }, - { - name: "bidWall", - isMut: true, - isSigner: false, - }, - { - name: "bidWallQuoteTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "feeRecipient", - isMut: false, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "staticAccounts", - accounts: [ - { - name: "futarchyProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenMetadataProgram", - isMut: false, - isSigner: false, - }, - { - name: "futarchyEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfig", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgramConfigTreasury", - isMut: true, - isSigner: false, - }, - { - name: "bidWallProgram", - isMut: false, - isSigner: false, - }, - { - name: "bidWallEventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "meteoraAccounts", - accounts: [ - { - name: "dammV2Program", - isMut: false, - isSigner: false, - }, - { - name: "config", - isMut: false, - isSigner: false, - }, - { - name: "token2022Program", - isMut: false, - isSigner: false, - }, - { - name: "positionNftAccount", - isMut: true, - isSigner: false, - }, - { - name: "pool", - isMut: true, - isSigner: false, - }, - { - name: "position", - isMut: true, - isSigner: false, - }, - { - name: "positionNftMint", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "quoteMint", - isMut: false, - isSigner: false, - }, - { - name: "tokenAVault", - isMut: true, - isSigner: false, - }, - { - name: "tokenBVault", - isMut: true, - isSigner: false, - }, - { - name: "poolCreatorAuthority", - isMut: false, - isSigner: false, - }, - { - name: "poolAuthority", - isMut: false, - isSigner: false, - }, - { - name: "dammV2EventAuthority", - isMut: false, - isSigner: false, - }, - ], - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claim", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "refund", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "fundingRecord", - isMut: true, - isSigner: false, - }, - { - name: "launchQuoteVault", - isMut: true, - isSigner: false, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "funder", - isMut: false, - isSigner: false, - }, - { - name: "funderQuoteAccount", - isMut: true, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "claimAdditionalTokenAllocation", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "launchBaseVault", - isMut: true, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipient", - isMut: false, - isSigner: false, - }, - { - name: "additionalTokensRecipientTokenAccount", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "associatedTokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "finalizeLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "payer", - isMut: true, - isSigner: true, - }, - { - name: "launchSigner", - isMut: false, - isSigner: false, - }, - { - name: "baseMint", - isMut: false, - isSigner: false, - }, - { - name: "dao", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisig", - isMut: false, - isSigner: false, - }, - { - name: "squadsMultisigVault", - isMut: false, - isSigner: false, - }, - { - name: "performancePackageGrantee", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernor", - isMut: true, - isSigner: false, - }, - { - name: "ppMintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "daoMintAuthority", - isMut: true, - isSigner: false, - }, - { - name: "performancePackage", - isMut: true, - isSigner: false, - }, - { - name: "systemProgram", - isMut: false, - isSigner: false, - }, - { - name: "tokenProgram", - isMut: false, - isSigner: false, - }, - { - name: "squadsProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorProgram", - isMut: false, - isSigner: false, - }, - { - name: "mintGovernorEventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "performancePackageV2Program", - isMut: false, - isSigner: false, - }, - { - name: "performancePackageV2EventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [], - }, - { - name: "extendLaunch", - accounts: [ - { - name: "launch", - isMut: true, - isSigner: false, - }, - { - name: "admin", - isMut: false, - isSigner: true, - }, - { - name: "eventAuthority", - isMut: false, - isSigner: false, - }, - { - name: "program", - isMut: false, - isSigner: false, - }, - ], - args: [ - { - name: "args", - type: { - defined: "ExtendLaunchArgs", - }, - }, - ], - }, - ], - accounts: [ - { - name: "fundingRecord", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "funder", - docs: ["The funder."], - type: "publicKey", - }, - { - name: "launch", - docs: ["The launch."], - type: "publicKey", - }, - { - name: "committedAmount", - docs: ["The amount of USDC that has been committed by the funder."], - type: "u64", - }, - { - name: "isTokensClaimed", - docs: ["Whether the tokens have been claimed."], - type: "bool", - }, - { - name: "isUsdcRefunded", - docs: ["Whether the USDC has been refunded."], - type: "bool", - }, - { - name: "approvedAmount", - docs: [ - "The amount of USDC that the launch authority has approved for the funder.", - "If zero, the funder has not been approved for any amount.", - ], - type: "u64", - }, - { - name: "committedAmountAccumulator", - docs: [ - "Running integral of committed_amount over time (committed_amount * seconds).", - ], - type: "u128", - }, - { - name: "lastAccumulatorUpdate", - docs: ["Unix timestamp of the last accumulator update."], - type: "i64", - }, - ], - }, - }, - { - name: "launch", - type: { - kind: "struct", - fields: [ - { - name: "pdaBump", - docs: ["The PDA bump."], - type: "u8", - }, - { - name: "minimumRaiseAmount", - docs: [ - "The minimum amount of USDC that must be raised, otherwise", - "everyone can get their USDC back.", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - docs: [ - "The monthly spending limit the DAO allocates to the team. Must be", - "less than 1/6th of the minimum raise amount (so 6 months of burn).", - ], - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - docs: [ - "The wallets that have access to the monthly spending limit.", - ], - type: { - vec: "publicKey", - }, - }, - { - name: "launchAuthority", - docs: ["The account that can start the launch."], - type: "publicKey", - }, - { - name: "launchSigner", - docs: ["The launch signer address."], - type: "publicKey", - }, - { - name: "launchSignerPdaBump", - docs: ["The PDA bump for the launch signer."], - type: "u8", - }, - { - name: "launchQuoteVault", - docs: [ - "The USDC vault that will hold the USDC raised until the launch is over.", - ], - type: "publicKey", - }, - { - name: "launchBaseVault", - docs: ["The token vault, used to send tokens to the AMM."], - type: "publicKey", - }, - { - name: "baseMint", - docs: [ - "The token that will be minted to funders and that will control the DAO.", - ], - type: "publicKey", - }, - { - name: "quoteMint", - docs: ["The USDC mint."], - type: "publicKey", - }, - { - name: "unixTimestampStarted", - docs: ["The unix timestamp when the launch was started."], - type: { - option: "i64", - }, - }, - { - name: "unixTimestampClosed", - docs: [ - "The unix timestamp when the launch stopped taking new contributions.", - ], - type: { - option: "i64", - }, - }, - { - name: "totalCommittedAmount", - docs: ["The amount of USDC that has been committed by the users."], - type: "u64", - }, - { - name: "state", - docs: ["The state of the launch."], - type: { - defined: "LaunchState", - }, - }, - { - name: "seqNum", - docs: [ - "The sequence number of this launch. Useful for sorting events.", - ], - type: "u64", - }, - { - name: "secondsForLaunch", - docs: ["The number of seconds that the launch will be live for."], - type: "u32", - }, - { - name: "dao", - docs: ["The DAO, if the launch is complete."], - type: { - option: "publicKey", - }, - }, - { - name: "daoVault", - docs: [ - "The DAO treasury that USDC / LP is sent to, if the launch is complete.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "performancePackageGrantee", - docs: [ - "The address that will receive the performance package tokens.", - ], - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - docs: [ - "The amount of tokens to be granted to the performance package grantee.", - ], - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - docs: [ - "The number of months that insiders must wait before unlocking their tokens.", - ], - type: "u8", - }, - { - name: "teamAddress", - docs: ["The initial address used to sponsor team proposals."], - type: "publicKey", - }, - { - name: "totalApprovedAmount", - docs: [ - "The amount of USDC that the launch authority has approved across all funders.", - ], - type: "u64", - }, - { - name: "additionalTokensAmount", - docs: [ - "The amount of additional tokens to be minted on a successful launch.", - ], - type: "u64", - }, - { - name: "additionalTokensRecipient", - docs: [ - "The token account that will receive the additional tokens.", - ], - type: { - option: "publicKey", - }, - }, - { - name: "additionalTokensClaimed", - docs: ["Are the additional tokens claimed."], - type: "bool", - }, - { - name: "unixTimestampCompleted", - docs: ["The unix timestamp when the launch was completed."], - type: { - option: "i64", - }, - }, - { - name: "isFinalized", - docs: ["Whether the launch has been finalized."], - type: "bool", - }, - { - name: "accumulatorActivationDelaySeconds", - docs: [ - "Number of seconds after launch start before the funding accumulator", - "begins tracking.", - ], - type: "u32", - }, - { - name: "hasBidWall", - docs: ["Whether the launch has a bid wall."], - type: "bool", - }, - { - name: "mintGovernor", - docs: ["The MintGovernor PDA that owns the SPL mint authority."], - type: "publicKey", - }, - ], - }, - }, - ], - types: [ - { - name: "CommonFields", - type: { - kind: "struct", - fields: [ - { - name: "slot", - type: "u64", - }, - { - name: "unixTimestamp", - type: "i64", - }, - { - name: "launchSeqNum", - type: "u64", - }, - ], - }, - }, - { - name: "ExtendLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "durationSeconds", - type: "u32", - }, - ], - }, - }, - { - name: "InitializeLaunchArgs", - type: { - kind: "struct", - fields: [ - { - name: "minimumRaiseAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - }, - { - name: "secondsForLaunch", - type: "u32", - }, - { - name: "tokenName", - type: "string", - }, - { - name: "tokenSymbol", - type: "string", - }, - { - name: "tokenUri", - type: "string", - }, - { - name: "performancePackageGrantee", - type: "publicKey", - }, - { - name: "performancePackageTokenAmount", - type: "u64", - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - }, - { - name: "teamAddress", - type: "publicKey", - }, - { - name: "additionalTokensAmount", - type: "u64", - }, - { - name: "accumulatorActivationDelaySeconds", - type: "u32", - }, - { - name: "hasBidWall", - type: "bool", - }, - ], - }, - }, - { - name: "LaunchState", - type: { - kind: "enum", - variants: [ - { - name: "Initialized", - }, - { - name: "Live", - }, - { - name: "Closed", - }, - { - name: "Complete", - }, - { - name: "Refunding", - }, - ], - }, - }, - ], - events: [ - { - name: "LaunchInitializedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "minimumRaiseAmount", - type: "u64", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "launchSigner", - type: "publicKey", - index: false, - }, - { - name: "launchSignerPdaBump", - type: "u8", - index: false, - }, - { - name: "launchUsdcVault", - type: "publicKey", - index: false, - }, - { - name: "launchTokenVault", - type: "publicKey", - index: false, - }, - { - name: "performancePackageGrantee", - type: "publicKey", - index: false, - }, - { - name: "performancePackageTokenAmount", - type: "u64", - index: false, - }, - { - name: "monthsUntilInsidersCanUnlock", - type: "u8", - index: false, - }, - { - name: "monthlySpendingLimitAmount", - type: "u64", - index: false, - }, - { - name: "monthlySpendingLimitMembers", - type: { - vec: "publicKey", - }, - index: false, - }, - { - name: "baseMint", - type: "publicKey", - index: false, - }, - { - name: "quoteMint", - type: "publicKey", - index: false, - }, - { - name: "pdaBump", - type: "u8", - index: false, - }, - { - name: "secondsForLaunch", - type: "u32", - index: false, - }, - { - name: "additionalTokensAmount", - type: "u64", - index: false, - }, - { - name: "additionalTokensRecipient", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "accumulatorActivationDelaySeconds", - type: "u32", - index: false, - }, - { - name: "hasBidWall", - type: "bool", - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchStartedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "launchAuthority", - type: "publicKey", - index: false, - }, - { - name: "slotStarted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "amount", - type: "u64", - index: false, - }, - { - name: "totalCommittedByFunder", - type: "u64", - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "committedAmountAccumulator", - type: "u128", - index: false, - }, - ], - }, - { - name: "FundingRecordApprovalSetEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "approvedAmount", - type: "u64", - index: false, - }, - { - name: "totalApproved", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchSettledEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "finalState", - type: { - defined: "LaunchState", - }, - index: false, - }, - { - name: "totalCommitted", - type: "u64", - index: false, - }, - { - name: "dao", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "daoTreasury", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "totalApprovedAmount", - type: "u64", - index: false, - }, - { - name: "bidWall", - type: { - option: "publicKey", - }, - index: false, - }, - { - name: "bidWallAmount", - type: "u64", - index: false, - }, - { - name: "tokensMinted", - type: "u64", - index: false, - }, - ], - }, - { - name: "LaunchFinalizedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "performancePackage", - type: "publicKey", - index: false, - }, - { - name: "mintGovernor", - type: "publicKey", - index: false, - }, - { - name: "mintGovernorNewAdmin", - type: "publicKey", - index: false, - }, - { - name: "ppMintAuthority", - type: "publicKey", - index: false, - }, - { - name: "daoMintAuthority", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchRefundedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "usdcRefunded", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchClaimEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "funder", - type: "publicKey", - index: false, - }, - { - name: "tokensClaimed", - type: "u64", - index: false, - }, - { - name: "fundingRecord", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchCloseEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "newState", - type: { - defined: "LaunchState", - }, - index: false, - }, - ], - }, - { - name: "LaunchClaimAdditionalTokenAllocationEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "additionalTokensAmount", - type: "u64", - index: false, - }, - { - name: "additionalTokensRecipient", - type: "publicKey", - index: false, - }, - ], - }, - { - name: "LaunchExtendedEvent", - fields: [ - { - name: "common", - type: { - defined: "CommonFields", - }, - index: false, - }, - { - name: "launch", - type: "publicKey", - index: false, - }, - { - name: "oldSecondsForLaunch", - type: "u32", - index: false, - }, - { - name: "newSecondsForLaunch", - type: "u32", - index: false, - }, - ], - }, - ], - errors: [ - { - code: 6000, - name: "InvalidAmount", - msg: "Invalid amount", - }, - { - code: 6001, - name: "SupplyNonZero", - msg: "Supply must be zero", - }, - { - code: 6002, - name: "InvalidSecondsForLaunch", - msg: "Launch period must be between 1 hour and 2 weeks", - }, - { - code: 6003, - name: "InsufficientFunds", - msg: "Insufficient funds", - }, - { - code: 6004, - name: "InvalidLaunchState", - msg: "Invalid launch state", - }, - { - code: 6005, - name: "LaunchPeriodNotOver", - msg: "Launch period not over", - }, - { - code: 6006, - name: "LaunchExpired", - msg: "Launch is complete, no more funding allowed", - }, - { - code: 6007, - name: "LaunchNotRefunding", - msg: "Refund not available", - }, - { - code: 6008, - name: "LaunchNotInitialized", - msg: "Launch must be initialized to be started", - }, - { - code: 6009, - name: "FreezeAuthoritySet", - msg: "Freeze authority can't be set on launchpad tokens", - }, - { - code: 6010, - name: "InvalidMonthlySpendingLimit", - msg: "Monthly spending limit must be less than 1/6th of the minimum raise amount and cannot be 0", - }, - { - code: 6011, - name: "InvalidMonthlySpendingLimitMembers", - msg: "There can only be at most 10 monthly spending limit members", - }, - { - code: 6012, - name: "InvalidPerformancePackageTokenAmount", - msg: "Invalid performance package token amount", - }, - { - code: 6013, - name: "InvalidPerformancePackageMinUnlockTime", - msg: "Insiders must wait at least 12 months before unlocking", - }, - { - code: 6014, - name: "LaunchAuthorityNotSet", - msg: "Launch authority must be set to complete the launch until 2 days after closing", - }, - { - code: 6015, - name: "FinalRaiseAmountTooLow", - msg: "The final amount raised must be >= the minimum raise amount", - }, - { - code: 6016, - name: "TokensAlreadyClaimed", - msg: "Tokens already claimed", - }, - { - code: 6017, - name: "MoneyAlreadyRefunded", - msg: "USDC already refunded", - }, - { - code: 6018, - name: "InvariantViolated", - msg: "Invariant violated", - }, - { - code: 6019, - name: "LaunchNotLive", - msg: "Launch must be live to be closed", - }, - { - code: 6020, - name: "InvalidMinimumRaiseAmount", - msg: "Minimum raise amount too low for liquidity", - }, - { - code: 6021, - name: "FinalRaiseAmountAlreadySet", - msg: "Final raise amount already set", - }, - { - code: 6022, - name: "TotalApprovedAmountTooLow", - msg: "Total approved amount too low", - }, - { - code: 6023, - name: "InvalidAdditionalTokensRecipient", - msg: "Additional tokens recipient must be set when amount > 0", - }, - { - code: 6024, - name: "NoAdditionalTokensRecipientSet", - msg: "No additional tokens recipient set", - }, - { - code: 6025, - name: "AdditionalTokensAlreadyClaimed", - msg: "Additional tokens already claimed", - }, - { - code: 6026, - name: "FundingRecordApprovalPeriodOver", - msg: "Funding record approval period is over", - }, - { - code: 6027, - name: "PerformancePackageAlreadyInitialized", - msg: "Performance package already initialized", - }, - { - code: 6028, - name: "InvalidDao", - msg: "Invalid DAO", - }, - { - code: 6029, - name: "InvalidAccumulatorActivationDelaySeconds", - msg: "Accumulator activation delay must be less than the launch duration", - }, - { - code: 6030, - name: "ExtendDurationExceedsMax", - msg: "Extend duration would exceed maximum allowed launch duration", - }, - { - code: 6031, - name: "InvalidMintAuthority", - msg: "Mint authority does not match expected", - }, - { - code: 6032, - name: "InvalidMeteoraAccount", - msg: "Invalid Meteora account", - }, - ], -}; diff --git a/sdk/src/v0.7/types/v08_launchpad.ts b/sdk/src/v0.7/types/v08_launchpad.ts deleted file mode 100644 index c769e0c68..000000000 --- a/sdk/src/v0.7/types/v08_launchpad.ts +++ /dev/null @@ -1,123 +0,0 @@ -export type V08Launchpad = { - version: "0.8.0"; - name: "v08_launchpad"; - instructions: [ - { - name: "initializeLaunch"; - accounts: []; - args: []; - }, - { - name: "startLaunch"; - accounts: []; - args: []; - }, - { - name: "fund"; - accounts: []; - args: []; - }, - { - name: "setFundingRecordApproval"; - accounts: []; - args: []; - }, - { - name: "closeLaunch"; - accounts: []; - args: []; - }, - { - name: "settleLaunch"; - accounts: []; - args: []; - }, - { - name: "finalizeLaunch"; - accounts: []; - args: []; - }, - { - name: "claim"; - accounts: []; - args: []; - }, - { - name: "refund"; - accounts: []; - args: []; - }, - { - name: "claimAdditionalTokenAllocation"; - accounts: []; - args: []; - }, - { - name: "extendLaunch"; - accounts: []; - args: []; - }, - ]; -}; - -export const IDL: V08Launchpad = { - version: "0.8.0", - name: "v08_launchpad", - instructions: [ - { - name: "initializeLaunch", - accounts: [], - args: [], - }, - { - name: "startLaunch", - accounts: [], - args: [], - }, - { - name: "fund", - accounts: [], - args: [], - }, - { - name: "setFundingRecordApproval", - accounts: [], - args: [], - }, - { - name: "closeLaunch", - accounts: [], - args: [], - }, - { - name: "settleLaunch", - accounts: [], - args: [], - }, - { - name: "finalizeLaunch", - accounts: [], - args: [], - }, - { - name: "claim", - accounts: [], - args: [], - }, - { - name: "refund", - accounts: [], - args: [], - }, - { - name: "claimAdditionalTokenAllocation", - accounts: [], - args: [], - }, - { - name: "extendLaunch", - accounts: [], - args: [], - }, - ], -}; From 0f10d8fda7feafcc3a68df408320014b5a782db4 Mon Sep 17 00:00:00 2001 From: Pileks Date: Fri, 1 May 2026 01:03:18 +0200 Subject: [PATCH 099/100] adds full lifecycle launchpad_v8 -> performance_package_v2 + mint_governor test --- .../launchpad_v8_tranche_lifecycle.test.ts | 447 ++++++++++++++++++ tests/main.test.ts | 2 + 2 files changed, 449 insertions(+) create mode 100644 tests/integration/launchpad_v8_tranche_lifecycle.test.ts diff --git a/tests/integration/launchpad_v8_tranche_lifecycle.test.ts b/tests/integration/launchpad_v8_tranche_lifecycle.test.ts new file mode 100644 index 000000000..05e326c6f --- /dev/null +++ b/tests/integration/launchpad_v8_tranche_lifecycle.test.ts @@ -0,0 +1,447 @@ +import { + ComputeBudgetProgram, + Keypair, + PublicKey, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { assert } from "chai"; +import { + MAINNET_USDC, + LAUNCHPAD_V0_8_PROGRAM_ID, + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, +} from "@metadaoproject/programs"; +import { LaunchpadClient } from "@metadaoproject/programs/launchpad/v0.8"; +import BN from "bn.js"; +import { initializeMintWithSeeds } from "../launchpad_v8/utils.js"; +import { createLookupTableForTransaction, expectError } from "../utils.js"; + +// Hardcoded from programs/v08_launchpad/src/lib.rs:30-48 (not SDK-exported). +const PRICE_SCALE = new BN("1000000000000"); // 1e12 +const TOKENS_TO_PARTICIPANTS = new BN(10_000_000_000_000); // 10M tokens × 1e6 +const PP_TWAP_MIN_DURATION_SEC = 3 * 30 * 24 * 60 * 60; // 7_776_000 + +export default async function suite() { + before(async function () { + const dynamicConfig = await this.banksClient.getAccount( + new PublicKey("4mPQ4VuvvtYL3CeMPt14Uj1CLpBWcVdJoLoTH9ea4Kod"), + ); + + const poolCreatorAuthorityOffset = 8 + 32; + const configTypeOffset = 8 + 32 + 32 + 128 + 1 + 1; + + const [poolCreatorAuthority] = PublicKey.findProgramAddressSync( + [Buffer.from("damm_pool_creator_authority")], + LAUNCHPAD_V0_8_PROGRAM_ID, + ); + + dynamicConfig.data.set( + poolCreatorAuthority.toBuffer(), + poolCreatorAuthorityOffset, + ); + dynamicConfig.data.set([1], configTypeOffset); + + this.context.setAccount( + LAUNCHPAD_V0_8_MAINNET_METEORA_CONFIG, + dynamicConfig, + ); + }); + + it("trades the AMM up through every tranche and unlocks the full performance package", async function () { + // 620 cranking swaps + 5 unlock cycles. Bankrun is fast but JS RPC + // overhead per tx still adds up; give it 5 minutes. + this.timeout(5 * 60 * 1000); + + const launchpadClient: LaunchpadClient = this.launchpad_v8; + const futarchyClient = launchpadClient.futarchyClient; + + const funder1 = Keypair.generate(); + const funder2 = Keypair.generate(); + const funder3 = Keypair.generate(); + const launchAuthority = Keypair.generate(); + const grantee = Keypair.generate(); + const additionalTokensRecipient = Keypair.generate(); + + const minRaise = new BN(300_000 * 10 ** 6); + const launchPeriod = 60 * 60 * 24 * 2; + const monthlySpendingLimitAmount = new BN(25_000 * 10 ** 6); + const performancePackageTokenAmount = new BN(5_000_000 * 10 ** 6); // 5M + const additionalTokensAmount = new BN(1_000_000 * 10 ** 6); + const monthsUntilInsidersCanUnlock = 24; + const totalApproved = new BN(500_000 * 10 ** 6); // 250 + 100 + 150 + + const launchPrice = totalApproved + .mul(PRICE_SCALE) + .div(TOKENS_TO_PARTICIPANTS); + + // ============================================================ + // Phase A — Lifecycle (init → … → claim_additional) + // Mirrors launchpad_v8_full_lifecycle.test.ts:50-446 without the + // intermediate assertions; those are owned by that test and the + // per-instruction unit tests. + // ============================================================ + + const result = await initializeMintWithSeeds( + this.banksClient, + launchpadClient, + this.payer, + ); + const META = result.tokenMint; + const launch = result.launch; + const launchSigner = result.launchSigner; + + await this.createTokenAccount(MAINNET_USDC, funder1.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder2.publicKey); + await this.createTokenAccount(MAINNET_USDC, funder3.publicKey); + + await this.transfer( + MAINNET_USDC, + this.payer, + funder1.publicKey, + 500_000_000000, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder2.publicKey, + 200_000_000000, + ); + await this.transfer( + MAINNET_USDC, + this.payer, + funder3.publicKey, + 400_000_000000, + ); + + await launchpadClient + .initializeLaunchIx({ + tokenName: "META", + tokenSymbol: "META", + tokenUri: "https://example.com", + minimumRaiseAmount: minRaise, + secondsForLaunch: launchPeriod, + baseMint: META, + quoteMint: MAINNET_USDC, + monthlySpendingLimitAmount, + monthlySpendingLimitMembers: [this.payer.publicKey], + performancePackageGrantee: grantee.publicKey, + performancePackageTokenAmount, + monthsUntilInsidersCanUnlock, + teamAddress: PublicKey.default, + launchAuthority: launchAuthority.publicKey, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + additionalTokensAmount, + hasBidWall: false, + }) + .rpc(); + + await launchpadClient + .startLaunchIx({ launch, launchAuthority: launchAuthority.publicKey }) + .signers([launchAuthority]) + .rpc(); + + await launchpadClient + .fundIx({ + launch, + amount: new BN(500_000_000000), + funder: funder1.publicKey, + }) + .signers([funder1]) + .rpc(); + await launchpadClient + .fundIx({ + launch, + amount: new BN(200_000_000000), + funder: funder2.publicKey, + }) + .signers([funder2]) + .rpc(); + await launchpadClient + .fundIx({ + launch, + amount: new BN(400_000_000000), + funder: funder3.publicKey, + }) + .signers([funder3]) + .rpc(); + + await this.advanceBySeconds(launchPeriod + 1); + await launchpadClient.closeLaunchIx({ launch }).rpc(); + + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder1.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(250_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder2.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(100_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + await launchpadClient + .setFundingRecordApprovalIx({ + launch, + funder: funder3.publicKey, + launchAuthority: launchAuthority.publicKey, + approvedAmount: new BN(150_000_000000), + }) + .signers([launchAuthority]) + .rpc(); + + const settleTx = await launchpadClient + .settleLaunchIx({ + launch, + baseMint: META, + launchAuthority: launchAuthority.publicKey, + }) + .signers([launchAuthority]) + .transaction(); + + const lut = await createLookupTableForTransaction(settleTx, this); + + const settleMessage = new TransactionMessage({ + payerKey: this.payer.publicKey, + recentBlockhash: (await this.banksClient.getLatestBlockhash())[0], + instructions: settleTx.instructions, + }).compileToV0Message([lut]); + + const settleVersionedTx = new VersionedTransaction(settleMessage); + settleVersionedTx.sign([this.payer, launchAuthority]); + + await this.banksClient.processTransaction(settleVersionedTx); + + let launchAccount = await launchpadClient.fetchLaunch(launch); + const dao = launchAccount.dao!; + + await launchpadClient + .finalizeLaunchIx({ + launch, + baseMint: META, + performancePackageGrantee: launchAccount.performancePackageGrantee, + }) + .rpc(); + + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder1.publicKey }) + .rpc(); + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder2.publicKey }) + .rpc(); + await launchpadClient + .claimIx({ launch, baseMint: META, funder: funder3.publicKey }) + .rpc(); + + await launchpadClient.refundIx({ launch, funder: funder1.publicKey }).rpc(); + await launchpadClient.refundIx({ launch, funder: funder2.publicKey }).rpc(); + await launchpadClient.refundIx({ launch, funder: funder3.publicKey }).rpc(); + + await launchpadClient + .claimAdditionalTokenAllocationIx({ + launch, + baseMint: META, + additionalTokensRecipient: additionalTokensRecipient.publicKey, + }) + .rpc(); + + // Capture the post-finalize addresses we'll need below. + const mintGovernorAddr = launchpadClient.getMintGovernorAddress({ + baseMint: META, + launchSigner, + }); + const performancePackageAddr = + launchpadClient.getLaunchPerformancePackageAddress({ launch }); + const ppMintAuthorityAddr = launchpadClient.getMintAuthorityAddress({ + mintGovernor: mintGovernorAddr, + authorizedMinter: performancePackageAddr, + }); + + // ============================================================ + // Phase B — Pre-unlock invariants + // ============================================================ + + // Mint authority is now the mint_governor PDA, not the launch_signer. + const mintAcc = await this.getMint(META); + assert.ok(mintAcc.mintAuthority.equals(mintGovernorAddr)); + + // start_unlock fails before min_unlock_timestamp. + const earlyStartCallbacks = expectError( + "UnlockTimestampNotReached", + "start_unlock should fail before min_unlock_timestamp", + ); + await launchpadClient.performancePackageV2 + .startUnlockIx({ + performancePackage: performancePackageAddr, + signer: grantee.publicKey, + dao, + }) + .signers([grantee]) + .rpc() + .then(earlyStartCallbacks[0], earlyStartCallbacks[1]); + + // ============================================================ + // Phase C — Whale buy + advance to min_unlock_timestamp + // ============================================================ + + // Past twap_start_delay (1 day) so update_twap actually moves the aggregator + // (programs/futarchy/src/state/futarchy_amm.rs:393-396). + await this.advanceBySeconds(24 * 60 * 60 + 60); + + const whale = Keypair.generate(); + await this.createTokenAccount(MAINNET_USDC, whale.publicKey); + await this.transfer( + MAINNET_USDC, + this.payer, + whale.publicKey, + 1_000_000_000_000, // $1M + ); + + // ~$1M buy → spot price ≈ 121× launch_price (CPMM math against + // the 100k USDC + 2M META reserves seeded by settle_launch). + await futarchyClient + .spotSwapIx({ + dao, + baseMint: META, + swapType: "buy", + inputAmount: new BN(1_000_000_000_000), + trader: whale.publicKey, + }) + .signers([whale]) + .rpc(); + + // Advance the rest of the way to min_unlock_timestamp (24 months). + await this.advanceBySeconds( + monthsUntilInsidersCanUnlock * 30 * 24 * 60 * 60, + ); + + // ============================================================ + // Phase D — Cranker + 5 unlock cycles at 2/4/8/16/32× + // ============================================================ + + const cranker = Keypair.generate(); + await this.createTokenAccount(MAINNET_USDC, cranker.publicKey); + await this.transfer( + MAINNET_USDC, + this.payer, + cranker.publicKey, + 100_000_000_000, // $100k — way more than the 620 × $10 ≈ $6 200 we'll spend. + ); + + // Walk last_observation up to targetMultiplier × launch_price by issuing + // tiny buy swaps spaced ≥61 s apart. Each update_twap moves the + // observation by at most launch_price/20 (programs/futarchy/src/state/ + // futarchy_amm.rs:339-449). Since the whale buy left last_price ≫ 32×, + // every crank advances by exactly the cap. + // + // Each iteration adds a unique ComputeBudget instruction so the swap + // signatures don't collide (bankrun rejects duplicates). + let crankNonce = 0; + const crankObservationTo = async (targetMultiplier: number) => { + const target = launchPrice.muln(targetMultiplier); + while (true) { + const daoAcc = await futarchyClient.getDao(dao); + const obs = daoAcc.amm.state.spot.spot.oracle.lastObservation as BN; + if (obs.gte(target)) return; + await this.advanceBySeconds(61); + await futarchyClient + .spotSwapIx({ + dao, + baseMint: META, + swapType: "buy", + inputAmount: new BN(10_000_000), // 10 USDC + trader: cranker.publicKey, + }) + .postInstructions([ + ComputeBudgetProgram.setComputeUnitLimit({ + units: 200_000 + crankNonce++, + }), + ]) + .signers([cranker]) + .rpc(); + } + }; + + const granteeAta = await this.createTokenAccount(META, grantee.publicKey); + + const ppAmount = performancePackageTokenAmount; + const fifth = ppAmount.divn(5); // 1M × 1e6 + + const runUnlockCycle = async ( + targetMultiplier: number, + expectedCumulative: BN, + ) => { + await crankObservationTo(targetMultiplier); + + await launchpadClient.performancePackageV2 + .startUnlockIx({ + performancePackage: performancePackageAddr, + signer: grantee.publicKey, + dao, + }) + .signers([grantee]) + .rpc(); + + // No swaps fire during this wait, so last_observation stays pinned at + // targetMultiplier × launch_price. The effective_aggregator extrapolation + // (programs/performance_package_v2/src/state/performance_package.rs:87-92) + // makes the TWAP between start_unlock and complete_unlock equal to + // targetMultiplier × launch_price. + await this.advanceBySeconds(PP_TWAP_MIN_DURATION_SEC + 60); + + await launchpadClient.performancePackageV2 + .completeUnlockIx({ + performancePackage: performancePackageAddr, + mintGovernor: mintGovernorAddr, + mintAuthority: ppMintAuthorityAddr, + mint: META, + recipient: grantee.publicKey, + signer: grantee.publicKey, + dao, + }) + .signers([grantee]) + .rpc(); + + const granteeBalance = await this.getTokenBalance( + META, + grantee.publicKey, + ); + assert.equal(granteeBalance.toString(), expectedCumulative.toString()); + + const pp = + await launchpadClient.performancePackageV2.fetchPerformancePackage( + performancePackageAddr, + ); + assert.equal( + pp.totalRewardsPaidOut.toString(), + expectedCumulative.toString(), + ); + assert.deepEqual(pp.status, { locked: {} }); + assert.equal(pp.oracleReader.futarchyTwap.startValue.toString(), "0"); + assert.equal(pp.oracleReader.futarchyTwap.endValue.toString(), "0"); + }; + + await runUnlockCycle(2, fifth.muln(1)); + await runUnlockCycle(4, fifth.muln(2)); + await runUnlockCycle(8, fifth.muln(3)); + await runUnlockCycle(16, fifth.muln(4)); + await runUnlockCycle(32, fifth.muln(5)); + + // ============================================================ + // Phase E — Cap assertion + // ============================================================ + + const ppAuthority = + await launchpadClient.mintGovernorClient.fetchMintAuthority( + ppMintAuthorityAddr, + ); + assert.equal(ppAuthority.totalMinted.toString(), ppAmount.toString()); + assert.equal(ppAuthority.maxTotal.toString(), ppAmount.toString()); + }); +} diff --git a/tests/main.test.ts b/tests/main.test.ts index e89a25541..7b69d89b4 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -81,6 +81,7 @@ import mintAndSwap from "./integration/mintAndSwap.test.js"; import fullLaunch from "./integration/fullLaunch.test.js"; import fullLaunch_v7 from "./integration/fullLaunch_v7.test.js"; import fullLaunch_v8 from "./integration/launchpad_v8_full_lifecycle.test.js"; +import trancheLifecycle_v8 from "./integration/launchpad_v8_tranche_lifecycle.test.js"; import { BN } from "bn.js"; const ONE_BUCK_PRICE = PriceMath.getAmmPrice(1, 6, 6); @@ -761,4 +762,5 @@ describe("project-wide integration tests", function () { describe("full launch v6", fullLaunch); describe("full launch v7", fullLaunch_v7); describe("full launch v8", fullLaunch_v8); + describe("full launch v8 - tranche lifecycle", trancheLifecycle_v8); }); From 89978de8fb1a468e3f4fce41d2b26f3fa07110a8 Mon Sep 17 00:00:00 2001 From: Pileks Date: Wed, 6 May 2026 01:53:27 +0200 Subject: [PATCH 100/100] add gh workflows --- .github/workflows/deploy-programs.yaml | 20 +++++++++++++++++++ .../workflows/generate-verifiable-builds.yaml | 19 +++++++++++++++++- README.md | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-programs.yaml b/.github/workflows/deploy-programs.yaml index 725df8802..4d99d78cc 100644 --- a/.github/workflows/deploy-programs.yaml +++ b/.github/workflows/deploy-programs.yaml @@ -13,6 +13,7 @@ on: - launchpad_v6 - price_based_performance_package_v6 - launchpad_v7 + - launchpad_v8 - bid_wall - liquidation - mint_governor @@ -189,6 +190,25 @@ jobs: use-squads: true features: "production" priority-fee: ${{ inputs.priority-fee }} + secrets: + MAINNET_SOLANA_DEPLOY_URL: ${{ secrets.MAINNET_SOLANA_DEPLOY_URL }} + MAINNET_DEPLOYER_KEYPAIR: ${{ secrets.MAINNET_DEPLOYER_KEYPAIR }} + MAINNET_MULTISIG: ${{ secrets.MAINNET_MULTISIG }} + MAINNET_MULTISIG_VAULT: ${{ secrets.MAINNET_MULTISIG_VAULT }} + + launchpad-v8: + if: inputs.program == 'launchpad_v8' + uses: ./.github/workflows/reusable-build.yaml + with: + program: "launchpad_v8" + override-program-id: "moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n" + network: "mainnet" + deploy: true + upload_idl: true + verify: true + use-squads: true + features: "production" + priority-fee: ${{ inputs.priority-fee }} secrets: MAINNET_SOLANA_DEPLOY_URL: ${{ secrets.MAINNET_SOLANA_DEPLOY_URL }} MAINNET_DEPLOYER_KEYPAIR: ${{ secrets.MAINNET_DEPLOYER_KEYPAIR }} diff --git a/.github/workflows/generate-verifiable-builds.yaml b/.github/workflows/generate-verifiable-builds.yaml index c4fe27e5f..d7bbb7172 100644 --- a/.github/workflows/generate-verifiable-builds.yaml +++ b/.github/workflows/generate-verifiable-builds.yaml @@ -162,4 +162,21 @@ jobs: uses: EndBug/add-and-commit@v9.1.4 with: default_author: github_actions - message: 'Update performance_package_v2 verifiable build' \ No newline at end of file + message: 'Update performance_package_v2 verifiable build' + generate-verifiable-launchpad-v8: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: metadaoproject/anchor-verifiable-build@v0.4 + with: + program: launchpad_v8 + anchor-version: '0.29.0' + solana-cli-version: '1.17.31' + features: 'production' + - run: 'git pull --rebase' + - run: cp target/deploy/launchpad_v8.so ./verifiable-builds + - name: Commit verifiable build back to mainline + uses: EndBug/add-and-commit@v9.1.4 + with: + default_author: github_actions + message: 'Update launchpad_v8 verifiable build' \ No newline at end of file diff --git a/README.md b/README.md index 5b89a6a2e..ed07e0b93 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Programs for unruggable capital formation and market-driven governance. | program | tag | program ID | | ----------------- | ---- | -------------------------------------------- | +| launchpad | v0.8.0 | moonDJUoHteKkGATejA5bdJVwJ6V6Dg74gyqyJTx73n | | launchpad | v0.7.0 | moontUzsdepotRGe5xsfip7vLPTJnVuafqdUWexVnPM | | bid_wall | v0.7.0 | WALL8ucBuUyL46QYxwYJjidaFYhdvxUFrgvBxPshERx | | mint_governor | v0.7.0 | gvnr27cVeyW3AVf3acL7VCJ5WjGAphytnsgcK1feHyH |