Skip to content

Conversation

@blueogin
Copy link
Collaborator

Description

Added a GenericDistributionHelper XDC-fork test to verify that swapping G$ to XDC through xswap is working correctly.

About # (link your issue here)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:275-284` </location>
<code_context>
+  it("should correctly calculate swap amounts using XSWAP pools", async function () {
</code_context>

<issue_to_address>
**suggestion (testing):** Missing test for edge cases in calcGDToSell (e.g., zero input, very large input).

Add tests for calcGDToSell with zero and very large G$ inputs to verify correct handling of boundary conditions.
</issue_to_address>

### Comment 2
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:322-331` </location>
<code_context>
+  it("should handle swap with correct slippage protection", async function () {
</code_context>

<issue_to_address>
**suggestion (testing):** Missing test for slippage exceeding maxSlippage.

Add a test case where slippage exceeds maxSlippage and verify that the swap is reverted, confirming slippage protection works correctly.
</issue_to_address>

### Comment 3
<location> `test/reserve/GenericDistributionHelper.e2e.test.ts:343` </location>
<code_context>
    const maxSlippage = feeSettings.maxSlippage;

</code_context>

<issue_to_address>
**suggestion (code-quality):** Prefer object destructuring when accessing and using properties. ([`use-object-destructuring`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/use-object-destructuring))

```suggestion
    const {maxSlippage} = feeSettings;
```

<br/><details><summary>Explanation</summary>Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the [Airbnb Javascript Style Guide](https://airbnb.io/javascript/#destructuring--object)
</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +275 to +288
it("should correctly calculate swap amounts using XSWAP pools", async function () {
const amountToSell = ethers.utils.parseEther("100"); // 100 G$

// Test quote from G$ to CUSD
const [quoteCUSD, poolsGDCUSD] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
amountToSell,
goodDollar.address,
reserveToken.address,
60
);
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Missing test for edge cases in calcGDToSell (e.g., zero input, very large input).

Add tests for calcGDToSell with zero and very large G$ inputs to verify correct handling of boundary conditions.

Comment on lines 322 to 335
it("should handle swap with correct slippage protection", async function () {
// This test verifies that the swap respects maxSlippage settings
const amountToSell = ethers.utils.parseEther("50"); // 50 G$

// Get quote
const [quoteCUSD, ] = await staticOracle.quoteAllAvailablePoolsWithTimePeriod(
amountToSell,
goodDollar.address,
reserveToken.address,
60
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Missing test for slippage exceeding maxSlippage.

Add a test case where slippage exceeds maxSlippage and verify that the swap is reverted, confirming slippage protection works correctly.

@sirpy sirpy force-pushed the feat/fork-test/distribution-with-xswap branch from 71b4c84 to d74faa9 Compare December 24, 2025 09:34
expect(xdcIncrease.gt(0), "Swap should have increased either WXDC or xdc balance").to.be.true;
});

it("should correctly calculate swap amounts using XSWAP pools", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

you are not comparing the quotes to calcgdtosell so you are not actually testing "correctly calculate swap amounts"

});
});

it("should handle swap with correct slippage protection", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

you are not swaping so you dont actually test slippage protection.
either change the name or modify the logic

@openzeppelin-code
Copy link

openzeppelin-code bot commented Dec 24, 2025

Add xdc fork test for GenericDistributionHelper

Generated at commit: a8f06c3d2f41c58b5283390b7da9a149870a789f

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
5
0
16
44
68
Dependencies Critical
High
Medium
Low
Note
Total
0
0
1
0
130
131

For more details view the full report in OpenZeppelin Code Inspector

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.

3 participants