-
Notifications
You must be signed in to change notification settings - Fork 704
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 Conversion: Pool Touch Call #3251
Conversation
/bot help |
bot help |
Here's a link to docs |
bot bench substrate-pallet --pallet=pallet-asset-conversion |
@muharem option '--pallet ' argument 'pallet-asset-conversion' is invalid. argument pallet is not matching rule ^([a-z_]+)([:]{2}[a-z_]+)?$ |
bot bench substrate-pallet --pallet=pallet_asset_conversion |
@muharem https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5516365 was started for your command Comment |
…=dev --target_dir=substrate --pallet=pallet_asset_conversion
@muharem Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, a couple of comments.
@@ -32,6 +32,18 @@ pub trait Create<AccountId>: Inspect<AccountId> { | |||
) -> DispatchResult; | |||
} | |||
|
|||
/// Trait for refunding the deposit of a target asset account. | |||
pub trait Refund<AccountId> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be trait Refund<AccountId>: Inspect<AccountId>
to avoid defining AssetId
and Balance
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is more flexible, refund type do not have to implement the inspect trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a usecase where Refund
would be implemented on something other than the thing implementing Inspect
. Also, is there ever a usecase where Refund
has a different AssetId
and/or Balance
type than the underlying Inspect
fungibles impl? I think removing this type complexity is nice.
Also, all of the other traits in this file use Inspect
as a base. Same goes for the other traits in this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a usecase where
Refund
would be implemented on something other than the thing implementingInspect
.
Not likely in the context of the FRAME. I really see the point for super traits when some of the functions/methods used in a sub trait. But when need to decide convenience (no needs for type definition) vs flexibility (interface segregation), I will go for flexibility.
In this case it's not that important, perhaps Refund
wont need to be implemented on a type not implementing Inspect
. I am fine with super trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@georgepisaltu I had to set an additional bound to Currency type in Assets pallet for this. Please check and approve if you happy with it.
290c0f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however I do not see the benefits. in most cases you still have to define what Balance and AssetId are. and now you can not have a separate type implementing only refund.
/// Scalar type for representing balance of an account. | ||
type Balance: Balance; | ||
/// Returns the amount of account deposit and depositor address, if any. | ||
fn deposit_held(id: Self::AssetId, who: AccountId) -> Option<(AccountId, Self::Balance)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is unnecessary in the Refund
interface. Having fn refund
should be enough, the other fungibles
trait impls can be used to determine the deposits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fungibles
traits have no function to check the deposit held for an asset's account existence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was saying that fn deposit_held
is unnecessary in Refund
because:
- the usage below in
fn refund
doesn't use theBalance
parameter; in fact,fn refund
only cares about whether the caller is the depositor or if it's someone else (or no one) - aside from the use above which can clearly be refactored out, it's only used in benchmarks; we wouldn't even need to keep it with a benchmark feature gate because you would have access to the
Assets
pallet storage in the bench to check the deposit, but you could keep it around as a helper or something
fungibles
traits have no function to check the deposit held for an asset's account existence.
Again, seems it's unused functionality, but IMO even if fungibles
don't let you check this deposit, it doesn't feel like this functionality should belong in a Refund
trait. Maybe I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the example where it is used
https://github.com/paritytech/polkadot-sdk/pull/3250/files#diff-fbf88fab34bcf066e3c722cd1345365529c1c652df82604ba23aea4f047993d5R243
T::AssetsRefund::deposit_held(asset1.clone(), prior_account.clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was indeed missing something because that's from another PR 😁 .
I still feel this functionality for querying the deposit shouldn't be in a Refund
trait, but rather in some other parent interface to separate these concerns. In practical terms though, it doesn't matter too much. In the future, if we need to separate them, it will be very easy to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just querying the refund amount held can also be done with a Get<Option<(AssetID, AccountId)>>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case types like pallet, will implement a general Get trait, might be not enough to differentiate from other impls. I think the current way is better
} | ||
} | ||
fn refund(id: Self::AssetId, who: T::AccountId) -> DispatchResult { | ||
match Self::deposit_held(id.clone(), who.clone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling deposit_held
here only complicates things, especially because you don't care about the actual value of the deposit at this level, only if it is provided by someone else. It would be simpler to move the logic from deposit_held
above here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will duplicate that match and get from above. No strong opinion though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my argument was not convincing and you decide against removing fn deposit_held
, then there is no point in duplicating the logic here.
Review required! Latest push from author must always be reviewed |
|
||
impl< | ||
Left: fungible::Inspect<AccountId>, | ||
Right: fungibles::Inspect<AccountId> + fungibles::Refund<AccountId>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this adapter requiring heterogeneous types for Left and Right?
Why is the left side just assumed to not be Refund?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we ether assume there is no refund for fungible
, or we introduce a no-op impl for fungible
, which is balance pallet, with asset id ()
, or we have to introduce one more refund trait without asset id. Given this, I made a chose for no-op in adapter (no refund trait for fungible, no adapter for it). I am open to go for another solution, as I do not see an obvious winner here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt we will need refund for fungible
. I would prefer to introduce it if we need it in the future.
Introduce `touch` call designed to address operational prerequisites before providing liquidity to a pool. This function ensures that essential requirements, such as the presence of the pool's accounts, are fulfilled. It is particularly beneficial in scenarios where a pool creator removes the pool's accounts without providing liquidity. --------- Co-authored-by: command-bot <>
Introduce
touch
call designed to address operational prerequisites before providing liquidity to a pool.This function ensures that essential requirements, such as the presence of the pool's accounts, are fulfilled. It is particularly beneficial in scenarios where a pool creator removes the pool's accounts without providing liquidity.