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

Update fee computation in coordinators #559

Merged

Conversation

martinkersner
Copy link
Member

@martinkersner martinkersner commented Apr 25, 2023

Description

This PR refactors VRFCoordinator and RequestResponseCoordinator to a more unified structure through CoordinatorBase.

  • Removed sMinBalance (use more precise computation)
  • Removed DirectPaymentConfig with its fulfillmentFee and baseFee
  • Removed reqCount for temporary account
  • Removed return value (payment) from fulfillment functions (cannot be accessed when executed through EOA anyway)
  • Added auxiliary function to compute commitments (computeCommitment - differs between VRF & RR)
  • Added numSubmission to Request-Response's RequestCommitment (replacing sRequestToNumSubmission)

VRF

VRF can be fulfilled by a single oracle only.

Regular Account

  • Request: Account balance is required to be above value returned from estimateTotalFee function that returns a sum of calculateServiceFee and maxGasCost (tx.gasprice * callbackGasLimit). Fee tier discount can be applied based on reqCount.
  • Fulfillment: Account is charged the amount equal to calculateServiceFee(reqCount) (fee tier discount can be applied based on reqCount) and calculateGasCost (tx.gasprice * (sConfig.gasAfterPaymentCalculation + actualGasUsed)).

Temporary Account

  • Request: Account balance is required to be above value returned from estimateTotalFee function that returns a sum of calculateServiceFee(reqCount) and maxGasCost (tx.gasprice * callbackGasLimit). Fee tier discount cannot be applied.

  • Fulfillment: Account is charged the $KLAY amount that was deposited during request.

Request-Response

Request-Response can be fulfilled by one or more oracles depending on the job type (jobId) and number of submissions (numSubmission).

Regular Account

  • Request: Account balance is required to be above value returned from estimateTotalFee function that returns a sum of calculateServiceFee(reqCount) * numSubmission and maxGasCost (tx.gasprice * callbackGasLimit). Consumer can request multiple submissions from oracles which leads to higher service fee that is proportional to numSubmission parameter specified by a consumer. Fee tier discount can be applied based on reqCount.
  • Fulfillment: Account is charged the amount equal to calculateServiceFee(reqCount) (fee tier discount can be applied based on reqCount) and calculateGasCost (tx.gasprice * (sConfig.gasAfterPaymentCalculation + actualGasUsed))

Temporary Account

  • Request: Account balance is required to be above value returned from estimateTotalFee function that returns a sum of calculateServiceFee(reqCount) * numSubmission and maxGasCost (tx.gasprice * callbackGasLimit). Consumer can request multiple submissions from oracles which leads to higher service fee that is proportional to numSubmission parameter specified by a consumer. Fee tier discount cannot be applied.

  • Fulfillment: Account is charged the $KLAY amount that was deposited during request.

Approximate Fee Distribution

Fees paid by Orakl Network consumers are distributed differently based on the account that was used to create a request. The approximate fee distribution is shown below.

  • Burn represents a portion of a fee that will be burnt
  • Oracle represents a portion of a fee that will be given to an EOA off-chain oracle that fulfilled request
  • Protocol represents a portion of a fee that will be given to Orakl Network for providing service

Regular Account

%%{init: {'theme': 'dark', 'themeVariables': { 'pie1': '#FFA500', 'pie2': '#ff0000', 'pie3': '#00FF00'}}}%%
pie title Service Fee Distribution
    "Oracle" : 45
    "Burn" : 50
    "Protocol" : 5
Loading
%%{init: {'theme': 'dark', 'themeVariables': { 'pie1': '#FFA500', 'pie2': '#ff0000', 'pie3': '#00FF00'}}}%%
pie title Gas Fee Distribution
    "Oracle" : 100
Loading

Temporary Account

%%{init: {'theme': 'dark', 'themeVariables': { 'pie1': '#FFA500', 'pie2': '#ff0000', 'pie3': '#00FF00'}}}%%
pie title Fee (Service + Gas) Distribution
    "Oracle" : 45
    "Burn" : 50
    "Protocol" : 5
Loading

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist before requesting a review

  • I have performed a self-review of my code.

@martinkersner martinkersner self-assigned this Apr 25, 2023
@martinkersner martinkersner linked an issue Apr 25, 2023 that may be closed by this pull request
@martinkersner martinkersner marked this pull request as ready for review April 25, 2023 14:51
@martinkersner martinkersner requested review from a team, bayram98 and KelvinThai as code owners April 25, 2023 14:51
@martinkersner martinkersner merged commit e3ef3b1 into master Apr 26, 2023
@martinkersner martinkersner deleted the i-555/feat/update-fee-computation-in-coordinators branch April 26, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update fee computation in coordinators
1 participant