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

Define and implement Hold for Assets #4315

Open
1 task
pandres95 opened this issue Apr 28, 2024 · 5 comments · May be fixed by #4530
Open
1 task

Define and implement Hold for Assets #4315

pandres95 opened this issue Apr 28, 2024 · 5 comments · May be fixed by #4530
Labels
I5-enhancement An additional feature request.

Comments

@pandres95
Copy link
Contributor

pandres95 commented Apr 28, 2024

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

A follow-up of #3342. The current design of pallet-assets doesn't implement holds, while there are multiple use cases for which it would be beneficial to support this behaviour (e.g. bonding, staking, deposits, payment holds, escrowed vesting, etc.).

Request

Because of the above, it is desirable to find a way of implementing inspection and mutation of the fungibles::holds traits.

Solution

A basic definition and implementation of a HeldBalance (an analogous to FrozenBalance) that can be added as a type in pallet-assets.

pub trait HeldBalance<AssetId, AccountId, Balance> {
    // Required methods
    fn held_balance(asset: AssetId, who: &AccountId) -> Option<Balance>;
    fn died(asset: AssetId, who: &AccountId);
}

Then, by using the held_balance method in Assets, it would be possible to subtract the free balance to obtain the reducible_balance, and adjust to the balance components model.

Analogous to pallet-assets-freezer, this proposed pallet extends the capabilities of pallet-assets to support holding balances.

Are you willing to help with this request?

Yes!

Tasks

@pandres95 pandres95 added the I5-enhancement An additional feature request. label Apr 28, 2024
@pandres95
Copy link
Contributor Author

Quick question before proceeding with the proposed implementation: after taking a review on #236, I noticed that (at least for fungible tokens) it is expected that holds are not overlapped with free balance, while frozen may be applied to the total balance (including held balances).

This leads me to think the reducible_balance for an asset account should be calculated as total - max(frozen, held).

Is this assumption correct @gavofyork, or does this concept only for fungible tokens?

@pandres95 pandres95 linked a pull request May 21, 2024 that will close this issue
@Polkadot-Forum
Copy link

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/2024-05-21-technical-fellowship-opendev-call/8264/1

@muharem
Copy link
Contributor

muharem commented Jul 25, 2024

Quick question before proceeding with the proposed implementation: after taking a review on #236, I noticed that (at least for fungible tokens) it is expected that holds are not overlapped with free balance, while frozen may be applied to the total balance (including held balances).

This leads me to think the reducible_balance for an asset account should be calculated as total - max(frozen, held).

Is this assumption correct @gavofyork, or does this concept only for fungible tokens?

there is an issue explaining these relations. you should look for the PR introducing new fungible/s traits. should be linked there.

@Polkadot-Forum
Copy link

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/assethub-new-feature-bond-with-specific-unbond-period/7494/3

@Polkadot-Forum
Copy link

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/2024-07-16-technical-fellowship-opendev-call/9512/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I5-enhancement An additional feature request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants