diff --git a/cli/src/bin/cli.rs b/cli/src/bin/cli.rs index 2314b63..8ad7981 100644 --- a/cli/src/bin/cli.rs +++ b/cli/src/bin/cli.rs @@ -243,9 +243,6 @@ pub struct NewDistributorArgs { #[clap(long, env)] pub locker: Pubkey, - - #[clap(long, env)] - pub min_stake_duration: u64, } // NewDistributor subcommand args @@ -290,9 +287,6 @@ pub struct NewDistributorWithBonusArgs { #[clap(long, env)] pub locker: Pubkey, - #[clap(long, env)] - pub min_stake_duration: u64, - #[clap(long, env)] pub bonus_vesting_duration: u64, @@ -314,7 +308,6 @@ impl NewDistributorWithBonusArgs { base_path: self.base_path.clone(), clawback_receiver_owner: self.clawback_receiver_owner, locker: self.locker, - min_stake_duration: self.min_stake_duration, } } } @@ -635,7 +628,6 @@ fn check_distributor_onchain_matches( total_bonus: u64, bonus_vesting_duration: u64, locker: Pubkey, - min_locked_duration: u64, pubkey: Pubkey, base: Pubkey, args: &Args, @@ -691,10 +683,6 @@ fn check_distributor_onchain_matches( return Err("locker mismatch"); } - if distributor.min_locked_duration != min_locked_duration { - return Err("min_locked_duration mismatch"); - } - // TODO fix code let clawback_receiver_token_account = spl_associated_token_account::get_associated_token_address( diff --git a/cli/src/bin/instructions/process_new_distributor.rs b/cli/src/bin/instructions/process_new_distributor.rs index 9e45215..648d771 100644 --- a/cli/src/bin/instructions/process_new_distributor.rs +++ b/cli/src/bin/instructions/process_new_distributor.rs @@ -120,7 +120,6 @@ fn create_new_distributor( total_bonus, bonus_vesting_duration, new_distributor_args.locker, - new_distributor_args.min_stake_duration, keypair.pubkey(), base.pubkey(), &args, @@ -193,7 +192,6 @@ fn create_new_distributor( enable_slot: new_distributor_args.enable_slot, closable: new_distributor_args.closable, locker: new_distributor_args.locker, - min_locked_duration: new_distributor_args.min_stake_duration, } .data(), }); @@ -225,7 +223,6 @@ fn create_new_distributor( total_bonus, bonus_vesting_slot_duration: bonus_vesting_duration, locker: new_distributor_args.locker, - min_locked_duration: new_distributor_args.min_stake_duration, } .data(), }); @@ -284,7 +281,6 @@ fn create_new_distributor( total_bonus, bonus_vesting_duration, new_distributor_args.locker, - new_distributor_args.min_stake_duration, keypair.pubkey(), base.pubkey(), args, diff --git a/programs/merkle-distributor/src/error.rs b/programs/merkle-distributor/src/error.rs index 7406ea9..87a4fe8 100644 --- a/programs/merkle-distributor/src/error.rs +++ b/programs/merkle-distributor/src/error.rs @@ -45,6 +45,6 @@ pub enum ErrorCode { CannotCloseDistributor, #[msg("Cannot close claim status")] CannotCloseClaimStatus, - #[msg("Remaning locked duration is too small")] - RemaningLockedDurationIsTooSmall, + #[msg("Escrow is not max lock")] + EscrowIsNotMaxLock, } diff --git a/programs/merkle-distributor/src/instructions/claim_locked.rs b/programs/merkle-distributor/src/instructions/claim_locked.rs index 7ff3b53..f7a6921 100644 --- a/programs/merkle-distributor/src/instructions/claim_locked.rs +++ b/programs/merkle-distributor/src/instructions/claim_locked.rs @@ -96,14 +96,7 @@ pub fn handle_claim_locked(ctx: Context) -> Result<()> { let curr_slot = Clock::get()?.slot; let escrow = &ctx.accounts.escrow; - let locker = &ctx.accounts.locker; - let remaing_locked_duration = escrow - .get_remaining_duration_until_expiration(curr_ts, locker) - .unwrap(); - require!( - remaing_locked_duration >= distributor.min_locked_duration, - ErrorCode::RemaningLockedDurationIsTooSmall - ); + require!(escrow.is_max_lock, ErrorCode::EscrowIsNotMaxLock); require!(!distributor.clawed_back, ErrorCode::ClaimExpired); diff --git a/programs/merkle-distributor/src/instructions/new_claim.rs b/programs/merkle-distributor/src/instructions/new_claim.rs index d75eb49..86e6b8e 100644 --- a/programs/merkle-distributor/src/instructions/new_claim.rs +++ b/programs/merkle-distributor/src/instructions/new_claim.rs @@ -117,14 +117,7 @@ pub fn handle_new_claim( let curr_slot = Clock::get()?.slot; let escrow = &ctx.accounts.escrow; - let locker = &ctx.accounts.locker; - let remaing_locked_duration = escrow - .get_remaining_duration_until_expiration(curr_ts, locker) - .unwrap(); - require!( - remaing_locked_duration >= distributor.min_locked_duration, - ErrorCode::RemaningLockedDurationIsTooSmall - ); + require!(escrow.is_max_lock, ErrorCode::EscrowIsNotMaxLock); require!(!distributor.clawed_back, ErrorCode::ClaimExpired); require!( diff --git a/programs/merkle-distributor/src/instructions/new_distributor.rs b/programs/merkle-distributor/src/instructions/new_distributor.rs index 3de46c3..e570dae 100644 --- a/programs/merkle-distributor/src/instructions/new_distributor.rs +++ b/programs/merkle-distributor/src/instructions/new_distributor.rs @@ -89,7 +89,6 @@ pub fn handle_new_distributor( total_bonus: u64, bonus_vesting_slot_duration: u64, locker: Pubkey, - min_locked_duration: u64, ) -> Result<()> { let curr_ts = Clock::get()?.unix_timestamp; @@ -143,11 +142,10 @@ pub fn handle_new_distributor( total_claimed_bonus: 0, }; distributor.locker = locker; - distributor.min_locked_duration = min_locked_duration; // Note: might get truncated, do not rely on msg! { - "New distributor created with version = {}, mint={}, vault={} max_total_claim={}, max_nodes: {}, start_ts: {}, end_ts: {}, clawback_start: {}, clawback_receiver: {} enable_slot {} total_bonus {}, bonus_vesting_slot_duration {}, locker {} min_locked_duration {}", + "New distributor created with version = {}, mint={}, vault={} max_total_claim={}, max_nodes: {}, start_ts: {}, end_ts: {}, clawback_start: {}, clawback_receiver: {} enable_slot {} total_bonus {}, bonus_vesting_slot_duration {}, locker {}", distributor.version, distributor.mint, ctx.accounts.token_vault.key(), @@ -161,7 +159,6 @@ pub fn handle_new_distributor( distributor.airdrop_bonus.total_bonus, distributor.airdrop_bonus.vesting_slot_duration, distributor.locker, - distributor.min_locked_duration, }; Ok(()) diff --git a/programs/merkle-distributor/src/lib.rs b/programs/merkle-distributor/src/lib.rs index 3799e14..4fa931c 100644 --- a/programs/merkle-distributor/src/lib.rs +++ b/programs/merkle-distributor/src/lib.rs @@ -68,7 +68,6 @@ pub mod merkle_distributor { enable_slot: u64, closable: bool, locker: Pubkey, - min_locked_duration: u64, ) -> Result<()> { handle_new_distributor( ctx, @@ -84,7 +83,6 @@ pub mod merkle_distributor { 0, 0, locker, - min_locked_duration, ) } @@ -103,7 +101,6 @@ pub mod merkle_distributor { total_bonus: u64, bonus_vesting_slot_duration: u64, locker: Pubkey, - min_locked_duration: u64, ) -> Result<()> { let max_total_claim = total_claim .checked_add(total_bonus) @@ -122,7 +119,6 @@ pub mod merkle_distributor { total_bonus, bonus_vesting_slot_duration, locker, - min_locked_duration, ) } /// only available in test phase diff --git a/programs/merkle-distributor/src/state/merkle_distributor.rs b/programs/merkle-distributor/src/state/merkle_distributor.rs index e6bf4bb..15e8378 100644 --- a/programs/merkle-distributor/src/state/merkle_distributor.rs +++ b/programs/merkle-distributor/src/state/merkle_distributor.rs @@ -46,7 +46,7 @@ pub struct MerkleDistributor { /// bonus multiplier pub airdrop_bonus: AirdropBonus, /// min_locked_duration - pub min_locked_duration: u64, + pub buffer_1: u64, /// locker pub locker: Pubkey, /// Buffer 2