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

fix: refactor deposit logic #702

Closed
wants to merge 3 commits into from
Closed

fix: refactor deposit logic #702

wants to merge 3 commits into from

Conversation

ajansari95
Copy link
Contributor

1. Overview

  • Simplified deposit logic by consolidating common code and eliminating redundancy wherever possible.

2. Implementation details

  • Optimized AnyDeposit logic by resolving repetitive if-else blocks.
  • Unified deposit types using an enum, removing separate deposit modules

3. How to test/use

4. Checklist

  • Does the Readme need to be updated?

5. Limitations (optional)

6. Future Work (optional)

Copy link
Contributor

@magiodev magiodev left a comment

Choose a reason for hiding this comment

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

I don't quite understand why the rename from any_deposit to deposit.rs. This seems unnecessary and much less consistent. If we want a single deposit.rs file, we should also merge in the logic from exact_deposit.rs, but I tend to prefer keeping things separate. This is just your preference, but in my opinion, it should be one or the other.

Copy link
Contributor

@magiodev magiodev left a comment

Choose a reason for hiding this comment

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

After checking out the branch locally, I realized that you did, hehe. The file changes on GitHub are not showing any change in the exact_deposit.rs file. Anyway, I still think that merging those two into one becomes monolithic and unnecessary. The execute_deposit() function is very large, and having a big match there with nested logic, or even wrapped by helper functions, doesn’t provide any clean proposition nor enhance the readability.

@ajansari95 ajansari95 force-pushed the fix/deposit-refactor branch from 6e5f871 to d518490 Compare July 25, 2024 05:25
@ajansari95 ajansari95 requested a review from magiodev July 25, 2024 05:30
Copy link
Contributor

@0xLaurenzo 0xLaurenzo left a comment

Choose a reason for hiding this comment

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

The addition of the Deposit type enum does not make a whole lot of sense to me since that same information is already implied by the two different entry points. For this PR, I'd remove any changes related to that enum's addition and discuss that in slack and restrict the PR to the math refactor in range.rs

@@ -173,6 +173,11 @@ pub struct InstantiateMsg {
pub initial_upper_tick: i64,
}

pub enum DepositType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this distinction not already made by the two different entrypoints?


let user_value = get_asset0_value(deps.storage, &deps.querier, deposit.0, deposit.1)?;
let refund_value = get_asset0_value(deps.storage, &deps.querier, refund.0, refund.1)?;
// NOTE: both the deposit arms here have some repeated math logic,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we combine both entrypoints into a single function call, why do we still have math logic that is repeated?

@ajansari95 ajansari95 closed this Aug 1, 2024
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