Skip to content

Commit

Permalink
Revert "simulate exchange rate (#1742)" (#1746)
Browse files Browse the repository at this point in the history
This reverts commit cbb484b.
  • Loading branch information
Frank Yin authored Jan 4, 2022
1 parent cbb484b commit d0bacd0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use module_currencies::{BasicCurrencyAdapter, Currency};
use module_evm::{CallInfo, CreateInfo, EvmTask, Runner};
use module_evm_accounts::EvmAddressMapping;
use module_relaychain::RelayChainCallBuilder;
use module_support::{AssetIdMapping, DispatchableTask};
use module_support::{AssetIdMapping, DispatchableTask, ExchangeRateProvider};
use module_transaction_payment::{Multiplier, TargetedFeeAdjustment, TransactionFeePoolTrader};
use scale_info::TypeInfo;

Expand Down Expand Up @@ -1846,21 +1846,17 @@ impl orml_tokens::ConvertBalance<Balance, Balance> for ConvertBalanceHoma {
type AssetId = CurrencyId;

fn convert_balance(balance: Balance, asset_id: CurrencyId) -> Balance {
let current_block = System::block_number();
let exchange_rate =
ExchangeRate::checked_from_rational(current_block, 3_000_000u128).unwrap_or_else(DefaultExchangeRate::get);
match asset_id {
CurrencyId::Token(TokenSymbol::LKSM) => exchange_rate.checked_mul_int(balance).unwrap_or_default(),
CurrencyId::Token(TokenSymbol::LKSM) => {
Homa::get_exchange_rate().checked_mul_int(balance).unwrap_or_default()
}
_ => balance,
}
}

fn convert_balance_back(balance: Balance, asset_id: CurrencyId) -> Balance {
let current_block = System::block_number();
let exchange_rate =
ExchangeRate::checked_from_rational(current_block, 3_000_000u128).unwrap_or_else(DefaultExchangeRate::get);
match asset_id {
CurrencyId::Token(TokenSymbol::LKSM) => exchange_rate
CurrencyId::Token(TokenSymbol::LKSM) => Homa::get_exchange_rate()
.reciprocal()
.unwrap_or_default()
.checked_mul_int(balance)
Expand Down

0 comments on commit d0bacd0

Please sign in to comment.