diff --git a/Cargo.lock b/Cargo.lock index c7bde61..971763c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,7 +73,7 @@ dependencies = [ [[package]] name = "amm-program" -version = "1.0.0" +version = "1.0.1" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/program/Cargo.toml b/program/Cargo.toml index dc4320f..c0a2fe2 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "amm-program" -version = "1.0.0" +version = "1.0.1" edition = "2021" readme = "./README.md" license-file = "../LICENSE" diff --git a/program/idl.json b/program/idl.json index 0ad6c84..d4fa34e 100644 --- a/program/idl.json +++ b/program/idl.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.0.1", "name": "amm_program", "docs": [ "Program entrypoint" @@ -19,6 +19,11 @@ "name": "MAX_DELTA_BPS", "type": "u16", "value": "9999" + }, + { + "name": "MAX_EXPIRY_SEC", + "type": "i64", + "value": "365 * 24 * 60 * 60" } ], "instructions": [ diff --git a/program/src/instructions/create_pool.rs b/program/src/instructions/create_pool.rs index 0fcbdac..3bb5d25 100644 --- a/program/src/instructions/create_pool.rs +++ b/program/src/instructions/create_pool.rs @@ -1,7 +1,6 @@ //! Create a new pool. use anchor_lang::prelude::*; use escrow_program::state::MarginAccount; -use tensor_vipers::throw_err; use whitelist_program::{self, WhitelistV2}; use crate::{ @@ -79,10 +78,6 @@ impl<'info> CreatePool<'info> { /// Create a new pool. #[access_control(ctx.accounts.validate(args.config))] pub fn process_create_pool(ctx: Context, args: CreatePoolArgs) -> Result<()> { - if args.config.starting_price < 1 { - throw_err!(ErrorCode::StartingPriceTooSmall); - } - let timestamp = Clock::get()?.unix_timestamp; let expiry = assert_expiry(args.expire_in_sec.unwrap_or(MAX_EXPIRY_SEC as u64))?; diff --git a/program/src/instructions/mod.rs b/program/src/instructions/mod.rs index 7fe08a6..246df7e 100644 --- a/program/src/instructions/mod.rs +++ b/program/src/instructions/mod.rs @@ -12,7 +12,6 @@ pub mod t22; pub mod withdraw_sol; pub use admin::*; -use anchor_spl::token::Mint; pub use close_expired_pool::*; pub use close_pool::*; pub use create_pool::*; @@ -28,37 +27,10 @@ use crate::{error::ErrorCode, *}; use anchor_lang::prelude::*; use solana_program::pubkey; use tensor_vipers::throw_err; -use whitelist_program::{self, MintProof, MintProofV2, Whitelist, WhitelistV2}; +use whitelist_program::{self, MintProofV2, WhitelistV2}; pub static MPL_TOKEN_AUTH_RULES_ID: Pubkey = pubkey!("auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg"); -#[inline(never)] -pub fn assert_decode_mint_proof( - whitelist: &Account, - nft_mint: &InterfaceAccount, - mint_proof: &UncheckedAccount, -) -> Result> { - let (key, _) = Pubkey::find_program_address( - &[ - b"mint_proof".as_ref(), - nft_mint.key().as_ref(), - whitelist.key().as_ref(), - ], - &whitelist_program::ID, - ); - if key != *mint_proof.key { - throw_err!(ErrorCode::BadMintProof); - } - // Check program owner (redundant because of find_program_address above, but why not). - if *mint_proof.owner != whitelist_program::ID { - throw_err!(ErrorCode::BadMintProof); - } - - let mut data: &[u8] = &mint_proof.try_borrow_data()?; - let mint_proof: Box = Box::new(AccountDeserialize::try_deserialize(&mut data)?); - Ok(mint_proof) -} - #[inline(never)] pub fn assert_decode_mint_proof_v2( whitelist: &Account, diff --git a/program/src/state/mod.rs b/program/src/state/mod.rs index 56b6b0e..127e676 100644 --- a/program/src/state/mod.rs +++ b/program/src/state/mod.rs @@ -14,6 +14,7 @@ use mpl_token_metadata::types::{AuthorizationData, Payload, PayloadType, ProofIn use std::collections::HashMap; /// Maximum expiration time for a pool--one year. +#[constant] pub const MAX_EXPIRY_SEC: i64 = 365 * 24 * 60 * 60; // --------------------------------------- replicating mplex type for anchor IDL export diff --git a/program/src/state/pool.rs b/program/src/state/pool.rs index 20173ef..a6c332a 100644 --- a/program/src/state/pool.rs +++ b/program/src/state/pool.rs @@ -57,6 +57,10 @@ pub struct PoolConfig { impl PoolConfig { pub fn validate(&self) -> Result<()> { + if self.starting_price < 1 { + throw_err!(ErrorCode::StartingPriceTooSmall); + } + match self.pool_type { PoolType::NFT | PoolType::Token => { if self.mm_fee_bps > 0 { diff --git a/scripts/generate-idls.mjs b/scripts/generate-idls.mjs index 2d6e7fe..12d7685 100644 --- a/scripts/generate-idls.mjs +++ b/scripts/generate-idls.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env zx -import "zx/globals"; import { generateIdl } from "@metaplex-foundation/shank-js"; +import "zx/globals"; import { getCargo, getProgramFolders } from "./utils.mjs"; const binaryInstallDir = path.join(__dirname, "..", ".cargo");