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

Split implementations of FeeHandlerWithOracle #122

Closed
3 tasks
MakMuftic opened this issue Feb 10, 2023 · 2 comments
Closed
3 tasks

Split implementations of FeeHandlerWithOracle #122

MakMuftic opened this issue Feb 10, 2023 · 2 comments
Assignees

Comments

@MakMuftic
Copy link
Contributor

Separate fee handler with oracle contracts for evm, substrate, and generic message passing as separate implementations.

Implementation details

Currently, we have this logic inside FeeHandlerWithOracle:

if(oracleMessage.msgGasLimit > 0) {
    // txCost = dstGasPrice * oracleMessage.msgGasLimit * Base Effective Rate (rate between base currencies of source and dest)
    txCost = oracleMessage.dstGasPrice * oracleMessage.msgGasLimit * oracleMessage.ber / 1e18;
} else {
    // txCost = dstGasPrice * _gasUsed * Token Effective Rate (rate of dest base currency to token)
    txCost = oracleMessage.dstGasPrice * _gasUsed * oracleMessage.ter / 1e18;
}

that determines if the processed message (deposit request) is just a basic token transfer or a generic message (msgGasLimit > 0).

This approach allows users to do funky things like set this msgGasLimit when requesting fee data from fee oracle, but then execute erc20 token bridging with this fee data. I don't know how exactly this can be used for malicious behavior, but we should split this into two different implementations of FeeHandlerWithOracle. With this approach, we can map exact implementation based on resourceID and domains inside fee router and not even worry about how this can be used for malicious activity.

Testing details

  • Refactor and expand unit test

Acceptance Criteria

  • Have three different implementations of fee handler with oracle
  • Passing unit tests
@P1sar
Copy link
Contributor

P1sar commented Feb 10, 2023

We already have task for this. Or I am missing something?
#60
and PR
https://github.com/sygmaprotocol/sygma-solidity/pull/120/files

@viatrix
Copy link
Contributor

viatrix commented Feb 10, 2023

The issue #60 is just for Substrate. This issue also covers the generic message handling. I'll update the PR and reference this task in the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants