Skip to content

Commit

Permalink
chore: change default simple UDT fee rate to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Dec 28, 2021
1 parent afe5f77 commit 770645e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub struct FeeConfig {
/// HashMap<sudt_id, fee rate weight>
///
/// adjusted fee_rate: fee_rate * weight / 1000
/// if sudt_id is not in the map, the weight is 1000
/// if sudt_id is not in the map, the weight is 0
pub sudt_fee_rate_weight: HashMap<Uint32, u64>,
}

Expand Down
7 changes: 4 additions & 3 deletions crates/mem-pool/src/fee/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use gw_types::{
use std::{cmp::Ordering, convert::TryInto};

const FEE_RATE_WEIGHT_BASE: u64 = 1000;
const DEFAULT_SUDT_FEE_RATE: u64 = 0;

#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub enum FeeItemKind {
Expand Down Expand Up @@ -166,7 +167,7 @@ fn parse_withdraw_fee_rate(
.sudt_fee_rate_weight
.get(&sudt_id.into())
.cloned()
.unwrap_or(FEE_RATE_WEIGHT_BASE);
.unwrap_or(DEFAULT_SUDT_FEE_RATE);
let fee_amount: u128 = fee.amount().unpack();
let fee_rate = fee_amount
.saturating_mul(fee_rate_weight.into())
Expand Down Expand Up @@ -198,7 +199,7 @@ fn parse_l2tx_fee_rate(
.sudt_fee_rate_weight
.get(&sudt_id.into())
.cloned()
.unwrap_or(FEE_RATE_WEIGHT_BASE);
.unwrap_or(DEFAULT_SUDT_FEE_RATE);

// fee rate = fee / cycles_limit * (weight / FEE_RATE_WEIGHT_BASE)
let fee_rate = fee_amount
Expand Down Expand Up @@ -226,7 +227,7 @@ fn parse_l2tx_fee_rate(
.sudt_fee_rate_weight
.get(&sudt_id.into())
.cloned()
.unwrap_or(FEE_RATE_WEIGHT_BASE);
.unwrap_or(DEFAULT_SUDT_FEE_RATE);

// fee rate = fee / cycles_limit * (weight / FEE_RATE_WEIGHT_BASE)
let fee_rate = fee_amount
Expand Down

0 comments on commit 770645e

Please sign in to comment.