Let's say I have vesting schedule for 1 year and then 3 year following linear unlocking. But I terminate vesting in the middle.
I use this test code
#[test]
fn test_123_team_terminate() {
let e = Env::init(None);
let users = Users::init(&e);
let amount = d(60000, TOKEN_DECIMALS);
e.set_time_sec(GENESIS_TIMESTAMP_SEC);
let lockups = e.get_account_lockups(&users.alice);
assert!(lockups.is_empty());
let vesting_schedule = Schedule(vec![
Checkpoint {
timestamp: GENESIS_TIMESTAMP_SEC,
balance: 0,
},
Checkpoint {
timestamp: GENESIS_TIMESTAMP_SEC + ONE_YEAR_SEC,
balance: amount,
},
]);
let lockup = Lockup {
account_id: users.alice.valid_account_id(),
schedule: Schedule(vec![
Checkpoint {
timestamp: GENESIS_TIMESTAMP_SEC + ONE_YEAR_SEC,
balance: 0,
},
Checkpoint {
timestamp: GENESIS_TIMESTAMP_SEC + 4 * ONE_YEAR_SEC,
balance: amount,
},
]),
claimed_balance: 0,
termination_config: Some(TerminationConfig {
terminator_id: users.eve.valid_account_id(),
vesting_schedule: Some(HashOrSchedule::Schedule(vesting_schedule)),
}),
};
let balance: WrappedBalance = e.add_lockup(&e.owner, amount, &lockup).unwrap_json();
assert_eq!(balance.0, amount);
let lockups = e.get_account_lockups(&users.alice);
assert_eq!(lockups.len(), 1);
assert_eq!(lockups[0].1.total_balance, amount);
assert_eq!(lockups[0].1.claimed_balance, 0);
assert_eq!(lockups[0].1.unclaimed_balance, 0);
println!("π° TGE -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
e.set_time_sec(GENESIS_TIMESTAMP_SEC + ONE_MONTH_SEC);
let lockups = e.get_account_lockups(&users.alice);
assert_eq!(lockups.len(), 1);
assert_eq!(lockups[0].1.total_balance, amount);
assert_eq!(lockups[0].1.claimed_balance, 0);
assert_eq!(lockups[0].1.unclaimed_balance, 0);
println!("π° 1 month latter -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
e.set_time_sec(GENESIS_TIMESTAMP_SEC + ONE_YEAR_SEC / 2);
let lockups = e.get_account_lockups(&users.alice);
let lockup_index = lockups[0].0;
assert_eq!(lockups.len(), 1);
assert_eq!(lockups[0].1.total_balance, amount);
assert_eq!(lockups[0].1.claimed_balance, 0);
assert_eq!(lockups[0].1.unclaimed_balance, 0);
println!("π° half year latter -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
// TERMINATE employee half-year after vesting had started
ft_storage_deposit(&users.eve, TOKEN_ID, &users.eve.account_id);
let res: WrappedBalance = e.terminate(&users.eve, lockup_index).unwrap_json();
println!("β€οΈβπ₯ terminator gets {} ", res.0 / 1e18 as u128);
assert_eq!(res.0, amount / 2);
let terminator_balance = e.ft_balance_of(&users.eve);
println!("β€οΈβπ₯ terminator gets {} ", terminator_balance / 1e18 as u128);
assert_eq!(terminator_balance, amount / 2);
let lockups = e.get_account_lockups(&users.alice);
assert_eq!(lockups.len(), 1);
assert_eq!(lockups[0].1.total_balance, amount / 2);
assert_eq!(lockups[0].1.claimed_balance, 0);
assert_eq!(lockups[0].1.unclaimed_balance, 0);
println!("π° available after termination (1/2y) -> {} ", lockups[0].1.total_balance / 1e18 as u128);
println!("π° available after termination (1/2y) -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
e.set_time_sec(GENESIS_TIMESTAMP_SEC + ONE_YEAR_SEC + 1);
let lockups = e.get_account_lockups(&users.alice);
println!("π° 1 year + 1s latter -> {} ", lockups[0].1.total_balance / 1e18 as u128);
println!("π° 1 year + 1s year latter -> {} ", lockups[0].1.claimed_balance / 1e18 as u128);
println!("π° 1 year + 1s year latter -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
e.set_time_sec(GENESIS_TIMESTAMP_SEC + 5 * ONE_YEAR_SEC / 2);
let lockups = e.get_account_lockups(&users.alice);
println!("π° 2.5 year latter -> {} ", lockups[0].1.total_balance / 1e18 as u128);
println!("π° 2.5 year latter -> {} ", lockups[0].1.claimed_balance / 1e18 as u128);
println!("π° 2.5 year latter -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
e.set_time_sec(GENESIS_TIMESTAMP_SEC + 4 * ONE_YEAR_SEC );
let lockups = e.get_account_lockups(&users.alice);
println!("π° 4 year latter -> {} ", lockups[0].1.total_balance / 1e18 as u128);
println!("π° 4 year latter -> {} ", lockups[0].1.claimed_balance / 1e18 as u128);
println!("π° 4 year latter -> {} ", lockups[0].1.unclaimed_balance / 1e18 as u128);
}
After termination, half tokens goes to terminator, half already vested and thats OK. However why after termination unlocking works like it would work with full amount? I expected 2.5 years latter I can claim only half of the vested tokens, - 15k, and only at 4 years latter - all of them which is 30k. Is it possible to setup this way? (like it's % rather than absolute numbers?)
TGE -> 0
π° 1 month latter -> 0
π° half year latter -> 0
β€οΈβπ₯ terminator gets 30000
β€οΈβπ₯ terminator gets 30000
π° available after termination (1/2y) -> 30000
π° available after termination (1/2y) -> 0
π° 2.5 year latter -> 30000
π° 2.5 year latter -> 0
π° 2.5 year latter -> 30000 /// βοΈHERE IT SHOULD BE 15000 β
π° 4 year latter -> 30000
π° 4 year latter -> 0
π° 4 year latter -> 30000