Skip to content

Commit

Permalink
Merge pull request #191 from metaplex-foundation/feat/svm-fees
Browse files Browse the repository at this point in the history
Scaling fees based on SVM native rent.
  • Loading branch information
blockiosaurus authored Sep 8, 2024
2 parents f565600 + e21a961 commit 5002851
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions programs/mpl-core/src/processor/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 12 additions & 2 deletions programs/mpl-core/src/state/collect.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
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");

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<u64, ProgramError> {
let rent = Rent::get()?.minimum_balance(CREATE_FEE_SCALAR);

Ok(rent
.checked_add(CREATE_FEE_OFFSET)
.ok_or(MplCoreError::NumericalOverflowError)?)
}

0 comments on commit 5002851

Please sign in to comment.