Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change default simple UDT fee rate to 0 #517

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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