Skip to content

API endpoint to set a channel fee #4755

@rakanalh

Description

@rakanalh

Abstract

Currently, Raiden implements ActionChannelSetFee which is currently used when the --flat-fee and --proportional-fee CLI flags are used to set the fee amounts for all channels.

def _initialize_channel_fees(self) -> None:
""" Initializes the fees of all open channels to the latest set values.
This includes a recalculation of the dynamic rebalancing fees.
"""
chain_state = views.state_from_raiden(self)
fee_config: MediationFeeConfig = self.config["mediation_fees"]
token_addresses = views.get_token_identifiers(
chain_state=chain_state, token_network_registry_address=self.default_registry.address
)
for token_address in token_addresses:
channels = views.get_channelstate_open(
chain_state=chain_state,
token_network_registry_address=self.default_registry.address,
token_address=token_address,
)
for channel in channels:
# get the flat fee for this network if set, otherwise the default
flat_fee = fee_config.get_flat_fee(channel.token_network_address)
log.info(
"Updating channel fees",
channel=channel.canonical_identifier,
flat_fee=flat_fee,
proportional_fee=fee_config.proportional_fee,
proportional_imbalance_fee=fee_config.proportional_imbalance_fee,
)
state_change = actionchannelupdatefee_from_channelstate(
channel_state=channel,
flat_fee=flat_fee,
proportional_fee=fee_config.proportional_fee,
proportional_imbalance_fee=fee_config.proportional_imbalance_fee,
)
self.handle_and_track_state_changes([state_change])

def actionchannelupdatefee_from_channelstate(
channel_state: NettingChannelState,
flat_fee: FeeAmount,
proportional_fee: ProportionalFeeAmount,
proportional_imbalance_fee: ProportionalFeeAmount,
) -> ActionChannelUpdateFee:
imbalance_penalty = calculate_imbalance_fees(
channel_capacity=get_capacity(channel_state),
proportional_imbalance_fee=proportional_imbalance_fee,
)
return ActionChannelUpdateFee(
canonical_identifier=channel_state.canonical_identifier,
fee_schedule=FeeScheduleState(
flat=flat_fee, proportional=proportional_fee, imbalance_penalty=imbalance_penalty
),
)

There should be a way for the user to be able to set fee parameters for each channel individually and through the WebUI.

Specification

  • Implement an API endpoint which allows for setting the fee parameters similar to the code above.
  • Write new tests cover this new endpoint.
  • Create an issue in the WebUI repo to integrate this endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions