Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

wip

# This is the commit message #2:

fix ref cnt error
  • Loading branch information
JSHan94 committed Mar 14, 2024
1 parent f82835d commit 6358a17
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 9 deletions.
100 changes: 91 additions & 9 deletions precompile/modules/initia_stdlib/sources/vip/vesting.move
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,58 @@ module initia_std::vip_vesting {
//

#[event]
struct VestingClaimEvent has drop, store {
struct UserVestingCreateEvent has drop, store {
account: address,
bridge_id: u64,
start_stage: u64,
end_stage: u64,
l2_score: u64,
minimum_score: u64,
initial_reward: u64,
}

#[event]
struct OperatorVestingCreateEvent has drop, store {
account: address,
bridge_id: u64,
start_stage: u64,
end_stage: u64,
initial_reward: u64,
}

#[event]
struct UserVestingFinalizedEvent has drop, store {
account: address,
bridge_id: u64,
stage: u64,
remaining_reward: u64,
}

#[event]
struct OperatorVestingFinalizedEvent has drop, store {
account: address,
bridge_id: u64,
stage: u64,
remaining_reward: u64,
}

#[event]
struct UserVestingClaimEvent has drop, store {
account: address,
bridge_id: u64,
stage: u64,
vesting_reward_amount: u64,
vested_reward_amount: u64,
vesting_changes: vector<VestingChange>,
}

#[event]
struct OperatorVestingClaimEvent has drop, store {
account: address,
bridge_id: u64,
// claimed stage.
stage: u64,
// newly vested reward amount.
vesting_reward_amount: u64,
// accumulated claimed vesting reward that was previously distributed.
vested_reward_amount: u64,
// vesting changes
vesting_changes: vector<VestingChange>,
}

Expand Down Expand Up @@ -261,6 +303,14 @@ module initia_std::vip_vesting {

// move vesting if end stage is over or the left reward is empty
if ( stage > value.end_stage || value.remaining_reward == 0) {
event::emit(
UserVestingFinalizedEvent {
account: account_addr,
bridge_id,
stage: value.start_stage,
remaining_reward: value.remaining_reward,
}
);
finalize_vesting<UserVesting>(account_addr, bridge_id, value.start_stage);
continue
};
Expand Down Expand Up @@ -299,6 +349,14 @@ module initia_std::vip_vesting {

// move vesting if end stage is over or the left reward is empty
if ( stage > value.end_stage || value.remaining_reward == 0) {
event::emit(
OperatorVestingFinalizedEvent {
account: account_addr,
bridge_id,
stage: value.start_stage,
remaining_reward: value.remaining_reward,
}
);
finalize_vesting<OperatorVesting>(account_addr, bridge_id, value.start_stage);
continue
};
Expand Down Expand Up @@ -382,6 +440,18 @@ module initia_std::vip_vesting {
minimum_score,
});

event::emit(
UserVestingCreateEvent {
account: account_addr,
bridge_id,
start_stage,
end_stage,
l2_score,
minimum_score,
initial_reward: vesting_reward_amount,
}
);

vesting_reward_amount
}

Expand All @@ -401,6 +471,16 @@ module initia_std::vip_vesting {
end_stage,
});

event::emit(
OperatorVestingCreateEvent {
account: account_addr,
bridge_id,
start_stage,
end_stage,
initial_reward: stage_reward,
}
);

stage_reward
}

Expand Down Expand Up @@ -499,7 +579,9 @@ module initia_std::vip_vesting {
);


let vesting_reward_amount = 0;
let vesting_reward_amount = 0;

// if l2_score is less than 0, do not create new position
if (l2_score >= 0) {
vesting_reward_amount = add_user_vesting(
account_addr,
Expand All @@ -513,7 +595,7 @@ module initia_std::vip_vesting {
};

event::emit(
VestingClaimEvent {
UserVestingClaimEvent {
account: account_addr,
bridge_id,
stage: start_stage,
Expand All @@ -531,7 +613,7 @@ module initia_std::vip_vesting {
bridge_id: u64,
start_stage: u64,
end_stage: u64,
): FungibleAsset acquires VestingStore{
): FungibleAsset acquires VestingStore {
let (vested_reward, vesting_changes) = claim_previous_operator_vestings(
account_addr,
bridge_id,
Expand All @@ -546,7 +628,7 @@ module initia_std::vip_vesting {
);

event::emit(
VestingClaimEvent {
OperatorVestingClaimEvent {
account: account_addr,
bridge_id,
stage: start_stage,
Expand Down
1 change: 1 addition & 0 deletions precompile/modules/initia_stdlib/sources/vip/vip.move
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ module initia_std::vip {
let (bridge_address1, bridge_address2) = (@0x999, @0x1000);
let mint_amount = 1_000_000_000_000;
let release_time = 0;

coin::mint_to(&cap.mint_cap, signer::address_of(chain), mint_amount);
vip_vault::deposit(chain, mint_amount);
coin::mint_to(&cap.mint_cap, signer::address_of(operator), mint_amount);
Expand Down

0 comments on commit 6358a17

Please sign in to comment.