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

Asset Hub: Asset Conversion and Swap Weight Trader #218

Merged

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Mar 5, 2024

Asset Conversion instance for Polkadot Asset Hub and XCM Swap Weight Trader for both Asset Hubs.

TODO:

@muharem muharem marked this pull request as draft March 5, 2024 17:46
@muharem muharem marked this pull request as ready for review March 6, 2024 11:48
@muharem
Copy link
Contributor Author

muharem commented Mar 6, 2024

@joepetrowski need your help to set there parameters:

  1. account deposit for pool assets
  2. pool setup fee
  3. liquidity withdrawal fee

I think we can have 0 for 1. if 2. is not 0. In Kusama both set as 0.

@joepetrowski
Copy link
Contributor

We decided to set both as 0 because all pairs must be against DOT, so the number of pools is limited by the number of assets linearly (one asset, one pool) as opposed to quadratically (any-to-any pools, N^2). Since asset creation requires a deposit, we decided that it would reasonably include having a pool fot it.

Liquidity withdrawal fee can also be 0, that only needs to be nonzero if any-to-any pools are allowed.

Copy link
Contributor

@joepetrowski joepetrowski left a comment

Choose a reason for hiding this comment

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

Some minor nits but looking good. One question, XCM V3 is used throughout, but since SDK v1.7.0 we are on XCM v4. Do these types need to be updated here?

I didn't look too closely at the bridge test cases. Would be good if @acatangiu can check those.

Comment on lines +18 to +19
// TODO: the types in the module copied from the PR: https://github.com/paritytech/polkadot-sdk/pull/3250
// and should be removed when changes from the PR will get released.
Copy link
Contributor

Choose a reason for hiding this comment

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

Link an issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am also collecting similar TODOs here: #186

system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs Outdated Show resolved Hide resolved
system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs Outdated Show resolved Hide resolved
system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs Outdated Show resolved Hide resolved
@acatangiu
Copy link
Contributor

Some minor nits but looking good. One question, XCM V3 is used throughout, but since SDK v1.7.0 we are on XCM v4. Do these types need to be updated here?

I didn't look too closely at the bridge test cases. Would be good if @acatangiu can check those.

Reviewed tests and all of them look good! Before finishing full review, I had an early question: are we adding the DEX/pools on both Kusama and Polkadot at the same time? I was under the impression Polkadot was to get it one release later than Kusama..

@joepetrowski
Copy link
Contributor

Reviewed tests and all of them look good! Before finishing full review, I had an early question: are we adding the DEX/pools on both Kusama and Polkadot at the same time? I was under the impression Polkadot was to get it one release later than Kusama..

This has been on Kusama for like 6 months :)

@acatangiu
Copy link
Contributor

This has been on Kusama for like 6 months :)

Ok, sorry, I posted the early question too early (before even looking at the runtimes code) :))

Copy link

@georgepisaltu georgepisaltu left a comment

Choose a reason for hiding this comment

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

LGTM

muharem and others added 2 commits March 11, 2024 11:33
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: Sergej Sakac <73715684+Szegoo@users.noreply.github.com>
@muharem
Copy link
Contributor Author

muharem commented Mar 11, 2024

@joepetrowski I have updated the deposits/fees. Plus for PoolAssets in Kusama Asset Hub, AssetAccountDeposit is updated from 0 to the same amount as in other Assets instances

Copy link
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

lgmt, just left a few nits to check

@@ -721,6 +425,77 @@ fn limited_reserve_transfer_assets_for_native_asset_to_asset_hub_polkadot_works(
)
}

#[test]
fn receive_reserve_asset_deposited_dot_from_asset_hub_polkadot_fees_paid_by_pool_swap_works() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

///
/// The `PoolId` is represented as a tuple of `AssetKind`s with `FirstAsset` always positioned
/// as the first element.
pub struct WithFirstAsset<FirstAsset, AccountId, AssetKind, AccountIdConverter>(
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the AssetHubKusama? It uses pallet_asset_conversion::WithFirstAsset, should we change it there also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only possible with migration, which will be available for the next release

parameter_types! {
pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon");
pub const LiquidityWithdrawalFee: Permill = Permill::from_percent(0);
pub const PoolSetupFee: Balance = system_para_deposit(1, 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

what about AssetHubKusama? There is still:

	type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam

shouldn't we change AHK also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set it as in polkadot

Comment on lines +18 to +19
// TODO: the types in the module copied from the PR: https://github.com/paritytech/polkadot-sdk/pull/3250
// and should be removed when changes from the PR will get released.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am also collecting similar TODOs here: #186

// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./asset-hub-kusama-weights
Copy link
Contributor

Choose a reason for hiding this comment

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

when merged, I will regenerate weights as a part of #223

@muharem
Copy link
Contributor Author

muharem commented Mar 13, 2024

@acatangiu can you please help with review

@joepetrowski joepetrowski mentioned this pull request Mar 15, 2024
19 tasks
type AssetDeposit = ConstU128<0>;
type AssetAccountDeposit = AssetAccountDeposit;
type MetadataDepositBase = ConstU128<0>;
type MetadataDepositPerByte = ConstU128<0>;
Copy link
Member

Choose a reason for hiding this comment

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

DQ but why are they zero?

Copy link
Contributor

Choose a reason for hiding this comment

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

Only the system (the AC pallet) can actually create assets within this instance of Assets, so only the system itself could actually create any assets and add any metadata.

@bkchr
Copy link
Contributor

bkchr commented Mar 18, 2024

@muharem is this ready to be merged?

@muharem
Copy link
Contributor Author

muharem commented Mar 18, 2024

@muharem is this ready to be merged?

yes

@muharem
Copy link
Contributor Author

muharem commented Mar 18, 2024

/merge

@fellowship-merge-bot
Copy link
Contributor

There was a problem running the action.

❌😵❌

Please find more information in the logs.

@bkchr
Copy link
Contributor

bkchr commented Mar 18, 2024

/merge

@fellowship-merge-bot
Copy link
Contributor

There was a problem running the action.

❌😵❌

Please find more information in the logs.

@bkchr bkchr merged commit 49c6d6d into polkadot-fellows:main Mar 18, 2024
31 of 32 checks passed
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.

9 participants