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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "amm-program"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
readme = "./README.md"
license-file = "../LICENSE"
Expand Down
7 changes: 6 additions & 1 deletion program/idl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.1",
"name": "amm_program",
"docs": [
"Program entrypoint"
Expand All @@ -19,6 +19,11 @@
"name": "MAX_DELTA_BPS",
"type": "u16",
"value": "9999"
},
{
"name": "MAX_EXPIRY_SEC",
"type": "i64",
"value": "365 * 24 * 60 * 60"
}
],
"instructions": [
Expand Down
5 changes: 0 additions & 5 deletions program/src/instructions/create_pool.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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<CreatePool>, 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))?;
Expand Down
30 changes: 1 addition & 29 deletions program/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -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<Whitelist>,
nft_mint: &InterfaceAccount<Mint>,
mint_proof: &UncheckedAccount,
) -> Result<Box<MintProof>> {
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<MintProof> = Box::new(AccountDeserialize::try_deserialize(&mut data)?);
Ok(mint_proof)
}

#[inline(never)]
pub fn assert_decode_mint_proof_v2(
whitelist: &Account<WhitelistV2>,
Expand Down
1 change: 1 addition & 0 deletions program/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions program/src/state/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-idls.mjs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Loading