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

Amendment fixFrozenLPTokenTransfer: Prohibit transfer of LPToken when an asset is frozen #5227

Merged
merged 11 commits into from
Feb 5, 2025

Conversation

shawnxie999
Copy link
Collaborator

@shawnxie999 shawnxie999 commented Dec 18, 2024

High Level Overview of Change

New Definition

If a liquidity pool token (LPToken) is associated with a liquidity pool that contains at least one asset that is regularly frozen, the LPToken itself is considered "frozen". This means:

  1. The holder cannot send the frozen LPToken to others. (The frozen status restricts the holder from transferring the LPToken to another wallet)

  2. The holder can still receive frozen LPTokens. (If someone sends frozen LPTokens to the holder, they can still receive them, even though they cannot send them out)

This behavior is similar to how regular frozen IOUs work: you can receive them, but you cannot send them to others while they are frozen.

Background

Prior to this amendment, a blacklisted account that owns frozen LPTokens could still transfer them through mechanisms such as Payments, Checks, Offers, or NFTs. This loophole allowed the recipient of these LPTokens to redeem or withdraw the underlying assets of the pool, bypassing the restrictions that should have applied to the blacklisted account. This behavior undermines the freezing mechanism's integrity and creates inconsistencies in asset control.

Note: this amendment only works with the existing regular freeze, and has no correlation with deep-freeze

Example

  1. Alice deposits XRP and USD into an AMM pool.
  2. The USD issuer freezes Alice's USD trustline.
  3. Alice transfers her LPToken to Bob (although Alice cannot transfer USD directly, she can still transfer the LPToken).
  4. Bob redeems USD using the received LPToken, effectively bypassing the freezing restrictions imposed on Alice.

Amendment changes

This amendment ensures that frozen LPTokens cannot be transferred. Below are the changes to specific transaction types:

Payments

  • A blacklisted account can no longer send frozen LPTokens through direct payment.
  • Offers attempting to sell frozen LPTokens can no longer be consumed on the DEX.

OfferCreate

  • Accounts are prohibited from creating offers that attempt to sell frozen LPTokens.

CheckCash

  • Cashing a check fails if it attempts to cash a frozen LPToken from the sender.

NFTokenCreateOffer

  • Buyers are prohibited from creating buy offers involving frozen LPTokens.

NFTokenAcceptOffer

  • Buyers cannot accept a sell offer if the offer requires the use of frozen LPTokens as payment.

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)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@shawnxie999 shawnxie999 changed the title Lptoken freeze WIP Lptoken freeze Dec 18, 2024
@shawnxie999 shawnxie999 marked this pull request as ready for review December 18, 2024 21:40
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 91.83673% with 4 lines in your changes missing coverage. Please review.

Project coverage is 78.2%. Comparing base (f6d6308) to head (ceaa99d).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/xrpld/app/misc/detail/AMMUtils.cpp 81.0% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5227   +/-   ##
=======================================
  Coverage     78.1%   78.2%           
=======================================
  Files          790     790           
  Lines        67562   67607   +45     
  Branches      8160    8161    +1     
=======================================
+ Hits         52791   52837   +46     
+ Misses       14771   14770    -1     
Files with missing lines Coverage Δ
include/xrpl/protocol/Feature.h 100.0% <ø> (ø)
src/xrpld/app/paths/detail/DirectStep.cpp 82.5% <100.0%> (ø)
src/xrpld/app/paths/detail/StepChecks.h 100.0% <100.0%> (ø)
src/xrpld/ledger/View.h 100.0% <ø> (ø)
src/xrpld/ledger/detail/View.cpp 91.4% <100.0%> (+0.2%) ⬆️
src/xrpld/app/misc/detail/AMMUtils.cpp 97.4% <81.0%> (-2.1%) ⬇️

... and 4 files with indirect coverage changes

Impacted file tree graph

@shawnxie999 shawnxie999 changed the title WIP Lptoken freeze Amendment fixFrozenLPTokenTransfer: Prohibit transfer of LPToken when an asset is frozen Jan 6, 2025
@shawnxie999 shawnxie999 requested review from gregtatcam, yinyiqian1 and vvysokikh1 and removed request for gregtatcam January 7, 2025 16:11
Copy link
Collaborator

@yinyiqian1 yinyiqian1 left a comment

Choose a reason for hiding this comment

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

It looks functionally fine to me. Just left some comments about style, code coverage and redundant header files included.

src/xrpld/ledger/detail/View.cpp Outdated Show resolved Hide resolved
src/xrpld/ledger/detail/View.cpp Show resolved Hide resolved
src/xrpld/ledger/detail/View.cpp Show resolved Hide resolved
src/xrpld/app/paths/detail/StepChecks.h Outdated Show resolved Hide resolved
src/xrpld/app/paths/detail/StepChecks.h Show resolved Hide resolved
src/test/app/LPTokenTransfer_test.cpp Outdated Show resolved Hide resolved
src/test/app/LPTokenTransfer_test.cpp Outdated Show resolved Hide resolved
src/xrpld/ledger/detail/View.cpp Outdated Show resolved Hide resolved
src/xrpld/ledger/detail/View.cpp Outdated Show resolved Hide resolved
src/xrpld/app/misc/detail/AMMUtils.cpp Show resolved Hide resolved
@yinyiqian1 yinyiqian1 self-requested a review February 3, 2025 15:50
Copy link
Collaborator

@yinyiqian1 yinyiqian1 left a comment

Choose a reason for hiding this comment

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

just replied one comment. it looks good to me.

@kennyzlei kennyzlei added this to the 2.4.0 (2025) milestone Feb 4, 2025
Copy link
Collaborator

@vvysokikh1 vvysokikh1 left a comment

Choose a reason for hiding this comment

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

It looks good to me

src/test/app/LPTokenTransfer_test.cpp Show resolved Hide resolved
src/test/app/LPTokenTransfer_test.cpp Show resolved Hide resolved
src/test/app/LPTokenTransfer_test.cpp Outdated Show resolved Hide resolved
@shawnxie999 shawnxie999 added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Feb 5, 2025
@shawnxie999
Copy link
Collaborator Author

shawnxie999 commented Feb 5, 2025

@bthomee commit msg:

Prohibit LPToken holders from sending LPToken to others if they have been frozen by one of the assets in AMM pool

We can use the amendment name for the descripton/title

@bthomee bthomee merged commit fb3713b into XRPLF:develop Feb 5, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment Bug Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants