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

feat: allow setting liquidity cap for ZRC20 #1205

Merged
merged 17 commits into from
Oct 3, 2023
Merged

feat: allow setting liquidity cap for ZRC20 #1205

merged 17 commits into from
Oct 3, 2023

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Sep 27, 2023

Description

Allow setting a liquidity cap for a ZRC20. The value is stored in the ForeignCoin object. If the liquidity cap is reached (total minted on ZetaChain + inbound amount > liquidity cap) the cctx is automatically reverted to limit the liquidity on ZetaChain.

The value can be set from admin group 2 through the MsgUpdateZRC20LiquidityCap message.

Add smoke tests for the change

Other changes:

  • Introduce HandleEvmDeposit tests
  • Introduce ZRC20DepositAndCallContract tests

Closes: #1187

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

@lumtis lumtis self-assigned this Sep 27, 2023
@github-actions
Copy link

!!!WARNING!!!
nosec detected in the following files: testutil/nullify/nullify.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Sep 27, 2023
@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Sep 27, 2023
@lumtis lumtis marked this pull request as ready for review September 27, 2023 19:42
Copy link
Collaborator

@brewmaster012 brewmaster012 left a comment

Choose a reason for hiding this comment

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

LGTM

if txOrigin == "" {
txOrigin = msg.Sender
}
if len(logs) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does len(logs) == 0 mean something wrong (e.g., we always expect some logs)? Just curious about what pre-assumption we had in our mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

It prevents doing unnecessary call to fetch system contracts since there would be no logs to iterate

}

// update the liquidity cap
coin.LiquidityCap = msg.LiquidityCap
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that when currentTotalSupply already > msg.LiquidityCap, the ZRC20 will be capped immediately, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

currentSupply + amount > liquidityCap is the condition checked, therefore setting a liquidity cap below current supply would immediately blocks the deposits

Copy link
Contributor

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

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

looks good. no blocking comment

@lumtis lumtis requested a review from a team as a code owner October 3, 2023 18:19
@lumtis lumtis merged commit 4de526b into develop Oct 3, 2023
14 checks passed
@lumtis lumtis deleted the feat/cap-limit branch October 3, 2023 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli breaking:proto ci Changes to CI pipeline or github actions nosec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

liquidity cap
3 participants