Skip to content

Commit

Permalink
switch to max lock
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsource147 committed Jul 2, 2024
1 parent 3a1473f commit 791fe6a
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 43 deletions.
12 changes: 0 additions & 12 deletions cli/src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ pub struct NewDistributorArgs {

#[clap(long, env)]
pub locker: Pubkey,

#[clap(long, env)]
pub min_stake_duration: u64,
}

// NewDistributor subcommand args
Expand Down Expand Up @@ -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,

Expand All @@ -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,
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions cli/src/bin/instructions/process_new_distributor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
});
Expand Down Expand Up @@ -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(),
});
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions programs/merkle-distributor/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
9 changes: 1 addition & 8 deletions programs/merkle-distributor/src/instructions/claim_locked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ pub fn handle_claim_locked(ctx: Context<ClaimLocked>) -> 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);

Expand Down
9 changes: 1 addition & 8 deletions programs/merkle-distributor/src/instructions/new_claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand All @@ -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(())
Expand Down
4 changes: 0 additions & 4 deletions programs/merkle-distributor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub mod merkle_distributor {
enable_slot: u64,
closable: bool,
locker: Pubkey,
min_locked_duration: u64,
) -> Result<()> {
handle_new_distributor(
ctx,
Expand All @@ -84,7 +83,6 @@ pub mod merkle_distributor {
0,
0,
locker,
min_locked_duration,
)
}

Expand All @@ -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)
Expand All @@ -122,7 +119,6 @@ pub mod merkle_distributor {
total_bonus,
bonus_vesting_slot_duration,
locker,
min_locked_duration,
)
}
/// only available in test phase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 791fe6a

Please sign in to comment.