Skip to content

Commit

Permalink
Merge pull request #10 from memechan-gg/fix/reported-issues
Browse files Browse the repository at this point in the history
🔧 fix: get_fees
  • Loading branch information
avernikoz authored May 8, 2024
2 parents e4420b9 + e8b0a1a commit 0122ce3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
17 changes: 6 additions & 11 deletions memechan/sources/live_phase/fee_distribution.move
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,14 @@ module memechan::fee_distribution {
): (u64, u64) {
let sender = tx_context::sender(ctx);

if (!table::contains(&state.user_withdrawals_x, sender)) {
return (0, 0)
};
let user_withdrawals_x = if (table::contains(&state.user_withdrawals_x, sender))
*table::borrow(&state.user_withdrawals_x, sender) else 0;
let max_withdrawal_x = get_max_withdraw(user_withdrawals_x, state.fees_meme_total, user_stake, state.stakes_total);

let user_withdrawals_x = table::borrow(&state.user_withdrawals_x, sender);
let max_withdrawal_x = get_max_withdraw(*user_withdrawals_x, state.fees_meme_total, user_stake, state.stakes_total);

if (!table::contains(&state.user_withdrawals_y, sender)) {
return (0, 0)
};

let user_withdrawals_y = table::borrow(&state.user_withdrawals_y, sender);
let max_withdrawal_y = get_max_withdraw(*user_withdrawals_y, state.fees_s_total, user_stake, state.stakes_total);
let user_withdrawals_y = if (table::contains(&state.user_withdrawals_y, sender))
*table::borrow(&state.user_withdrawals_y, sender) else 0;
let max_withdrawal_y = get_max_withdraw(user_withdrawals_y, state.fees_s_total, user_stake, state.stakes_total);

(max_withdrawal_x, max_withdrawal_y)
}
Expand Down
2 changes: 1 addition & 1 deletion memechan/sources/live_phase/vesting.move
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module memechan::vesting {
): VestingConfig {
assert!(start_ts <= cliff_ts, EInconsistentTimestamps);
assert!(cliff_ts <= end_ts, EInconsistentTimestamps);
// `end_ts` must be greater than `start_ts`, otherwise the functino {duration} will attempt to divide by zero.
// `end_ts` must be greater than `start_ts`, otherwise the function {duration} will attempt to divide by zero.
assert!(start_ts < end_ts, EInconsistentTimestamps);

VestingConfig {
Expand Down
5 changes: 5 additions & 0 deletions memechan/tests/integration.move
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,16 @@ module memechan::integration {
ctx(scenario_mut),
);

let (fee_s_amount, fee_m_amount) = staking_pool::get_fees<SUI, BODEN, LP_COIN>(&staking_pool, ctx(scenario_mut));

let (coin_s, coin_m) = staking_pool::withdraw_fees<SUI, BODEN, LP_COIN>(
&mut staking_pool,
ctx(scenario_mut),
);

assert_eq(fee_s_amount, coin::value(&coin_s));
assert_eq(fee_m_amount, coin::value(&coin_m));

// TODO: More fee tests with unstaking

token::burn_for_testing(m_token);
Expand Down

0 comments on commit 0122ce3

Please sign in to comment.