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

fee splitter #45

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

fee splitter #45

wants to merge 9 commits into from

Conversation

0xdomrom
Copy link
Contributor

Create a utility contract for allowing fees to be collected into a smart contract and then split based on a set percentage to two different accounts.

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.74%. Comparing base (04e6805) to head (3b5c569).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #45      +/-   ##
==========================================
+ Coverage   92.15%   92.74%   +0.59%     
==========================================
  Files          13       14       +1     
  Lines         306      331      +25     
  Branches       68       71       +3     
==========================================
+ Hits          282      307      +25     
  Misses          7        7              
  Partials       17       17              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@joshpwrk joshpwrk left a comment

Choose a reason for hiding this comment

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

Main one is ensuring accountA / B are set before splitting

IAsset public immutable cashAsset;

uint public subAcc;
uint public splitPercent = 0.5e18;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: why not just force it in the constructor. Seems like an important value to not forget to set.


/// @notice Set the % split
function setSplit(uint _splitPercent) external onlyOwner {
if (_splitPercent > 1e18) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think cash and managers allow amount=0 transfers, but might be worth double checking.

E.g. if _splitPercent is 0 or 1, you'd need to make 0 amount transfers in split()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushed test for this 👌

int splitAmountA = balance.multiplyDecimal(int(splitPercent));
int splitAmountB = balance - splitAmountA;

ISubAccounts.AssetTransfer[] memory transfers = new ISubAccounts.AssetTransfer[](2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add a check that accountA and accountB are NOT 0. Otherwise I think you might accidentally send fees to the subaccountId 0 lol.

Copy link
Collaborator

Choose a reason for hiding this comment

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

or would run setSubaccounts in constructor.

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.

3 participants