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

Add pool fee during interest payments #50

Merged
merged 9 commits into from
Oct 20, 2022
Merged

Add pool fee during interest payments #50

merged 9 commits into from
Oct 20, 2022

Conversation

bricestacey
Copy link
Contributor

Draft PR: Need to improve the code organization and whatnot, but basic functionality is there.

@bricestacey bricestacey marked this pull request as ready for review October 18, 2022 20:13
IPool(_pool).manager(),
poolFee
);
LoanLib.completePayment(liquidityAsset, _pool, poolPayment);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this looks like you could optimize and combine the two function calls into one, but as you'll see later when paying off a loan we'll want to add in the remaining principal...

@@ -210,4 +212,56 @@ library LoanLib {
IERC20(liquidityAsset).safeTransferFrom(msg.sender, pool, amount);
emit LoanPaymentMade(pool, liquidityAsset, amount);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR doesn't change this event, but I think it's semantically different now. Trying to reason about it, but assuming people want to monitor payments made by borrowers, it should likely be one event per payment and the amount should likely be the total amount (with these changes, it no longer includes fees). We could add more granular events for fees, but I don't think it's necessary.

ams9198
ams9198 previously approved these changes Oct 19, 2022
Copy link
Contributor

@ams9198 ams9198 left a comment

Choose a reason for hiding this comment

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

Looks good! Small suggestion on naming to align with withdrawals stuff.

/**
* @dev The address of the first loss vault
*/
function firstLossVault() external view override returns (address) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need to expose feevault too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I updated the PR and added the feeVault and pool fees now go there instead of directly to the Pool Admin.

@@ -21,6 +21,10 @@ contract ServiceConfiguration is AccessControl, IServiceConfiguration {

mapping(address => bool) public isLiquidityAsset;

uint256 public firstLossFee = 500;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the withdrawal fees were denominated in bips, which was included in the variable name too. I kinda appreciated that explicitness: https://github.com/circlefin/valyria-core/blob/64dd99da802fc52f8b1a89d01775a1dfc7e3c6f5/contracts/interfaces/IPool.sol#L30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this.

*/
function previewFees(
uint256 payment,
uint256 firstLoss,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be firstLossFee or firstLossFeeBips so it's clearer? And then later on it's firstLossFeeAmount etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha I just dropped the word fee from the config but then realized the pool fee didn't have fee at the end... I actually don't have a good answer for this one. Maybe we can append Config to the params? That'd at least make it clear it is the input versus the output?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me...as long as it's not ambiguous

@bricestacey bricestacey merged commit 620de38 into circlefin:master Oct 20, 2022
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