Skip to content

Commit

Permalink
ignore pending assets
Browse files Browse the repository at this point in the history
  • Loading branch information
pisuthd committed May 27, 2024
1 parent 54e0f12 commit 933c8f4
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions packages/sui/sources/vault.move
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,20 @@ module legato::vault {
// Check if the pool has staked_sui at the current index
if ( vector::length(&pool.staked_sui) > count ) {
let staked_sui = vector::borrow(&pool.staked_sui, count);
let amount_with_rewards = get_amount_with_rewards(wrapper, staked_sui, epoch);

// If the amount with rewards is greater than the input amount, update output variables and break
if (amount_with_rewards > input_amount) {
output_pool = option::some<String>( pool_name );
output_id = option::some<u64>( count );
count = length; // break main loop
break
let activation_epoch = staking_pool::stake_activation_epoch(staked_sui);

if (epoch > activation_epoch) {
let amount_with_rewards = get_amount_with_rewards(wrapper, staked_sui, epoch);

// If the amount with rewards is greater than the input amount, update output variables and break
if (amount_with_rewards > input_amount) {
output_pool = option::some<String>( pool_name );
output_id = option::some<u64>( count );
count = length; // break main loop
break
};
};

};

pool_count = pool_count+1;
Expand Down Expand Up @@ -722,17 +727,22 @@ module legato::vault {
let pool_name = *vector::borrow(pool_list, pool_count);
let pool = table::borrow(pools, pool_name);


let length = vector::length(&pool.staked_sui);
let item_count = 0;
while (item_count < length) {
let staked_sui = vector::borrow(&pool.staked_sui, item_count);
let amount_with_rewards = get_amount_with_rewards(wrapper, staked_sui, epoch);
let this_ratio = fixed_point64::create_from_rational( (amount_with_rewards as u128) , (input_amount as u128));
let activation_epoch = staking_pool::stake_activation_epoch(staked_sui);

if (epoch > activation_epoch) {
let amount_with_rewards = get_amount_with_rewards(wrapper, staked_sui, epoch);
let this_ratio = fixed_point64::create_from_rational( (amount_with_rewards as u128) , (input_amount as u128));

vector::push_back(&mut ratio, this_ratio);
vector::push_back(&mut ratio_to_id, item_count);
vector::push_back(&mut ratio_to_pool, pool_name);
vector::push_back(&mut ratio, this_ratio);
vector::push_back(&mut ratio_to_id, item_count);
vector::push_back(&mut ratio_to_pool, pool_name);

};


item_count = item_count+1;
};
Expand Down

0 comments on commit 933c8f4

Please sign in to comment.