Skip to content

Commit

Permalink
delete multiweighttraders (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
herryho authored Oct 11, 2021
1 parent f2fa15e commit 249ea05
Showing 1 changed file with 0 additions and 89 deletions.
89 changes: 0 additions & 89 deletions runtime/common/src/xcm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,92 +187,3 @@ impl Convert<AccountId, MultiLocation> for BifrostAccountIdToMultiLocation {
X1(AccountId32 { network: NetworkId::Any, id: account.into() }).into()
}
}

// The implementation of multiple fee trader
pub struct MultiWeightTraders<KsmTrader, BncTrader, KarTrader, KusdTrader, VsksmTrader> {
ksm_trader: KsmTrader,
bnc_trader: BncTrader,
kar_trader: KarTrader,
kusd_trader: KusdTrader,
vsksm_trader: VsksmTrader,
}

impl<
KsmTrader: WeightTrader,
BncTrader: WeightTrader,
KarTrader: WeightTrader,
KusdTrader: WeightTrader,
VsksmTrader: WeightTrader,
> WeightTrader for MultiWeightTraders<KsmTrader, BncTrader, KarTrader, KusdTrader, VsksmTrader>
{
fn new() -> Self {
Self {
ksm_trader: KsmTrader::new(),
bnc_trader: BncTrader::new(),
kar_trader: KarTrader::new(),
kusd_trader: KusdTrader::new(),
vsksm_trader: VsksmTrader::new(),
// dummy_trader: DummyTrader::new(),
}
}
fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> {
if let Ok(assets) = self.ksm_trader.buy_weight(weight, payment.clone()) {
return Ok(assets);
}

if let Ok(assets) = self.bnc_trader.buy_weight(weight, payment.clone()) {
return Ok(assets);
}

if let Ok(assets) = self.kar_trader.buy_weight(weight, payment.clone()) {
return Ok(assets);
}

if let Ok(assets) = self.kusd_trader.buy_weight(weight, payment.clone()) {
return Ok(assets);
}

if let Ok(assets) = self.vsksm_trader.buy_weight(weight, payment) {
return Ok(assets);
}

// if let Ok(asset) = self.dummy_trader.buy_weight(weight, payment) {
// return Ok(assets)
// }

Err(XcmError::TooExpensive)
}

fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
if weight.is_zero() {
None
} else {
let ksm = self.ksm_trader.refund_weight(weight);
if ksm.is_some() {
return ksm;
}

let bnc = self.bnc_trader.refund_weight(weight);
if bnc.is_some() {
return bnc;
}

let kar = self.kar_trader.refund_weight(weight);
if kar.is_some() {
return kar;
}

let kusd = self.kusd_trader.refund_weight(weight);
if kusd.is_some() {
return kusd;
}

let vsksm = self.kusd_trader.refund_weight(weight);
if vsksm.is_some() {
return vsksm;
}

None
}
}
}

0 comments on commit 249ea05

Please sign in to comment.