Skip to content

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.

@codecov
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.

4 participants