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

[Nara] Shouldn't be possible to buy/sell token when CRT pallet is frozen #5028

Open
freakstatic opened this issue Jan 7, 2024 · 4 comments
Assignees

Comments

@freakstatic
Copy link
Contributor

freakstatic commented Jan 7, 2024

As @ivanturlakov reported here it seems that is possible to buy and sell tokens even with the CRT pallet frozen.
Since there are some runtime tests covering the sale, maybe atlas is not displaying the error or something happen during the tests that made the pallet not being actually frozen.

@freakstatic
Copy link
Contributor Author

it seems that this bug could be related with freezing, unfreezing the pallet and then freezing it again

@mnaamani
Copy link
Member

mnaamani commented Jan 8, 2024

Looks like we simply forgot to add a guard for both buy_on_amm and sell_on_amm dispatch calls

Fix:

diff --git a/runtime-modules/project-token/src/lib.rs b/runtime-modules/project-token/src/lib.rs
index 960ea3a284..5fba7a5ab3 100644
--- a/runtime-modules/project-token/src/lib.rs
+++ b/runtime-modules/project-token/src/lib.rs
@@ -836,6 +836,8 @@ decl_module! {
         /// - event deposited
         #[weight = WeightInfoToken::<T>::buy_on_amm_with_existing_account()]
         fn buy_on_amm(origin, token_id: T::TokenId, member_id: T::MemberId, amount: <T as Config>::Balance, slippage_tolerance: Option<(Permill, JoyBalanceOf<T>)>) -> DispatchResult {
+            Self::ensure_unfrozen_state()?;
+
             if amount.is_zero() {
                 return Ok(()); // noop
             }
@@ -916,6 +918,8 @@ decl_module! {
         /// - event deposited
         #[weight = WeightInfoToken::<T>::sell_on_amm()]
         fn sell_on_amm(origin, token_id: T::TokenId, member_id: T::MemberId, amount: <T as Config>::Balance, slippage_tolerance: Option<(Permill, JoyBalanceOf<T>)>) -> DispatchResult {
+            Self::ensure_unfrozen_state()?;
+
             if amount.is_zero() {
                return Ok(()); // noop
             }

@mnaamani mnaamani self-assigned this Jan 8, 2024
@mnaamani
Copy link
Member

mnaamani commented Jan 8, 2024

My best guess is in the QA testing, not the same extrinsic was tested with pallet frozen vs when it was not-frozen.

@mnaamani
Copy link
Member

mnaamani commented Jan 8, 2024

It seems that when reviewing #4871 I missed these two new dispatch calls

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

No branches or pull requests

2 participants