-
Notifications
You must be signed in to change notification settings - Fork 49
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
SOV-4106 Feat: Fee sharing collector with direct transfer #548
base: bobDevelopment
Are you sure you want to change the base?
Conversation
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.
Generally LGTM, added a couple of comments about concerns:
- Changing the native token address constant value is a possible footgun if the contract is updated on RSK
- Make sure changing the ABI doesn't break frontend / backend!
- I don't understand how it worked before the onlyExecution modifier was added, but I probably just missed something
contracts/governance/FeeSharingCollector/FeeSharingCollector.sol
Outdated
Show resolved
Hide resolved
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.
pls see inline comments
contracts/governance/FeeSharingCollector/FeeSharingCollector.sol
Outdated
Show resolved
Hide resolved
// We will change, so that feeSharingCollector will directly burn then loanToken (IWRBTC) to rbtc and send to the user --- by call burnToBTC function | ||
ILoanTokenWRBTC(_token).burnToBTC(_receiver, amount, false); | ||
if (loanWrappedNativeTokenAddress == _token) { | ||
// We will change, so that feeSharingCollector will directly burn then loanWrappedNativeToken (IWrappedNativeToken) to nativeToken and send to the user --- by call burnToBTC function |
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.
// We will change, so that feeSharingCollector will directly burn then loanWrappedNativeToken (IWrappedNativeToken) to nativeToken and send to the user --- by call burnToBTC function | |
// We will change, so that feeSharingCollector will directly burn then loanWrappedNativeToken (IWrappedNativeToken) to nativeToken and send to the user --- by call burnToBTC function which is burning to a native token - to be renamed to burnedToNativeToken |
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.
addressed in this commit
} else { | ||
// Previously it directly send the loanToken to the user | ||
// Previously it directly send the loanWrappedNativeToken to the user |
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.
why is the loanToken renamed to loanWrappedNativeToken?
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.
it was accidentally replaced, reverted back in this addressed in this commit
* the fees (except SOV) will be converted in wRBTC form, and then will be transferred to wRBTC loan pool. | ||
* For SOV, it will be directly deposited into the FeeSharingCollectorMultipleToken from the protocol. |
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.
* the fees (except SOV) will be converted in wRBTC form, and then will be transferred to wRBTC loan pool. | |
* For SOV, it will be directly deposited into the FeeSharingCollectorMultipleToken from the protocol. |
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.
addressed
); | ||
} | ||
|
||
uint256 wrbtcAmountWithdrawn = protocol.withdrawFees(_tokens, address(this)); |
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.
why does this multitoken implementation doesn't have RBTC
mentions renamed to native token
?
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.
addressed
} | ||
|
||
/** | ||
* @notice Withdraw fees from sovryn dex: |
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.
* @notice Withdraw fees from sovryn dex: | |
* @notice Withdraw fees from Sovryn DEX |
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.
no longer valid
|
||
if (loanWrappedNativeToken == _token) { | ||
// We will change, so that FeeSharingCollectorMultipleToken will directly burn then loanToken (IWRBTC) to rbtc and send to the user --- by call burnToBTC function | ||
uint256 loanAmountPaid = ILoanWrappedNativeToken(_token).burnToBTC( |
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.
unused variable
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.
addressed
false | ||
); | ||
} else { | ||
// Previously it directly send the token to the user |
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.
that's what it does now
// Previously it directly send the token to the user |
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.
addressed
* | ||
* @param _tokens array addresses of the tokens | ||
* */ | ||
function withdrawFeesFromDex(address[] memory _tokens) public { |
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.
missing tests for this function
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.
no longer valid
require(_amount > 0, "FeeSharingCollectorMultipleToken::transferTokens: invalid amount"); | ||
|
||
/// @notice Transfer tokens from msg.sender | ||
bool success = IERC20(_token).transferFrom(address(msg.sender), address(this), _amount); |
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.
it will fail when processing the native token - should check the value payload and process separately.
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 don't think the initial function of transferTokens here is supporting native token?
|
||
/** | ||
* @notice Transfer tokens to this contract. | ||
* @dev We just update amount of tokens here and write checkpoint in a separate methods |
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.
pls add a @dev note that the caller should take care of setting allowance for the token
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.
addressed
contract FeeSharingCollectorMultiToken is | ||
SafeMath96, | ||
IFeeSharingCollectorMultiToken, | ||
Ownable, |
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.
Using Ownable instead of OwnableUpgradeable, but I discussed with Cowsant that this has been the norm for upgradeable contracts.
* | ||
* @param _tokens array address of the token | ||
* */ | ||
function withdrawFees(address[] memory _tokens) public { |
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.
Is there any risk in this being public and re-entrant? Also this function doesn't validate _tokens
, but maybe it happens in protocol.withdrawFees
?
* the fees will be converted in wrappedNativeToken form, and then will be transferred to wrappedNativeToken loan pool | ||
* | ||
* */ | ||
function withdrawFeesFromLBDex() public { |
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.
Any risk with this being public and re-entrant?
|
||
/// @notice Transfer tokens from msg.sender | ||
bool success = IERC20(_token).transferFrom(address(msg.sender), address(this), _amount); | ||
require(success, "Staking::transferTokens: token transfer failed"); |
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.
Staking::transferTokens
? Should this be FeeSharingCollectorMultiToken::transferTokens
?
sender: root, | ||
token: loanWrappedNativeToken.address, | ||
amount: new BN(0), | ||
}); |
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.
@cwsnt this test seems weird: shouldn't we have an "expectRevert" checking here, instead of an event of a successful tx?
); | ||
}); | ||
|
||
it("Shouldn't be able to withdraw zero amount", async () => { |
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.
@cwsnt Wrong test description. Instead of "Shouldn't be able to withdraw zero amount", should say: "Shouldn't be able to withdraw above available"
No description provided.