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

Affiliates v2 #233

Merged
merged 68 commits into from
Jun 14, 2021
Merged

Affiliates v2 #233

merged 68 commits into from
Jun 14, 2021

Conversation

cwsnt
Copy link
Contributor

@cwsnt cwsnt commented May 17, 2021

Affiliates V2 done with LockedSOV implementation.
So the rewards for referrer will be stored in LockedSOV contract.
For the deployment, can use the deployAffiliate() in contract_interaction.py

dasaveliev and others added 30 commits December 28, 2020 21:58
@ghost
Copy link

ghost commented May 21, 2021

The coveralls shows failure due to decreased coverage, saw these two files mainly contributing to the cause.

These are the files where the coverage is decreased (you can use the key n and b to go forward and backward of uncovered lines).
https://coveralls.io/builds/39878342/source?filename=contracts%2Fconnectors%2Floantoken%2FLoanTokenSettingsLowerAdmin.sol
https://coveralls.io/builds/39878342/source?filename=contracts%2Fmodules%2FLoanMaintenance.sol

Coveralls failure is more towards quality than test failure, if you could cover those edge cases as well, that would be nice.

@ghost
Copy link

ghost commented May 21, 2021

@ghost
Copy link

ghost commented May 21, 2021

https://github.com/DistributedCollective/Sovryn-smart-contracts/tree/development/contracts/locked

This is in development but newer changes are in liquidity-mining (which might be merged soon by James.)

@cwsnt
Copy link
Contributor Author

cwsnt commented May 21, 2021

https://github.com/DistributedCollective/Sovryn-smart-contracts/blob/66d9d727d9ab645f5c10d0bf9bdc94f9047bc047/contracts/mockup/lockedSOVFailedMockup.sol

What is it's role?

https://github.com/DistributedCollective/Sovryn-smart-contracts/blob/66d9d727d9ab645f5c10d0bf9bdc94f9047bc047/contracts/mockup/lockedSOVFailedMockup.sol

What is it's role?

It's used to simulate the failed process of depositSOV in lockedSOV contract. In case it's failed, the affiliates contract will log it.
This is just used for testing purposes

Copy link

@eMarchenko eMarchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only minor issues

address affiliateReferrer, // the user was brought by the affiliate (referrer)
bytes memory loanDataBytes // arbitrary order data
)
public

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external


event SetProtocolAddress(address indexed sender, address indexed oldProtocol, address indexed newProtocol);

event SetMinReferralsToPayoutAffiliates(address indexed sender, uint256 indexed oldMinReferrals, uint256 indexed newMinReferrals);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should oldMinReferrals/newMinReferrals be indexed?

*/
function enumerate(AddressSet storage set) internal view returns (address[] memory) {
address[] memory output = new address[](set.values.length);
for (uint256 i; i < set.values.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set.values.length reads storage in a loop

address feeToken,
uint256 tradingFee
) internal returns (uint256 affiliatesBonusSOVAmount, uint256 affiliatesBonusTokenAmount) {
(affiliatesBonusSOVAmount, affiliatesBonusTokenAmount) = ProtocolAffiliatesInterface(protocolAddress).payTradingFeeToAffiliatesReferrer(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can get away with unnamed return parameters and just return ProtocolAffiliatesInterface(...).payTradingFeeToAffiliatesReferrer(...)

* @dev settles the trading fee and pays the token reward to the user.
* @param referrer the affiliate referrer address to send the reward to
* @param feeToken the address of the token in which the trading fee is paid
* */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

natspec is missing return values

constructor() public {}

function() external {
revert("Affiliates - fallback not allowed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback with revert is unnecessary, unless you want custom revert message

}
}

function getReferralsList(address referrer) public view returns (address[] memory refList) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external

IPriceFeeds(_priceFeeds).queryReturn.selector,
feeToken,
sovTokenAddress, // dest token = SOV
feeAmount.mul(_getAffiliatesTradingFeePercentForSOV()).div(10**20)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10**20 -> 1e20

feeAmount.mul(_getAffiliatesTradingFeePercentForSOV()).div(10**20)
)
);
assembly {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is abi.decode available? it's a cleaner way to parse bytes

address token,
uint256 tradingFeeTokenBaseAmount
) external onlyCallableInternal returns (uint256 referrerBonusSovAmount, uint256 referrerBonusTokenAmount) {
bool isHeld = referralsList[referrer].length() >= getMinReferralsToPayout() ? false : true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool isHeld = referralsList[referrer].length() < getMinReferralsToPayout();
in general, true and false are only required in single-word statements like return true;, while(true) or someFlag = false;

@ghost ghost linked an issue Jun 11, 2021 that may be closed by this pull request
@cwsnt cwsnt merged commit e1bb0c5 into development Jun 14, 2021
@ghost
Copy link

ghost commented Jun 14, 2021

Please test this on testnet first before merging with development branch. I have reset the development branch, you might have to create a new PR or revive this one @santosinarp

Please review the testing on testnet @tjcloa

@cwsnt
Copy link
Contributor Author

cwsnt commented Jun 20, 2021

Need to create new PR for this feature due to lack of testing on testnet.
The new PR is created at #280

@tjcloa tjcloa mentioned this pull request Jun 21, 2021
tjcloa added a commit that referenced this pull request Jun 21, 2021
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.

Referral system v2
4 participants