Skip to content

Commit

Permalink
feat: added MintTokensForReimbursedRedeem event
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed May 24, 2021
1 parent 5d0df77 commit 38e7289
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/redeem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ decl_event!(
ExecuteRedeem(H256, AccountId, Wrapped, Wrapped, AccountId),
// [redeem_id, redeemer, vault_id, slashing_amount_in_collateral, reimburse]
CancelRedeem(H256, AccountId, AccountId, Collateral, bool),
// [vault_id, redeem_id, amount_minted]
MintTokensForReimbursedRedeem(AccountId, H256, Wrapped),
}
);

Expand Down Expand Up @@ -229,8 +231,8 @@ decl_module! {
fn mint_tokens_for_reimbursed_redeem(origin, redeem_id: H256)
-> DispatchResult
{
let redeemer = ensure_signed(origin)?;
Self::_mint_tokens_for_reimbursed_redeem(redeemer, redeem_id)?;
let vault = ensure_signed(origin)?;
Self::_mint_tokens_for_reimbursed_redeem(vault, redeem_id)?;
Ok(())
}
}
Expand Down Expand Up @@ -485,7 +487,7 @@ impl<T: Config> Module<T> {
// first update the issued tokens; this logic is the same regardless of whether or not the vault is liquidated
if reimburse {
// Transfer the transaction fee to the pool. Even though the redeem was not
// successful, the user receives a premium in collateral, so it's to take the fee.
// successful, the user receives a premium in collateral, so it's OK to take the fee.
ext::treasury::unlock_and_transfer::<T>(
redeem.redeemer.clone(),
ext::fee::fee_pool_account_id::<T>(),
Expand Down Expand Up @@ -556,7 +558,13 @@ impl<T: Config> Module<T> {
ext::vault_registry::issue_tokens::<T>(&vault_id, reimbursed_amount)?;
ext::treasury::mint::<T>(vault_id, reimbursed_amount);

Self::set_redeem_status(redeem_id, RedeemRequestStatus::Completed);
Self::set_redeem_status(redeem_id, RedeemRequestStatus::Reimbursed(true));

Self::deposit_event(<Event<T>>::MintTokensForReimbursedRedeem(
vault_id,
redeem_id,
amount_wrapped,
));

Ok(())
}
Expand Down

0 comments on commit 38e7289

Please sign in to comment.