diff --git a/Cargo.lock b/Cargo.lock index c3d35a52d..e7a11fd32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -958,7 +958,7 @@ dependencies = [ [[package]] name = "andromeda-vesting" -version = "3.0.4-b.1" +version = "3.0.4-b.2" dependencies = [ "andromeda-app", "andromeda-finance", diff --git a/contracts/finance/andromeda-vesting/Cargo.toml b/contracts/finance/andromeda-vesting/Cargo.toml index 439fcd695..1e1326ca3 100644 --- a/contracts/finance/andromeda-vesting/Cargo.toml +++ b/contracts/finance/andromeda-vesting/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "andromeda-vesting" -version = "3.0.4-b.1" +version = "3.0.4-b.2" edition = "2021" rust-version = "1.75.0" diff --git a/contracts/finance/andromeda-vesting/src/contract.rs b/contracts/finance/andromeda-vesting/src/contract.rs index 16f8a5a1a..9b4a8b316 100644 --- a/contracts/finance/andromeda-vesting/src/contract.rs +++ b/contracts/finance/andromeda-vesting/src/contract.rs @@ -89,9 +89,9 @@ pub fn handle_execute(mut ctx: ExecuteContext, msg: ExecuteMsg) -> Result execute_create_batch(ctx, lockup_duration, release_unit, release_amount), + } => execute_create_batch(ctx, lockup_duration, release_duration, release_amount), ExecuteMsg::Claim { number_of_claims, batch_id, @@ -105,7 +105,7 @@ pub fn handle_execute(mut ctx: ExecuteContext, msg: ExecuteMsg) -> Result, - release_unit: Milliseconds, + release_duration: Milliseconds, release_amount: WithdrawalType, ) -> Result { let ExecuteContext { @@ -136,7 +136,7 @@ fn execute_create_batch( ); ensure!( - !release_unit.is_zero() && !release_amount.is_zero(), + !release_duration.is_zero() && !release_amount.is_zero(), ContractError::InvalidZeroAmount {} ); ensure!( @@ -180,7 +180,7 @@ fn execute_create_batch( amount: funds.amount, amount_claimed: Uint128::zero(), lockup_end, - release_unit, + release_duration, release_amount, last_claimed_release_time: lockup_end, }; @@ -191,7 +191,7 @@ fn execute_create_batch( .add_attribute("action", "create_batch") .add_attribute("amount", funds.amount) .add_attribute("lockup_end", lockup_end.to_string()) - .add_attribute("release_unit", release_unit.to_string()) + .add_attribute("release_duration", release_duration.to_string()) .add_attribute("release_amount", release_amount_string)) } @@ -274,7 +274,8 @@ fn execute_claim_all( let key = batches().key(batch_id); let elapsed_time = up_to_time.minus_milliseconds(batch.last_claimed_release_time); - let num_available_claims = elapsed_time.milliseconds() / batch.release_unit.milliseconds(); + let num_available_claims = + elapsed_time.milliseconds() / batch.release_duration.milliseconds(); let amount_to_send = claim_batch( &deps.querier, @@ -321,7 +322,7 @@ fn claim_batch( .query_balance(querier, env.contract.address.to_owned())?; let elapsed_time = current_time.minus_milliseconds(batch.last_claimed_release_time); - let num_available_claims = elapsed_time.milliseconds() / batch.release_unit.milliseconds(); + let num_available_claims = elapsed_time.milliseconds() / batch.release_duration.milliseconds(); let number_of_claims = cmp::min( number_of_claims.unwrap_or(num_available_claims), @@ -342,19 +343,20 @@ fn claim_batch( batch.amount_claimed = batch.amount_claimed.checked_add(amount_to_send)?; // Safe math version - let claims_release_unit = number_of_claims.checked_mul(batch.release_unit.milliseconds()); - if claims_release_unit.is_none() { + let claims_release_duration = + number_of_claims.checked_mul(batch.release_duration.milliseconds()); + if claims_release_duration.is_none() { return Err(ContractError::Overflow {}); } - let claims_release_unit = Milliseconds(claims_release_unit.unwrap()); + let claims_release_duration = Milliseconds(claims_release_duration.unwrap()); batch.last_claimed_release_time = batch .last_claimed_release_time - .plus_milliseconds(claims_release_unit); + .plus_milliseconds(claims_release_duration); // The unsafe version - // batch.last_claimed_release_time += number_of_claims * batch.release_unit; + // batch.last_claimed_release_time += number_of_claims * batch.release_duration; } Ok(amount_to_send) @@ -433,7 +435,7 @@ fn get_batch_response( number_of_available_claims, lockup_end: batch.lockup_end, release_amount: batch.release_amount, - release_unit: batch.release_unit, + release_duration: batch.release_duration, last_claimed_release_time: previous_last_claimed_release_time, }; diff --git a/contracts/finance/andromeda-vesting/src/state.rs b/contracts/finance/andromeda-vesting/src/state.rs index 7b96f0b45..c82a08ba4 100644 --- a/contracts/finance/andromeda-vesting/src/state.rs +++ b/contracts/finance/andromeda-vesting/src/state.rs @@ -22,8 +22,8 @@ pub struct Batch { /// When the lockup ends. pub lockup_end: Milliseconds, /// How often releases occur. - pub release_unit: Milliseconds, - /// Specifies how much is to be released after each `release_unit`. If + pub release_duration: Milliseconds, + /// Specifies how much is to be released after each `release_duration`. If /// it is a percentage, it would be the percentage of the original amount. pub release_amount: WithdrawalType, /// The time at which the last claim took place in seconds. @@ -140,7 +140,7 @@ mod tests { amount: Uint128::new(100), amount_claimed: Uint128::zero(), lockup_end: current_time.plus_seconds(10), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: current_time.minus_seconds(1), }; @@ -149,7 +149,7 @@ mod tests { amount: Uint128::new(100), amount_claimed: Uint128::zero(), lockup_end: current_time.minus_seconds(1), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: current_time.minus_seconds(1), }; @@ -158,7 +158,7 @@ mod tests { amount: Uint128::new(100), amount_claimed: Uint128::new(100), lockup_end: current_time.minus_seconds(1), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: current_time.minus_seconds(1), }; diff --git a/contracts/finance/andromeda-vesting/src/testing/tests.rs b/contracts/finance/andromeda-vesting/src/testing/tests.rs index c54c1715d..8bc2aed2f 100644 --- a/contracts/finance/andromeda-vesting/src/testing/tests.rs +++ b/contracts/finance/andromeda-vesting/src/testing/tests.rs @@ -33,13 +33,13 @@ fn init(deps: DepsMut) -> Response { fn create_batch( deps: DepsMut, lockup_duration: Option, - release_unit: Milliseconds, + release_duration: Milliseconds, release_amount: WithdrawalType, ) -> Response { - // Create batch with half of the release_unit. + // Create batch with half of the release_duration. let msg = ExecuteMsg::CreateBatch { lockup_duration, - release_unit, + release_duration, release_amount, }; @@ -116,7 +116,7 @@ fn test_create_batch_unauthorized() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -135,7 +135,7 @@ fn test_create_batch_no_funds() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -158,7 +158,7 @@ fn test_create_batch_invalid_denom() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -181,7 +181,7 @@ fn test_create_batch_valid_denom_zero_amount() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -191,7 +191,7 @@ fn test_create_batch_valid_denom_zero_amount() { } #[test] -fn test_create_batch_release_unit_zero() { +fn test_create_batch_release_duration_zero() { let mut deps = mock_dependencies_custom(&[coin(100000, MOCK_NATIVE_DENOM)]); init(deps.as_mut()); @@ -199,7 +199,7 @@ fn test_create_batch_release_unit_zero() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::zero(), + release_duration: Milliseconds::zero(), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -217,7 +217,7 @@ fn test_create_batch_release_amount_zero() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::zero()), }; @@ -235,7 +235,7 @@ fn test_create_batch() { let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -247,7 +247,10 @@ fn test_create_batch() { .add_attribute("action", "create_batch") .add_attribute("amount", "100") .add_attribute("lockup_end", current_time.to_string()) - .add_attribute("release_unit", Milliseconds::from_seconds(10).to_string()) + .add_attribute( + "release_duration", + Milliseconds::from_seconds(10).to_string() + ) .add_attribute("release_amount", "Amount(Uint128(10))"), res ); @@ -259,7 +262,7 @@ fn test_create_batch() { amount: Uint128::new(100), amount_claimed: Uint128::zero(), lockup_end: current_time, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: current_time, }, @@ -271,7 +274,7 @@ fn test_create_batch() { // Try to create another batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: Some(Milliseconds::from_seconds(100)), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -282,7 +285,10 @@ fn test_create_batch() { .add_attribute("action", "create_batch") .add_attribute("amount", "100") .add_attribute("lockup_end", (current_time.plus_seconds(100)).to_string()) - .add_attribute("release_unit", Milliseconds::from_seconds(10).to_string()) + .add_attribute( + "release_duration", + Milliseconds::from_seconds(10).to_string() + ) .add_attribute("release_amount", "Amount(Uint128(10))"), res ); @@ -294,7 +300,7 @@ fn test_create_batch() { amount: Uint128::new(100), amount_claimed: Uint128::zero(), lockup_end: current_time.plus_seconds(100), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: current_time.plus_seconds(100), }, @@ -330,7 +336,7 @@ fn test_claim_batch_still_locked() { // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: Some(Milliseconds::from_seconds(100)), - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -356,7 +362,7 @@ fn test_claim_batch_no_funds_available() { // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -380,12 +386,12 @@ fn test_claim_batch_single_claim() { init(deps.as_mut()); let info = mock_info("owner", &coins(100, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -398,7 +404,7 @@ fn test_claim_batch_single_claim() { // Skip time. let mut env = mock_env(); // A single release is available. - env.block.time = env.block.time.plus_seconds(release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(release_duration.seconds()); // Query created batch. let msg = QueryMsg::Batch { id: 1 }; @@ -413,7 +419,7 @@ fn test_claim_batch_single_claim() { amount_available_to_claim: Uint128::new(10), number_of_available_claims: Uint128::new(1), lockup_end, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: lockup_end, }, @@ -447,9 +453,9 @@ fn test_claim_batch_single_claim() { amount: Uint128::new(100), amount_claimed: Uint128::new(10), lockup_end, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_milliseconds(release_unit), + last_claimed_release_time: lockup_end.plus_milliseconds(release_duration), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -461,12 +467,12 @@ fn test_claim_batch_not_nice_numbers_single_release() { init(deps.as_mut()); let info = mock_info("owner", &coins(10, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -479,7 +485,7 @@ fn test_claim_batch_not_nice_numbers_single_release() { // Skip time. let mut env = mock_env(); // A single release is available. - env.block.time = env.block.time.plus_seconds(release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(release_duration.seconds()); // Claim batch. let msg = ExecuteMsg::Claim { @@ -508,9 +514,9 @@ fn test_claim_batch_not_nice_numbers_single_release() { amount: Uint128::new(10), amount_claimed: Uint128::new(7), lockup_end, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_milliseconds(release_unit), + last_claimed_release_time: lockup_end.plus_milliseconds(release_duration), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -523,14 +529,14 @@ fn test_claim_batch_not_nice_numbers_multiple_releases() { let vesting_amount = 1_000_000_000_000_000_000u128; let info = mock_info("owner", &coins(vesting_amount, "uusd")); - let release_unit = Milliseconds::from_seconds(1); // 1 second + let release_duration = Milliseconds::from_seconds(1); // 1 second let duration: u64 = 60 * 60 * 24 * 365 * 5; // 5 years let percent_release = Decimal::from_ratio(Uint128::one(), Uint128::from(duration)); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Percentage(percent_release), }; @@ -543,7 +549,7 @@ fn test_claim_batch_not_nice_numbers_multiple_releases() { // Skip time. let mut env = mock_env(); // Two releases are out. - env.block.time = env.block.time.plus_seconds(2 * release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(2 * release_duration.seconds()); // Claim batch. let msg = ExecuteMsg::Claim { @@ -572,9 +578,9 @@ fn test_claim_batch_not_nice_numbers_multiple_releases() { amount: Uint128::new(vesting_amount), amount_claimed: Uint128::new(12683916792), lockup_end, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Percentage(percent_release), - last_claimed_release_time: lockup_end.plus_seconds(2 * release_unit.seconds()), + last_claimed_release_time: lockup_end.plus_seconds(2 * release_duration.seconds()), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -600,7 +606,7 @@ fn test_claim_batch_not_nice_numbers_multiple_releases() { amount: Uint128::new(vesting_amount), amount_claimed: Uint128::from(vesting_amount), lockup_end, - release_unit: Milliseconds::from_seconds(1), + release_duration: Milliseconds::from_seconds(1), release_amount: WithdrawalType::Percentage(percent_release), last_claimed_release_time: lockup_end.plus_seconds(duration + 2), }, @@ -614,12 +620,12 @@ fn test_claim_batch_middle_of_interval() { init(deps.as_mut()); let info = mock_info("owner", &coins(100, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -637,14 +643,14 @@ fn test_claim_batch_middle_of_interval() { let mut env = mock_env(); // Only halfway to first release. - env.block.time = env.block.time.plus_seconds(release_unit.seconds() / 2); + env.block.time = env.block.time.plus_seconds(release_duration.seconds() / 2); let res = execute(deps.as_mut(), env.clone(), info.clone(), msg.clone()); assert_eq!(ContractError::WithdrawalIsEmpty {}, res.unwrap_err()); // First release available and halfway to second -> result is rounding down. - env.block.time = env.block.time.plus_seconds(release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(release_duration.seconds()); let res = execute(deps.as_mut(), env, info, msg).unwrap(); assert_eq!( @@ -666,9 +672,9 @@ fn test_claim_batch_middle_of_interval() { amount: Uint128::new(100), amount_claimed: Uint128::new(10), lockup_end, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_milliseconds(release_unit), + last_claimed_release_time: lockup_end.plus_milliseconds(release_duration), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -680,12 +686,12 @@ fn test_claim_batch_multiple_claims() { init(deps.as_mut()); let info = mock_info("owner", &coins(100, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -698,7 +704,7 @@ fn test_claim_batch_multiple_claims() { let mut env = mock_env(); // 4 releases are available. - env.block.time = env.block.time.plus_seconds(4 * release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(4 * release_duration.seconds()); // Claim only the first release. let msg = ExecuteMsg::Claim { @@ -726,9 +732,9 @@ fn test_claim_batch_multiple_claims() { amount: Uint128::new(100), amount_claimed: Uint128::new(10), lockup_end, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_milliseconds(release_unit), + last_claimed_release_time: lockup_end.plus_milliseconds(release_duration), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -759,9 +765,9 @@ fn test_claim_batch_multiple_claims() { amount: Uint128::new(100), amount_claimed: Uint128::new(40), lockup_end, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_seconds(4 * release_unit.seconds()), + last_claimed_release_time: lockup_end.plus_seconds(4 * release_duration.seconds()), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -773,12 +779,12 @@ fn test_claim_batch_all_releases() { init(deps.as_mut()); let info = mock_info("owner", &coins(100, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -790,9 +796,9 @@ fn test_claim_batch_all_releases() { let mut env = mock_env(); - // All releases are available and then some (10 * release_unit would be when all releases + // All releases are available and then some (10 * release_duration would be when all releases // become available). - env.block.time = env.block.time.plus_seconds(15 * release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(15 * release_duration.seconds()); // Claim only the first release. let msg = ExecuteMsg::Claim { @@ -820,9 +826,9 @@ fn test_claim_batch_all_releases() { amount: Uint128::new(100), amount_claimed: Uint128::new(100), lockup_end, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_seconds(15 * release_unit.seconds()), + last_claimed_release_time: lockup_end.plus_seconds(15 * release_duration.seconds()), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -839,12 +845,12 @@ fn test_claim_batch_too_high_of_claim() { init(deps.as_mut()); let info = mock_info("owner", &coins(100, "uusd")); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); // Create batch. let msg = ExecuteMsg::CreateBatch { lockup_duration: None, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), }; @@ -856,7 +862,7 @@ fn test_claim_batch_too_high_of_claim() { let mut env = mock_env(); // A single release is available. - env.block.time = env.block.time.plus_seconds(release_unit.seconds()); + env.block.time = env.block.time.plus_seconds(release_duration.seconds()); // Try to claim 3 releases. let msg = ExecuteMsg::Claim { @@ -886,9 +892,9 @@ fn test_claim_batch_too_high_of_claim() { amount: Uint128::new(100), amount_claimed: Uint128::new(10), lockup_end, - release_unit: Milliseconds::from_seconds(10), + release_duration: Milliseconds::from_seconds(10), release_amount: WithdrawalType::Amount(Uint128::new(10)), - last_claimed_release_time: lockup_end.plus_milliseconds(release_unit), + last_claimed_release_time: lockup_end.plus_milliseconds(release_duration), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -916,21 +922,26 @@ fn test_claim_all() { let mut deps = mock_dependencies_custom(&[coin(100000, MOCK_NATIVE_DENOM)]); init(deps.as_mut()); - let release_unit = Milliseconds::from_seconds(10); + let release_duration = Milliseconds::from_seconds(10); let release_amount = WithdrawalType::Amount(Uint128::new(10)); // Create batch. - create_batch(deps.as_mut(), None, release_unit, release_amount.clone()); + create_batch( + deps.as_mut(), + None, + release_duration, + release_amount.clone(), + ); - // Create batch with half of the release_unit. + // Create batch with half of the release_duration. create_batch( deps.as_mut(), None, - Milliseconds::from_seconds(release_unit.seconds() / 2), + Milliseconds::from_seconds(release_duration.seconds() / 2), release_amount.clone(), ); - // Create batch with a different release_unit scale (not a factor). + // Create batch with a different release_duration scale (not a factor). create_batch( deps.as_mut(), None, @@ -942,7 +953,7 @@ fn test_claim_all() { create_batch( deps.as_mut(), Some(Milliseconds::from_seconds(100)), - release_unit, + release_duration, release_amount.clone(), ); @@ -952,7 +963,7 @@ fn test_claim_all() { // Speed up time. let mut env = mock_env(); - env.block.time = env.block.time.plus_seconds(release_unit.seconds() * 2); + env.block.time = env.block.time.plus_seconds(release_duration.seconds() * 2); // Query batches let msg = QueryMsg::Batches { @@ -972,7 +983,7 @@ fn test_claim_all() { amount_available_to_claim: Uint128::new(20), number_of_available_claims: Uint128::new(2), lockup_end, - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: lockup_end, }, @@ -983,7 +994,7 @@ fn test_claim_all() { amount_available_to_claim: Uint128::new(40), number_of_available_claims: Uint128::new(4), lockup_end, - release_unit: Milliseconds::from_seconds(release_unit.seconds() / 2), + release_duration: Milliseconds::from_seconds(release_duration.seconds() / 2), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: lockup_end, }, @@ -994,7 +1005,7 @@ fn test_claim_all() { amount_available_to_claim: Uint128::new(10), number_of_available_claims: Uint128::new(1), lockup_end, - release_unit: Milliseconds::from_seconds(12), + release_duration: Milliseconds::from_seconds(12), release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: lockup_end, }, @@ -1005,7 +1016,7 @@ fn test_claim_all() { amount_available_to_claim: Uint128::zero(), number_of_available_claims: Uint128::zero(), lockup_end: lockup_end.plus_seconds(100), - release_unit, + release_duration, release_amount: WithdrawalType::Amount(Uint128::new(10)), last_claimed_release_time: lockup_end.plus_seconds(100), }, @@ -1040,9 +1051,9 @@ fn test_claim_all() { amount: Uint128::new(100), amount_claimed: Uint128::new(20), lockup_end, - release_unit, + release_duration, release_amount: release_amount.clone(), - last_claimed_release_time: lockup_end.plus_seconds(release_unit.seconds() * 2), + last_claimed_release_time: lockup_end.plus_seconds(release_duration.seconds() * 2), }, batches().load(deps.as_ref().storage, 1u64).unwrap() ); @@ -1052,9 +1063,9 @@ fn test_claim_all() { amount: Uint128::new(100), amount_claimed: Uint128::new(40), lockup_end, - release_unit: Milliseconds::from_seconds(release_unit.seconds() / 2), + release_duration: Milliseconds::from_seconds(release_duration.seconds() / 2), release_amount: release_amount.clone(), - last_claimed_release_time: lockup_end.plus_seconds(release_unit.seconds() * 2), + last_claimed_release_time: lockup_end.plus_seconds(release_duration.seconds() * 2), }, batches().load(deps.as_ref().storage, 2u64).unwrap() ); @@ -1064,7 +1075,7 @@ fn test_claim_all() { amount: Uint128::new(100), amount_claimed: Uint128::new(10), lockup_end, - release_unit: Milliseconds::from_seconds(12), + release_duration: Milliseconds::from_seconds(12), release_amount, last_claimed_release_time: lockup_end.plus_seconds(12), }, diff --git a/packages/andromeda-finance/src/vesting.rs b/packages/andromeda-finance/src/vesting.rs index aa5a5480b..4b40c95a5 100644 --- a/packages/andromeda-finance/src/vesting.rs +++ b/packages/andromeda-finance/src/vesting.rs @@ -37,8 +37,8 @@ pub enum ExecuteMsg { /// Specifying None would mean no lock up period and funds start vesting right away. lockup_duration: Option, /// How often releases occur in seconds. - release_unit: Milliseconds, - /// Specifies how much is to be released after each `release_unit`. If + release_duration: Milliseconds, + /// Specifies how much is to be released after each `release_duration`. If /// it is a percentage, it would be the percentage of the original amount. release_amount: WithdrawalType, }, @@ -85,8 +85,8 @@ pub struct BatchResponse { /// When the lockup ends. pub lockup_end: Milliseconds, /// How often releases occur. - pub release_unit: Milliseconds, - /// Specifies how much is to be released after each `release_unit`. If + pub release_duration: Milliseconds, + /// Specifies how much is to be released after each `release_duration`. If /// it is a percentage, it would be the percentage of the original amount. pub release_amount: WithdrawalType, /// The time at which the last claim took place in seconds.