Skip to content

fix: exclude funding fee from pool_amount in decrease_position (closes #412) - #482

Merged
abayomicornelius merged 1 commit into
SO4-Markets:mainfrom
Obiajulu-gif:fix/issue-412-funding-fee-pool-amount
Jul 26, 2026
Merged

fix: exclude funding fee from pool_amount in decrease_position (closes #412)#482
abayomicornelius merged 1 commit into
SO4-Markets:mainfrom
Obiajulu-gif:fix/issue-412-funding-fee-pool-amount

Conversation

@Obiajulu-gif

@Obiajulu-gif Obiajulu-gif commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Closes #412

Summary

In \decrease_position, only borrowing and position fees are added to \pool_amount. The funding fee is excluded because it is peer-to-peer and tracked separately via the funding accumulator.

Problem

\ otal_cost_amount\ (borrowing + funding + position fees) was added entirely to \pool_amount. This double-booked the funding fee: the paying side's funding fee inflated LP-owned pool value at close, while the counter side still independently claims the same tokens via the funding accumulator — without \pool_amount\ ever being decremented. Over time this systematically overstated the GM token price.

Fix

Changed \�pply_delta_to_pool_amount\ and \claimable_fee_amount_key\ to use \�orrowing_fee_amount + position_fee_amount\ instead of \ otal_cost_amount.

…SO4-Markets#412)

total_cost_amount (borrowing + funding + position fees) was added entirely
to pool_amount, double-booking the funding fee: the paying side's funding
fee inflates LP-owned pool value while the counter side still claims the
same tokens via the funding accumulator. Now only borrowing_fee_amount +
position_fee_amount feed into pool_amount and claimable_fee_amount.
@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@Obiajulu-gif Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@abayomicornelius
abayomicornelius merged commit 7b58316 into SO4-Markets:main Jul 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decrease_position_utils: funding fee is credited to LP pool_amount instead of the counter-side traders

2 participants