R
R
RadixPlanet
Search
K

Customizable Fee Rules

At RadixPlanet when a new liquidity pool is created, a user can choose which fee rules are applied on swaps that take place in the future for that specific liquidity pool, of course a liquidity pool can have a mix of several fee rules with multiple various combinations
The user can create a fee rule by forming a combination of the following varieties:
  1. 1.
    Fee rule type:
    we have two rule types to choose from:
    1. 1.
      Percentage fee rule
      A percentage fee rule simply means that with every swap, a specific percentage (%) of the swap input tokens are charged as swap fee from them and dealt with based on the selected collection strategy
    2. 2.
      Fixed fee rule
      A fixed fee rule means that with every swap, a specific fixed amount of a specific token is charged regardless of the swap value itself, the swapper must provide this amount of the token as a fee or else the swap will fail
  2. 2.
    Collection Strategy:
    The collection strategy defines how the collected fees are actually collected, or more precisely what to do with those collected fees, there are multiple available options for this selection:
    1. 1.
      Add To Liquidity:
      A collections strategy of "Add To Liquidity" means that the collected fee will be added to the pool liquidity, meaning that the fee will be automatically reinvested into the pool itself
    2. 2.
      Add To Withdrawable Profits:
      A collection strategy of "Add To Withdrawable Profits" means that the collected fee will be set aside and accumulated on a completely separate vault for liquidity providers to withdraw as per their need, this option enables liquidity providers to periodically withdraw their earnings without affecting their initial investment
    3. 3.
      Add To Pool Manager Fees:
      A collection strategy of "Add To Pool Manager Fees" is only allowed for pools with "Private" liquidity, and it specifically allows the "Pool Manager" to get income for his role in managing the pool, as it mans that collected fee will be set aside and accumulated for the pool manager to withdraw whenever he needs
  3. 3.
    Token Resource Address
    The token of a fee rule is optional, primarily used for fixed fee rules to determine which token to collect the fee with with swaps, but it also can be used with percentages fee rules (although not yet possible through UI because it needs more testing), but if present with percentage fee rules, it will require an amount of that taken that is calculated based on the swap amount and the mid-price of the collected token at the time the swap happens, see this example:
    Imagine we have a pool with two tokens, $XRD and $Planet with liquidity 100, and 1000 respectively, and this pool have a percentage fee rule to collect 1% of swap amount but always collect them in $Planet, regardless what the input token is, so let's image a swap comes in which the swapper provides 20 $XRD to be swapped for $Planet, in order for the pool to determine the amount of $Planet to be collected as swap fee, it calculates the following:
    1. 1.
      $Planet mid-price prior to the trade with equals {$XRDAmount}/{$PlanetAmount} = 100/1000 = 0.1
    2. 2.
      The percentage value of the swap input tokens = {$XRDInputAmount} * {Percentage} = 20 * 1% = 0.2
    3. 3.
      Calculate $Planet amount to be collected as fee = {PercentageValue}/{$PlanetMid-Price} = 0.2/0.1 = 2 $Planet
    So in order for the swap to succeed, the swapper must provide 2 $Planet as swap fee along with the input tokens of 20 $XRD, or else the swap will fail
  4. 4.
    Value:
    The value determines what value to be applied with the fee rule, if the fee rule type is percentage, its it put as decimal value between 0 and 1 in the manifest (or between 0 and 100 in the UI which gets converted automatically), and if the fee rule type is fixed, the value means the amount that should be collected of the given token as a swap fee

Automatic Re-Investing

Automatic re-investing mainly means that there's a fee rule with collection strategy of "Add To Liquidity", hence the collected fee will be added to the pool liquidity, meaning that the fee will be automatically reinvested into the pool itself.

Withdrawable Earnings

Withdrawable earnings mainly means that there's a fee rule with collection strategy of "Add To Withdrawable Profits", hence the collected fee will be set aside and accumulated on a completely separate vault for liquidity providers to withdraw as per their need, this option enables liquidity providers to periodically withdraw their earnings without affecting their initial investment