Example FeeContract Interactions
Last updated
Last updated
In this section, we provide detailed, real-world scenarios that demonstrate how application fees are set, collected, and distributed using the FeeContract. These examples will give you a clearer understanding of how the contract functions in practical situations.
Scenario: The Fee Oracle suggests a change in the base application fee due to market fluctuations.
Initial Setting:
Initially, the base fee (_fee
) is set to 10 tokens as per the Fee Oracle's directive.
Developers can set their service fees within a range determined by _minDevFeeMultiple = 1
and _maxDevFeeMultiple = 3
.
Updating the Fee:
The Fee Oracle updates its directive to 12 tokens due to changing network conditions.2
The updateFee()
function is called, and _fee
is now updated to 12 tokens.
Now, developers can charge a minimum of 12 tokens and a maximum of 36 tokens for their services.
Scenario: A developer wants to set a fee for their new blockchain application.
Determining the Fee:
The current base application fee (_fee
) is 12 tokens.
The developer decides to set their service fee at 2.5 times the base fee.
Calculating the Service Fee:
The service fee is calculated as
tokens.
This fee is within the allowed range set by the FeeContract (12 to 36 tokens
), so it is a valid fee for the developer to charge.
Scenario: The FeeContract has collected fees and is ready to distribute them among different channels.
Fee Accumulation:
Assume the FeeContract has collected a total of 1000 tokens in application fees over a period.
Channel Setup:
There are three channels set up for fee distribution with the following weights: Channel A (weight = 1), Channel B (weight = 2), Channel C (weight = 3).
Distribution Calculation:
Share of each channel:
Executing the Distribution:
The distributeFees()
function is called.
Each channel receives its respective share of the total collected fees based on its weight.
Scenario: The base fee needs an update, but there is a grace period to accommodate users' adaptation to the new fee.
Initial Fee Update:
The Fee Oracle suggests increasing the base fee from 12 to 15 tokens.
The updateFee()
function is called, and _fee
is set to 15 tokens.
Grace Period Implementation:
A predefined grace period, such as 600 blocks or approximately 50 minutes, is established, allowing transactions to continue utilizing the old fee during this transition phase.
During this period, a contract interacting with the FeeContract can use the old fee (12 tokens) or the new fee (15 tokens), whichever is lower.
Post-Grace Period:
After the grace period ends, all transactions must use the new fee (15 tokens).
These examples provide a snapshot of various functionalities within the FeeContract, illustrating the practical application of settings, updates, and processes related to managing application fees.
Total weights combined: shares.
Channel A: tokens.
Channel B: tokens.
Channel C: tokens.