Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Reward relayer on BH for S->E transfer #162

Closed

Conversation

yrong
Copy link

@yrong yrong commented Jul 23, 2024

No description provided.

Comment on lines 409 to +413
pub(crate) fn calculate_fee(
gas_used_at_most: u64,
params: PricingParameters<T::Balance>,
_gas_used_at_most: u64,
_params: PricingParameters<T::Balance>,
) -> Fee<T::Balance> {
// Remote fee in ether
let fee = Self::calculate_remote_fee(
gas_used_at_most,
params.fee_per_gas,
params.rewards.remote,
);

// downcast to u128
let fee: u128 = fee.try_into().defensive_unwrap_or(u128::MAX);

// multiply by multiplier and convert to local currency
let fee = FixedU128::from_inner(fee)
.saturating_mul(params.multiplier)
.checked_div(&params.exchange_rate)
.expect("exchange rate is not zero; qed")
.into_inner();

// adjust fixed point to match local currency
let fee = Self::convert_from_ether_decimals(fee);

Fee::from((Self::calculate_local_fee(), fee))
}

/// Calculate fee in remote currency for dispatching a message on Ethereum
pub(crate) fn calculate_remote_fee(
gas_used_at_most: u64,
fee_per_gas: U256,
reward: U256,
) -> U256 {
fee_per_gas.saturating_mul(gas_used_at_most.into()).saturating_add(reward)
Fee::from((Self::calculate_local_fee(), T::Balance::zero()))
Copy link
Author

Choose a reason for hiding this comment

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

Will remove price params on chain and the remote portion of the fee.

Comment on lines +440 to +441
T::Token::mint_into(&Self::account_id(), fee_amount)?;
}
Copy link
Author

Choose a reason for hiding this comment

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

Mint the fee(in DOT) to pallet account of OutboundQueue.

Comment on lines +263 to +266
/// Fee locked by message hash
#[pallet::storage]
pub type LockedFee<T: Config> = StorageMap<_, Twox64Concat, H256, u128, ValueQuery>;

Copy link
Author

@yrong yrong Jul 24, 2024

Choose a reason for hiding this comment

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

The storage map with Fee(in DOT) locked by MessageId.

Comment on lines +307 to +315
pub fn add_fees(
origin: OriginFor<T>,
message_id: H256,
fee_amount: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::lock_fee(message_id, fee_amount, Some(who))?;
Ok(())
}
Copy link
Author

Choose a reason for hiding this comment

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

Essentially just a transfer from the sender origin to the pallet account.

@yrong yrong changed the title Pay reward on BH Reward relayer on BH for S->E transfer Jul 30, 2024
@yrong yrong changed the title Reward relayer on BH for S->E transfer Reward relayer on BH for P->E transfer Jul 30, 2024
@yrong yrong changed the title Reward relayer on BH for P->E transfer Reward relayer on BH for S->E transfer Jul 30, 2024
@yrong yrong closed this Aug 22, 2024
@yrong yrong added the xcm label Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant