Skip to content

Core 341. Wrap all stable math ops to prevent unsafe calls#114

Open
Bromel777 wants to merge 1 commit into
developfrom
core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls
Open

Core 341. Wrap all stable math ops to prevent unsafe calls#114
Bromel777 wants to merge 1 commit into
developfrom
core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls

Conversation

@Bromel777

Copy link
Copy Markdown
Contributor

No description provided.

@Bromel777 Bromel777 force-pushed the core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls branch 3 times, most recently from 0d6a928 to 527c561 Compare July 18, 2024 12:19
@Bromel777 Bromel777 force-pushed the core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls branch from 527c561 to 03e0371 Compare July 18, 2024 13:50
Comment on lines +548 to +557
U512::from((self.reserves_x - self.treasury_x).untag() * self.multiplier_x),
U512::from((self.reserves_y - self.treasury_y).untag() * self.multiplier_x),
U512::from(self.an2n),
)
.expect(
format!(
"Invariant calculated incorrectly. calculate_invariant({}, {}, {})",
U512::from((self.reserves_x - self.treasury_x).untag() * self.multiplier_x),
U512::from((self.reserves_y - self.treasury_y).untag() * self.multiplier_x),
U512::from(self.an2n),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why repeating calculations? Bind them and reuse.

@Bromel777 Bromel777 force-pushed the core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls branch 2 times, most recently from 6cec840 to ef5e874 Compare July 22, 2024 12:46
@Bromel777 Bromel777 force-pushed the core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls branch 2 times, most recently from 7703eae to 92852ab Compare August 19, 2024 12:56
Wrap stable pool math with Option<..>
@Bromel777 Bromel777 force-pushed the core-341-wrap-all-stable-math-ops-to-prevent-unsafe-calls branch from 92852ab to 43698c4 Compare August 19, 2024 13:22
@AOranov AOranov self-requested a review August 19, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants