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

feat: add a cap for transfer fee #2022

Merged
merged 10 commits into from
Oct 30, 2023
15 changes: 12 additions & 3 deletions protocol/0057-TRAN-transfers.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Note: if there is no market with contribution to the reward metric - no transfer

A fee is taken from all transfers, and paid out to validators in a similar manner to the existing [infrastructure fees](0061-REWP-pos_rewards.md). For recurring transfers, the fee is charged each time the transfer occurs.

The fee is set by the `transfer.fee.factor` [network parameter](#network-parameters) that defines the proportion of each transfer taken as a fee.
The fee is determined by the `transfer.fee.factor` and is subject to a cap defined by the multiplier `transfer.fee.maxQuantumAmount` as specified in the network parameters, which governs the proportion of each transfer taken as a fee.
Jiajia-Cui marked this conversation as resolved.
Show resolved Hide resolved
The fee is taken from the transfer initiator's account immediately on execution, and is taken on top of the total amount transferred.
It is [paid in to the infrastructure fee pool](./0029-FEES-fees.md#collecting-and-distributing-fees).
Fees are charged in the asset that is being transferred.
Expand Down Expand Up @@ -217,6 +217,7 @@ message CancelTransfer {
| `spam.protection.maxUserTransfersPerEpoch` | String (integer) | strictly greater than `0` | `"20"` | The most transfers a use can initiate per epoch |
| `transfer.minTransferQuantumMultiple` | String (decimal) | greater than or equal to `0`| `"0.1"` | This, when multiplied by `quantum` (which is specified per asset) determines the minimum transfer amount |
| `transfer.fee.factor` | String (decimal) | in `[0.0,1.0]` | `"0.001"` | The proportion of the transfer charged as a fee |
| `transfer.fee.maxQuantumAmount` | String (decimal) | in `[0.0,1.0]` | `"0.001"` | The miltiplier of the transfer fee |

## Acceptance criteria

Expand All @@ -230,11 +231,16 @@ message CancelTransfer {
- As a user I cannot transfer funds from accounts I own but from the type is not supported:
- for accounts created in a futures market, bond and margin (<a name="0057-TRAN-006" href="#0057-TRAN-006">0057-TRAN-006</a>)
- for accounts created in a spot market, bond and holding (<a name="0057-TRAN-063" href="#0057-TRAN-063">0057-TRAN-063</a>)
- As a user I can do a transfer from any of the valid accounts (I control them and they're a valid source), and fees are taken from the source account when the transfer is executed. (<a name="0057-TRAN-007" href="#0057-TRAN-007">0057-TRAN-007</a>)
- As a user I can do a transfer from any of the valid accounts (I control them and they're a valid source), and fees are taken from the source account when the transfer is executed (when `transfer.fee.maxQuantumAmount` = 1). (<a name="0057-TRAN-007" href="#0057-TRAN-007">0057-TRAN-007</a>)
- The fee cost is correctly calculated using the network parameter
- If I have enough funds to pay transfer and fees, the transfer happens.
- If I do not have enough funds to pay transfer and fees, the transfer is cancelled.
- The fees are being paid into the infrastructure pool
- As a user I can do a transfer from any of the valid accounts (I control them and they're a valid source), and fees are taken from the source account when the transfer is executed (when `transfer.fee.maxQuantumAmount` = 0.02). (<a name="0057-TRAN-011" href="#0057-TRAN-011">0057-TRAN-011</a>)
- The fee cost is correctly calculated using the network parameter `transfer.fee.Maxfactor`
- If I have enough funds to pay transfer and fees, the transfer happens.
- If I do not have enough funds to pay transfer and fees, the transfer is cancelled.
- The fees are being paid into the infrastructure pool
- As a user, when I initiate a delayed transfer, the funds are taken from my account immediately (<a name="0057-TRAN-008" href="#0057-TRAN-008">0057-TRAN-008</a>)
- The funds arrive in the target account when the transaction is processed (i.e. with the correct delay), which is not before the timestamp occurs
- A delayed transfer that is invalid (to an invalid account type) is rejected when it is received, and the funds are not taken from the origin account.
Expand All @@ -256,7 +262,7 @@ As a user I can create a recurring transfer _that decreases over time_ (<a name=
- I specify a start and end epoch, and a factor of `0.7`
- Until the start epoch is reached not transfers are executed
- Once I reach the start epoch transfers happen and the first transfer is for the `start amount`. The fee amount taken from the source account is `start amount x transfer.fee.factor` and transferred to the infrastructure fee account for the asset.
- The transfer at end of `start epoch + 1` is `0.7 x start amount` and the fee amount is `0.7 x start amount x transfer.fee.factor`.
- The transfer at end of `start epoch + 1` is `0.7 x start amount` and the fee amount is `0.7 x start amount x transfer.fee.factor x transfer.fee.maxQuantumAmount`.
- The amount transferred every epoch decreases.
- After I reach the epoch `?`, no transfers are executed anymore

Expand Down Expand Up @@ -313,6 +319,9 @@ A user's recurring transfer to a reward account does not occur if there are no p
If the network parameter `transfer.fee.factor` is modified, this modification is applied
immediately, i.e., transfers are accepted/rejected according to the new parameter. This holds for both increase and decrease. (<a name="0057-TRAN-062" href="#0057-TRAN-062">0057-TRAN-062</a>)

If the network parameter `transfer.fee.maxQuantumAmount` is modified, this modification is applied
immediately, i.e., transfers are accepted/rejected according to the new parameter. This holds for both increase and decrease. (<a name="0057-TRAN-064" href="#0057-TRAN-064">0057-TRAN-064</a>)

If the network parameter `spam.protection.maxUserTransfersPerEpoch` is modified, this modification is applied immediately, i.e., transfers are accepted/rejected according to the new parameter. This holds for both increase and decrease. In the case of a decrease, existing recurring transfers are not cancelled. (<a name="0057-TRAN-060" href="#0057-TRAN-060">0057-TRAN-060</a>)

If the network parameter `transfer.minTransferQuantumMultiple` is modified, this modification is applied
Expand Down