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

TradeModuleV2 and GeneralIndexModuleV2 #154

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

richardliang
Copy link
Contributor

@richardliang richardliang commented Oct 14, 2021

Code Review Processes

New Feature Review

Before submitting a pull request for new review, make sure the following is done:

README Checks

  • [] README has proper context for the reviewer to understand what the code includes, any important design considerations, and areas to pay more attention to

Code Checks

  • [] Add explanatory comments. If there is complex code that requires specific context or understanding, note that in a comment
  • [] Remove unncessary comments. Any comments that do not add additional context, information, etc. should be removed
  • [] Add javadocs.
  • [] Scrub through the code for inconsistencies (e.g. removing extra spaces)
  • [] Ensure there are not any .onlys in spec files

Broader Considerations

  • [] Ensure variable, function and event naming is clear, consistent, and reflective for the scope of the code.
  • [] Consider if certain pieces of logic should be placed in a different library, module

@richardliang richardliang changed the title [WIP] - TradeModuleV2 and GeneralIndexModuleV2 TradeModuleV2 and GeneralIndexModuleV2 Oct 15, 2021
@bweick
Copy link
Contributor

bweick commented Oct 21, 2021

Commenting the diff for TradeModule and GeneralIndexModule

internal
returns (uint256 protocolFee, uint256 managerRebate)
{
uint256 totalFeePercentage = controller.getModuleFee(address(this), TRADE_MODULE_V2_TOTAL_FEE_INDEX);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use:

uint256 totalFees = getModuleFee(TRADE_MODULE_PROTOCOL_FEE_INDEX, _exchangedQuantity);
managerRebate = controller.getModuleFee(address(this), TRADE_MODULE_V2_MANAGER_REBATE_SPLIT_INDEX).preciseMul(totalFees);
protocolFee = totalFees.sub(managerRebate);

I think that way you can be more confident about not having some extra wei sent out due to rounding and you aren't recalculating totalFeePercentage.preciseMul(_exchangedQuantity)

* @param _setToken Instance of the SetToken to update fee recipient
* @param _newRebateRecipient New rebate fee recipient address
*/
function updateFeeRecipient(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make this clearer and call it updateRebateRecipient

* @param _setToken Instance of the SetToken to update fee recipient
* @param _newRebateRecipient New rebate fee recipient address
*/
function updateFeeRecipient(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would call this updateRebateRecipient as well

uint256 totalFeePercentage = controller.getModuleFee(address(this), GENERAL_INDEX_MODULE_V2_TOTAL_FEE_INDEX);
uint256 managerRebateSplitPercentage = controller.getModuleFee(address(this), GENERAL_INDEX_MODULE_V2_MANAGER_REBATE_SPLIT_INDEX);

managerRebate = totalFeePercentage.preciseMul(exchangedQuantity).preciseMul(managerRebateSplitPercentage);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would change this math similarly to TradeModuleV2 comment

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.

2 participants