-
Notifications
You must be signed in to change notification settings - Fork 83
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
Mandatory replace requests #823
Comments
If we want mandatory replace requests, we can simplify replaces a lot by removing the |
Yes, I think that is ideal. |
I think the following steps need to be done. A problem is that by making replace request originate from the old_vault, we can't supply a btc address as argument. Instead, we'll have to generate one like we do for issue, which does mean the client needs changes as well.
It's quite an involved change.. I'd like to have a think about if we can re-use the issue/redeem logic, as essentially the old-vault is making an issue with the new_vault, while the new_vault is making a redeem with the old_vault |
Why not? Do you mean from a UX perspective? In that case we can just use the master key which is already in the Vault's wallet. Otherwise the change is as you describe, basically refactor |
The master key is per account_id, not per vault_id though, so it's not part of the vault's currency-specific wallet |
Had a discussion with @sander2, we believe the best way forward is to re-use the issue and redeem logic. @nakul1010 hold-off on the implementation for now until we've had a chance to review the design. |
We will refactor the
Some very rough code as a guide: #[pallet::storage]
pub(super) type Requests<T: Config> = StorageMap<_, Blake2_128Concat, H256, H256>;
fn request_replace(
old_vault_id: DefaultVaultId<T>,
new_vault_id: DefaultVaultId<T>,
amount: BalanceOf<T>,
) {
// Vault B increases to_be_issued
let (issue_id, btc_address) = Issue::request_issue(
new_vault_id, // account to receive BTC
amount, // amount of BTC
);
// Vault A increases to_be_redeemed
let redeem_id = Redeem::request_redeem(
old_vault_id, // account to send BTC
btc_address, // owned by Vault B
amount, // amount of BTC
);
Requests::insert(redeem_id, issue_id);
}
fn execute_replace(
redeem_id: H256,
unchecked_transaction: FullTransactionProof,
) {
// Vault A decreases to_be_redeemed (and issued_tokens)
Redeem::execute_redeem(redeem_id, unchecked_transaction);
let issue_id = Requests::take(redeem_id);
// Vault B decreases to_be_issued
// Vault B increases issued_tokens
Issue::complete_issue(issue_id);
} Both extrinsics are submitted by the We should hence remove any unused replace code including storage items, events and extrinsics. We can also remove To disallow the other "execute" extrinsics (and generally make merging this into issue / redeem easier) it might be worth considering altering the enum AccountOrVault<AccountId, CurrencyId> {
Account(AccountId),
Vault(VaultId<AccountId, CurrencyId>)
} |
Hmm I'm not completely convinced by this approach - both on the parachain side and on the client side this needs special handling. If we go with the issue/redeem approach, then I think for the vault client they should appear as normal issue/redeems. So the old_vault would execute by calling |
Otherwise if we're ok with special handling on vault side then we might as well keep the current approach of having a special |
We had a call to discuss the approach and I think we are in agreement. Let's still remove the pub struct IssueRequest {
...
pub requester: AccountOrVault,
}
pub struct RedeemRequest {
...
pub redeemer: AccountOrVault,
pub issue_id: Option<H256>,
} We can add the |
Yup agreed, just a small note that we don't need the |
Is your feature request related to a problem? Please describe.
Any vault that provides unused mint capacity is subject to the ‘risk’ of receiving an issue request that can fill up all its remaining mint capacity. Hence, a replace request by another vault is nothing else than an issue request by a user (and hence should charge the same fees) but helps vaults at risk to mitigate liquidations.
Describe the solution you'd like
If a vault can request a replace by another vault with certainty, there is much lower risk of getting liquidated. If the vault which is supposed to replace the original vault has an option to decline this request, that option of risk mitigation becomes quite meaningless.
Additional context
We can achieve this functionality without changing too much in the replace core model.
The text was updated successfully, but these errors were encountered: