liberland / liberland_substrate

Substrate implementation of the Liberland Network node
22 stars 14 forks source link

Eresident only assets #410

Closed kacperzuk-neti closed 5 days ago

kacperzuk-neti commented 2 months ago

First commit contains just vendoring-in pallet-assets, second commit contains actual changes. DEX Liquidity Pool accounts are exempt from the eresidency restriction regardless the asset parameters set.

Known caveats:

  1. If eresident owns restricted assets and puts them in dex, he can transfer liquidity tokens to non-eresidents. These non-eresidents won't be able to withdraw the liquidity to get actual restricted assets though.
  2. Swaps on DEX can be triggered by non-eresidents as long as they set the immediate recipient of swap to valid eresident.

Sample guide on how to test:

  1. Alice (citizen) - assets.create
  2. Alice - assets.setParameters - eresidencyRequired: true
  3. Alice - assets.mint to Alice
  4. Alice - assets.transfer to Bob (citizen)
  5. Alice - assets.transfer to Ferdie (non-citizen, should fail with TokenBlocked)
  6. Alice - assetConversion.createPool with native
  7. Alice - assetConversion.addLiquidity
  8. Alice - assetConversion.swapTokensForExactTokens, swap Native to asset, should succeed
  9. Ferdie - assetConversion.swapTokensForExactTokens, swap Native to asset, should fail with TokenBlocked