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

Future Swap limitation #2843

Merged
merged 18 commits into from
Mar 22, 2024
Merged

Future Swap limitation #2843

merged 18 commits into from
Mar 22, 2024

Conversation

Bushstar
Copy link
Member

@Bushstar Bushstar commented Mar 4, 2024

Summary

  • Limits the amount that can be swapped from loan token to DUSD to 10% of the 28 day average liquidity of that loan token in its DUSD pool. Actual percentage and period is configurable, but defaults to the values above.
  • Average liquidity will only populate on a Future Swap event if there is enough liquidity data present, which there should be as long as the limitation has been enabled for the full 28 days period before the event.
  • If there is no average liquidity present then Future Swap will behave as normal without any limits.
  • Implements DFIP-2211-F: Limit FutureSwap volume dfips#238

RPCs

  • listloantokenliquidity returns a list of all present average liquidity.

Implications

  • Storage

    • Database reindex required
    • Database reindex optional
    • Database reindex not required
    • None
  • Consensus

    • Network upgrade required
    • Includes backward compatible changes
    • Includes consensus workarounds
    • Includes consensus refactors
    • None

src/dfi/consensus/smartcontracts.cpp Outdated Show resolved Hide resolved
src/dfi/validation.cpp Outdated Show resolved Hide resolved
src/dfi/validation.cpp Show resolved Hide resolved
Copy link
Contributor

@kuegi kuegi left a comment

Choose a reason for hiding this comment

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

small comment, rest looks good to me

src/dfi/validation.cpp Outdated Show resolved Hide resolved
src/dfi/validation.cpp Outdated Show resolved Hide resolved
@prasannavl
Copy link
Member

The cost of doing these calc at every block concerns me. This is going to stall the chain esp. on sync catch-up at this block range, which cannot be fixed after the fact as well.

We might likely want to just to do the calc at periodic intervals. I don't think accuracy is necessary here.

@kuegi
Copy link
Contributor

kuegi commented Mar 20, 2024

The cost of doing these calc at every block concerns me. This is going to stall the chain esp. on sync catch-up at this block range, which cannot be fixed after the fact as well.

We might likely want to just to do the calc at periodic intervals. I don't think accuracy is necessary here.

valid point. how about doing it every price block (so every 120 blocks)?

@prasannavl
Copy link
Member

Indeed, that would be perfect. We'll add var that makes the time period changeable.

@prasannavl prasannavl merged commit 055fae7 into master Mar 22, 2024
24 of 26 checks passed
@prasannavl prasannavl deleted the bush/fs-limit branch March 22, 2024 08:13
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.

4 participants