Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #269
this adds pallet-asset-conversion. The goal is to improve UX for first-timers that don't have TEER yet. They can just transfer KSM from relay or asset hub and convert into directly on our chain without any more hops. Even if we don't expect this dex to be deeply liquid, it will serve well for small amounts in the order of paying fees for utility
testing
note preimage to register ROC as an asset on Integritee, set metadata and register its multilocation
execution should result in Events:
assets.forceCreated
assets.MetadataSet
assetRegistry.ReserveAssetRegistered
if testing with polkadot >= 1.7 binaries, need to downgrade safeXcmVersion to V3 on relaychain
transfer 100.0 ROC from relay to itee
create DEX
everyone can create a pool, but that's ok as only two tokens exist so there can be only one pool
create pool for ROC/TEER
this will create a new LPT asset for the new pool, and it will create a new technical account we will call PoolReserve to hold the assets in the liq pool:
2PUnzrp5fQnwWJgoNexyUaysy4i7KN9MNDesMa1BdyyrAKar
you should see events
assets.Touched
PoolReservepoolAssets.ForceCreated
poolAssets.Touched
PoolReserveassetConversion.PoolCreated
add liquidity: 900 TEER + 25 ROC
you should see events:
system.NewAccount
PoolReservebalances.Transfer
Alice to PoolReserve 900 TEERassets.Transferred
Alice to PoolReserve 25 ROCpoolAssets.Issued
100 LPT to PoolReserve (guess this is meant as ED)poolAssets.Issued
149'999'999'999'900 LPT to AliceassetConversion.LiquidityAdded
swap exactly 10 TEER for a market rate of ROC
event:
assetConversion.SwapExecuted
: in : 10TEER, out: 273.910128905 mROCthe original exchange rate was 25/900 = 27.777
We sold TEER, so price of TEER went down and we get less ROC (CPMM slippage) 27.391...mROC/TEER
if we do the same again, we'll only get 26.79 mROC per TEER
also, there's an LPfee of 0.3% which stays in the PoolReserve
Alice withdraws her liquidity
Alice can't withdraw EVERYTHING, she must leave an existential amount
events:
balances.Transfer
from PoolReserve to Alice: 913.86.. TEERassets.Transferred
from PoolReserve to Alice: 24.265 ROCassetConversion.LiquidityRemoved
, burning 149.0 LPT