-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: minimum chunk size setting #5314
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5314 +/- ##
======================================
- Coverage 70% 70% -0%
======================================
Files 489 489
Lines 87874 87776 -98
Branches 87874 87776 -98
======================================
- Hits 61939 61772 -167
- Misses 22630 22694 +64
- Partials 3305 3310 +5 ☔ View full report in Codecov by Sentry. |
@@ -1964,6 +1983,18 @@ pub mod pallet { | |||
swap_amount | |||
}; | |||
|
|||
// Restrict the number of chunks based on the minimum chunk size. | |||
let dca_params = dca_params.map(|mut dca_params| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoheb391 just double checking that the frontend will be able to handle this (changing the number of dca chunks based on the amount). I imagine if you are reading the number of chunks from SwapRequested
rather than by looking at the channel, this shouldn't be a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msgmaxim The front-end does not have an option to change dca interval params. It is our quoting endpoint that decides on the dca params. if the swap amount is under the configuration amount (~3000usd) we only use 1 chunk so it won't be an issue on our front-end or in our sdk if they use it like we recommend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoheb391 The issue here is that the protocol might change the parameters: if the chosen number of chunks would result in chunks that are smaller than some minimum, we reduce the number of chunks accordingly. This can still happen with our FE. Example: User requests a quote for 10BTC and gets a dca quote for 1000 chunks. But then they only send 0.1BTC. In this case, the protocol would adjust the number of chunks to something smaller than 1000 to ensure we don't waste resources on 1000 tiny swaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see now. yeah we're using the channel for dca params. So that might be a problem for us. We will need to make that switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm guessing interval remains unchanged though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyways will track the issue and make the necessary changes 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm guessing interval remains unchanged though?
Yes, no change to the interval but I would still recommend using the swap request details rather than the channel details for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but let's see whether or not we want a migration here to set the initial limits.
#[pallet::storage] | ||
#[pallet::getter(fn minimum_chunk_size)] | ||
pub type MinimumChunkSize<T: Config> = | ||
StorageMap<_, Twox64Concat, Asset, AssetAmount, ValueQuery>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really need to be stored as an AssetAmount
. u32
is plenty, and then we don't have the confusion of returning a NumberOrHex from the rpc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some assets like ETH have 18 decimal places. Even if we set this so something small like 0.001 ETH, it would still be a large enough number that it won't fit in u32, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ignore me. For some reason I was confusing chunk size with number of chunks. AssetAmount makes total sense.
…lana-ccm * origin/main: chore: update polkadot sdk 1.15.2, rust to 2024-07-31 (#5306) chore: add sol min_prio_fee to ingress and egress estimation (#5323) docs: fix log filtering in readme (#5319) feat: cleanup aborted broadcasts (#5301) fix: increase init timeout for backup test (#5317) feat: minimum chunk size setting (#5314) chore: add egress fee for token account rent (#5315) fix: ensure unused sol deposit channels are closed (#5312)
Pull Request
Closes: PRO-1703
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
MinimumChunkSize
init_swap_request
function that lowers the number of chunks so it will always be >= to the minimum.minimum_chunk_size
AssetMap
to theSwappingEnvironment