diff --git a/programs/mpl-core/src/processor/create.rs b/programs/mpl-core/src/processor/create.rs index 52130b9b..b86ccb08 100644 --- a/programs/mpl-core/src/processor/create.rs +++ b/programs/mpl-core/src/processor/create.rs @@ -15,7 +15,7 @@ use crate::{ PluginType, PluginValidationContext, ValidationResult, }, state::{ - AssetV1, Authority, CollectionV1, DataState, SolanaAccount, UpdateAuthority, COLLECT_AMOUNT, + get_create_fee, AssetV1, Authority, CollectionV1, DataState, SolanaAccount, UpdateAuthority, }, utils::{resolve_authority, validate_asset_permissions}, }; @@ -122,7 +122,7 @@ pub(crate) fn process_create<'a>( } }; - let lamports = rent.minimum_balance(serialized_data.len()) + COLLECT_AMOUNT; + let lamports = rent.minimum_balance(serialized_data.len()) + get_create_fee()?; // CPI to the System Program. invoke( diff --git a/programs/mpl-core/src/state/collect.rs b/programs/mpl-core/src/state/collect.rs index 39d0aa07..0742c9fb 100644 --- a/programs/mpl-core/src/state/collect.rs +++ b/programs/mpl-core/src/state/collect.rs @@ -1,4 +1,6 @@ -use solana_program::pubkey::Pubkey; +use solana_program::{program_error::ProgramError, pubkey::Pubkey, rent::Rent, sysvar::Sysvar}; + +use crate::error::MplCoreError; pub(crate) const COLLECT_RECIPIENT1: Pubkey = solana_program::pubkey!("8AT6o8Qk5T9QnZvPThMrF9bcCQLTGkyGvVZZzHgCw11v"); @@ -6,4 +8,12 @@ pub(crate) const COLLECT_RECIPIENT1: Pubkey = pub(crate) const COLLECT_RECIPIENT2: Pubkey = solana_program::pubkey!("MmHsqX4LxTfifxoH8BVRLUKrwDn1LPCac6YcCZTHhwt"); -pub(crate) const COLLECT_AMOUNT: u64 = 1_500_000; +const CREATE_FEE_SCALAR: usize = 87; +const CREATE_FEE_OFFSET: u64 = 3600; +pub fn get_create_fee() -> Result { + let rent = Rent::get()?.minimum_balance(CREATE_FEE_SCALAR); + + Ok(rent + .checked_add(CREATE_FEE_OFFSET) + .ok_or(MplCoreError::NumericalOverflowError)?) +}