-
Notifications
You must be signed in to change notification settings - Fork 228
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
Separate fee into home fee and foreign fee #151
Changes from 3 commits
e1787e6
34a4960
b209667
b54cd53
78d6c3b
5a69e97
f9e3193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pragma solidity 0.4.24; | ||
|
||
|
||
contract FeeTypes { | ||
bytes32 internal constant HOME_FEE = keccak256(abi.encodePacked("home-fee")); | ||
bytes32 internal constant FOREIGN_FEE = keccak256(abi.encodePacked("foreign-fee")); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge, | |
uint256 valueToTransfer = msg.value; | ||
address feeManager = feeManagerContract(); | ||
if (feeManager != address(0)) { | ||
uint256 fee = calculateFee(valueToTransfer, false, feeManager); | ||
uint256 fee = calculateFee(valueToTransfer, false, feeManager, HOME_FEE); | ||
valueToTransfer = valueToTransfer.sub(fee); | ||
} | ||
setTotalBurntCoins(totalBurntCoins().add(valueToTransfer)); | ||
|
@@ -76,7 +76,8 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge, | |
uint256 _foreignMaxPerTx, | ||
address _owner, | ||
address _feeManager, | ||
uint256 _fee | ||
uint256 _homeFee, | ||
uint256 _foreignFee | ||
) public returns(bool) | ||
{ | ||
_initialize( | ||
|
@@ -93,7 +94,8 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge, | |
); | ||
require(isContract(_feeManager)); | ||
addressStorage[keccak256(abi.encodePacked("feeManagerContract"))] = _feeManager; | ||
_setFee(_feeManager, _fee); | ||
_setFee(_feeManager, _homeFee, HOME_FEE); | ||
_setFee(_feeManager, _foreignFee, FOREIGN_FEE); | ||
setInitialize(true); | ||
|
||
return isInitialized(); | ||
|
@@ -157,7 +159,7 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge, | |
|
||
address feeManager = feeManagerContract(); | ||
if (feeManager != address(0)) { | ||
uint256 fee = calculateFee(valueToMint, false, feeManager); | ||
uint256 fee = calculateFee(valueToMint, false, feeManager, FOREIGN_FEE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit messed up. Let's clarify this together one more time:
What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for clarification. Yes, that's my understanding too. I'll update documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed on b54cd53 |
||
distributeFeeFromAffirmation(fee, feeManager); | ||
valueToMint = valueToMint.sub(fee); | ||
} | ||
|
@@ -173,7 +175,7 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge, | |
bytes32 txHash; | ||
address contractAddress; | ||
(recipient, amount, txHash, contractAddress) = Message.parseMessage(_message); | ||
uint256 fee = calculateFee(amount, true, feeManager); | ||
uint256 fee = calculateFee(amount, true, feeManager, HOME_FEE); | ||
distributeFeeFromSignatures(fee, feeManager); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to move these methods to the corresponding implementations of the bridges:
erc20_to_native/RewardableHomeBridgeErcToNative.sol
:setHomeFee
setForeignFee
getHomeFee
getForeignFee
native_to_erc20/RewardableHomeBridgeNativeToErc.sol
setForeignFee
getForeignFee
native_to_erc20/RewardableForeignBridgeNativeToErc.sol
setHomeFee
getHomeFee
By doing this we would:
native-to-erc
mode.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree on the changes, this would help on making code easier to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 78d6c3b