-
Notifications
You must be signed in to change notification settings - Fork 48
SOV-4106 Feat: Fee sharing collector with direct transfer #548
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
Open
cwsnt
wants to merge
15
commits into
bobDevelopment
Choose a base branch
from
feeSharingCollector-with-direct-transfer
base: bobDevelopment
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0dff045
init: refactor feeSharingCollector
df9644a
add withdrawFeesFromDex function
a15d0ad
fix: unit test
cd3cfe7
add check in unit test
b931a51
init: feeSharingCollectorMultipleToken
d8ef7a6
revert old feeSharingCollector
7594a8b
ran prettier
8a5a980
1/ address comment review
8778ed7
change tokens withdraw interaction
cacbe79
ran prettier
084dd92
feat: update for the lb dex integration
6a0158b
removed unused contract
5bf61d6
update vesting creation with new schedule
tjcloa 02e1704
addressed unresolved comments
1a4823e
2/ addressed unresolved comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
440 changes: 212 additions & 228 deletions
440
contracts/governance/FeeSharingCollector/FeeSharingCollector.sol
Large diffs are not rendered by default.
Oops, something went wrong.
646 changes: 646 additions & 0 deletions
646
contracts/governance/FeeSharingCollector/FeeSharingCollectorMultiToken.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| pragma solidity ^0.5.17; | ||
|
|
||
| /** | ||
| * @title Interface for contract governance/FeeSharingCollector/FeeSharingCollector.sol | ||
| * @dev Interfaces are used to cast a contract address into a callable instance. | ||
| * */ | ||
| interface IFeeSharingCollectorMultiToken { | ||
| function withdrawFees(address[] calldata _token) external; | ||
|
|
||
| function transferTokens(address _token, uint96 _amount) external; | ||
|
|
||
| function withdraw(address _token, uint32 _maxCheckpoint, address _receiver) external; | ||
|
|
||
| function withdrawTokens( | ||
| address[] calldata _tokens, | ||
| uint32[] calldata _maxCheckpoints, | ||
| address _receiver | ||
| ) external; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| pragma solidity 0.5.17; | ||
|
|
||
| interface ISovrynLBFactoryDex { | ||
| function getNumberOfLBPairs() external view returns (uint256); | ||
|
|
||
| function getLBPairAtIndex(uint256 id) external returns (address); | ||
|
|
||
| function getFeeRecipient() external view returns (address); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| pragma solidity 0.5.17; | ||
|
|
||
| interface ISovrynLBPairDex { | ||
| function getProtocolFees() external view returns (uint128 protocolFeeX, uint128 protocolFeeY); | ||
|
|
||
| function collectProtocolFees() external returns (bytes32 collectedProtocolFees); | ||
|
|
||
| function getTokenX() external view returns (address tokenX); | ||
|
|
||
| function getTokenY() external view returns (address tokenY); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /** | ||
| * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved. | ||
| * Licensed under the Apache License, Version 2.0. | ||
| */ | ||
|
|
||
| pragma solidity >=0.5.0 <0.6.0; | ||
|
|
||
| interface IWrappedNativeToken { | ||
| function deposit() external payable; | ||
|
|
||
| function withdraw(uint256 wad) external; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /** | ||
| * Copyright 2017-2020, bZeroX, LLC. All Rights Reserved. | ||
| * Licensed under the Apache License, Version 2.0. | ||
| */ | ||
|
|
||
| pragma solidity >=0.5.0 <0.6.0; | ||
|
|
||
| import "./IWrappedNativeToken.sol"; | ||
| import "./IERC20.sol"; | ||
|
|
||
| contract IWrappedNativeTokenERC20 is IWrappedNativeToken, IERC20 {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
contracts/mockup/FeeSharingCollectorMultipleTokenMockup.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| pragma solidity ^0.5.17; | ||
|
|
||
| import "../governance/FeeSharingCollector/FeeSharingCollectorMultiToken.sol"; | ||
|
|
||
| contract FeeSharingCollectorMultiTokenMockup is FeeSharingCollectorMultiToken { | ||
| struct TestData { | ||
| address loanPoolToken; | ||
| uint32 maxCheckpoints; | ||
| address receiver; | ||
| } | ||
|
|
||
| TestData public testData; | ||
|
|
||
| constructor(IProtocol _protocol, IStaking _staking) public { | ||
| protocol = _protocol; | ||
| staking = _staking; | ||
| } | ||
|
|
||
| function withdraw(address _token, uint32 _maxCheckpoint, address _receiver) public { | ||
| testData = TestData(_token, _maxCheckpoint, _receiver); | ||
| } | ||
|
|
||
| function trueWithdraw(address _token, uint32 _maxCheckpoint, address _receiver) public { | ||
| super.withdraw(_token, _maxCheckpoint, _receiver); | ||
| } | ||
|
|
||
| function trueWithdrawTokens( | ||
| address[] memory _tokens, | ||
| uint32[] memory _maxCheckpoints, | ||
| address _receiver | ||
| ) public { | ||
| super.withdrawTokens(_tokens, _maxCheckpoints, _receiver); | ||
| } | ||
|
|
||
| function addCheckPoint(address loanPoolToken, uint256 poolTokenAmount) public { | ||
| uint96 amount96 = safe96( | ||
| poolTokenAmount, | ||
| "FeeSharingProxy::withdrawFees: pool token amount exceeds 96 bits" | ||
| ); | ||
| _addCheckpoint(loanPoolToken, amount96); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| pragma solidity 0.5.17; | ||
|
|
||
| import "../interfaces/IERC20.sol"; | ||
| import "../governance/IFeeSharingCollectorMultiToken.sol"; | ||
|
|
||
| contract MockSovrynLBFactory { | ||
| address feeRecipient; | ||
| uint256 totalPairs; | ||
| address[] lbPairs; | ||
|
|
||
| constructor() public {} | ||
|
|
||
| function getFeeRecipient() public returns (address) { | ||
| return feeRecipient; | ||
| } | ||
|
|
||
| function setFeeRecipient(address _feeRecipient) public { | ||
| feeRecipient = _feeRecipient; | ||
| } | ||
|
|
||
| function addLbPairs(uint256 _totalPairs, address[] memory _lbPairs) public { | ||
| require(_totalPairs == _lbPairs.length, "mismatch lbPairs length"); | ||
| totalPairs = _totalPairs; | ||
| lbPairs = _lbPairs; | ||
| } | ||
|
|
||
| function getNumberOfLBPairs() public view returns (uint256) { | ||
| return totalPairs; | ||
| } | ||
|
|
||
| function getLBPairAtIndex(uint256 _id) public view returns (address) { | ||
| return lbPairs[_id]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| pragma solidity 0.5.17; | ||
|
|
||
| import "../interfaces/IERC20.sol"; | ||
| import "../governance/IFeeSharingCollectorMultiToken.sol"; | ||
| import "../interfaces/ISovrynLBFactoryDex.sol"; | ||
|
|
||
| contract MockSovrynLBPair { | ||
| address lbFactory; | ||
| address tokenX; | ||
| address tokenY; | ||
|
|
||
| uint128 amountTokenX; | ||
| uint128 amountTokenY; | ||
|
|
||
| modifier onlyFeeRecipient() { | ||
| require( | ||
| ISovrynLBFactoryDex(lbFactory).getFeeRecipient() == msg.sender, | ||
| "Only feeRecipient" | ||
| ); | ||
| _; | ||
| } | ||
|
|
||
| function getTokenX() public returns (address _tokenX) { | ||
| return tokenX; | ||
| } | ||
|
|
||
| function getTokenY() public returns (address _tokenY) { | ||
| return tokenY; | ||
| } | ||
|
|
||
| constructor( | ||
| address _lbFactory, | ||
| address _tokenX, | ||
| address _tokenY, | ||
| uint128 _amountTokenX, | ||
| uint128 _amountTokenY | ||
| ) public { | ||
| tokenX = _tokenX; | ||
| tokenY = _tokenY; | ||
| amountTokenX = _amountTokenX; | ||
| amountTokenY = _amountTokenY; | ||
| lbFactory = _lbFactory; | ||
| } | ||
|
|
||
| function getProtocolFees() public view returns (uint128 protocolFeeX, uint128 protocolFeeY) { | ||
| return (amountTokenX, amountTokenY); | ||
| } | ||
|
|
||
| function collectProtocolFees() public onlyFeeRecipient returns (bytes32) { | ||
| IERC20(tokenX).transfer(msg.sender, amountTokenX); | ||
| IERC20(tokenY).transfer(msg.sender, amountTokenY); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.