An important part of router operations is the capability to charge fees. Routers incur costs in the form of server costs, onchain transaction costs, collateral costs, and other maintenance overhead. Routers can charge to forward transfers to recoup costs and turn a profit. Routers can charge two types of fees: static fees (flat or percentage) and dynamic fees.
The typical user flow for fees will look like:
getTransferQuote is used for the purposes of showing the user the estimated fees so they consent to the transfer. If the transfer is sent without the fee quote in the meta, the fee will automatically be applied at the time of the transfer.
Fees where the transfer amount is less than the quoted fee will error on the client side.
Percentage fees are charged as a percentage of the total transfer value that is being transferred. The amount will be subtracted from the total received on the receiver's channel.
Flat fees are a static value, denominated in the sender asset. The amount will be subtracted from the total received on the receiver's channel.
Dynamic fees take into account the total Ethereum mainnet gas costs that the router will spend forwarding a transaction. The costs considered are:
These costs are added up and converted into the sending currency, and subtracted from the total received on the receiver's channel.
The following configuration options are available for fees:
The following router.config.json will take a base fee plus a percentage fee and dynamic fees on all swaps.
The following router.config.json will subsidize transfers from ETH to Matic but charge fees on the way out.