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

Changed LPFee to Percent type in Asset Conversion Pallet #1237

Closed
wants to merge 2 commits into from

Conversation

PatricioNapoli
Copy link
Contributor

@PatricioNapoli PatricioNapoli commented Aug 29, 2023

Fixes #88

Changed Liquidity Pool fee in Asset Conversion pallet from a u32 to a Percent type.

TODO: Fix fee multipliers

@PatricioNapoli PatricioNapoli added R0-silent Changes should not be mentioned in any release notes T2-pallets This PR/Issue is related to a particular pallet. D1-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Aug 29, 2023
@paritytech-ci paritytech-ci requested review from a team August 29, 2023 05:46
@@ -291,6 +291,7 @@ parameter_types! {
pub const AllowMultiAssetPools: bool = false;
// should be non-zero if AllowMultiAssetPools is true, otherwise can be zero
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
pub LiquidityPoolFee: Percent = Percent::from_rational_with_rounding(997u32, 1000u32, Rounding::NearestPrefDown).unwrap(); // 0.3%
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this be zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah undesired, I meant (3, 1000) which is still rounded to either 0% or 1% depending on rounding rule. I probably need more accuracy for a 0.3% using Permill (there is no inbetween Percent and Permill right?) and then the fee calculations need to take this into consideration

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it will have to be a PerMill

@paritytech-ci paritytech-ci requested a review from a team August 29, 2023 06:14
let amount_in_with_fee = amount_in
.checked_mul(&(T::HigherPrecisionBalance::from(1000u32) - (T::LPFee::get().into())))
.ok_or(Error::<T>::Overflow)?;
let fee_mult = T::HigherPrecisionBalance::from(T::LPFee::get() * 1u32);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO, temporal, same as below

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 2/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3465536

@@ -173,7 +173,7 @@ pub mod pallet {

/// A % the liquidity providers will take of every swap. Represents 10ths of a percent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// A % the liquidity providers will take of every swap. Represents 10ths of a percent.
/// A % the liquidity providers will take of every swap.

@bkchr
Copy link
Member

bkchr commented Nov 29, 2023

Ping @PatricioNapoli

@bkchr bkchr closed this Nov 29, 2023
@bkchr bkchr deleted the pato/asset-conversion-lpfee branch November 29, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D1-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. R0-silent Changes should not be mentioned in any release notes T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asset Conversion LPFee Should Use a Per{Something} Instead of u32
5 participants