Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bigz/update amm revenue pool logic #398

Merged
merged 11 commits into from
Mar 22, 2023

Conversation

0xbigz
Copy link
Member

@0xbigz 0xbigz commented Mar 17, 2023

No description provided.

@0xbigz 0xbigz marked this pull request as ready for review March 20, 2023 19:48
@@ -614,7 +614,9 @@ describe('delist market', () => {
'totalExchangeFee:',
marketAfter.amm.totalExchangeFee.toString()
);
assert(marketAfter.amm.feePool.scaledBalance.eq(new BN(21567000)));
// assert(marketAfter.amm.feePool.scaledBalance.eq(new BN(21567000)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

programs/drift/src/controller/amm.rs Outdated Show resolved Hide resolved
market
.insurance_claim
.quote_settled_insurance
.safe_add(market.insurance_claim.quote_max_insurance)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this add?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both numbers are positive cumulative numbers for insurance

cumulative liquidation fees are only given for revenue pool up to the current external insurance levels provided + net losses already paid for by external insurance

.safe_sub(market.amm.total_fee_withdrawn.cast()?)?
let fee_pool_threshold = amm_fee_pool_token_amount_after
.saturating_sub(
FEE_POOL_TO_REVENUE_POOL_THRESHOLD.safe_add(market.amm.total_social_loss)?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you add social loss here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a market has had social loss, its indication it needs to maintain a larger fee pool for internal insurance (rather than giving to external insurance)

@crispheaney crispheaney merged commit abb34e4 into master Mar 22, 2023
crispheaney added a commit that referenced this pull request Mar 23, 2023
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.

None yet

2 participants