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

Interest distribution operator #415

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

Interest distribution operator #415

wants to merge 34 commits into from

Conversation

hieronx
Copy link
Contributor

@hieronx hieronx commented Sep 23, 2024

No description provided.

@@ -308,6 +308,12 @@ interface IERC7540Vault is
/// @dev MUST be called by endorsed sender
function setEndorsedOperator(address owner, bool approved) external;

/// @notice TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @notice TODO
// --- Helpers ---
/// @notice Price of 1 unit of share, quoted in the decimals of the asset.

@@ -0,0 +1,34 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.5.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason why pragma is defined like that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allows any integration to pull in these interfaces, using any Solidity version.

}

/// @inheritdoc IInterestDistributor
function clear(address vault, address controller) external {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this to dropOut. Meaning that you want to drop-out from the interest distribution process.

// Assuming price updates coincide with epoch fulfillments, this results in only requesting
// interest on the previous outstanding balance before the new fulfillment.
uint128 request = priceLastUpdated > user.lastUpdate
? _computeRequest(user.shares, currentShares, user.peak, uint96(currentPrice))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
? _computeRequest(user.shares, currentShares, user.peak, uint96(currentPrice))
? _computerRedeemAmount(user.shares, currentShares, user.peak, uint96(currentPrice))

// Calculate request before updating user.shares, so it is based on the balance at the last price update.
// Assuming price updates coincide with epoch fulfillments, this results in only requesting
// interest on the previous outstanding balance before the new fulfillment.
uint128 request = priceLastUpdated > user.lastUpdate
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint128 request = priceLastUpdated > user.lastUpdate
uint128 redeemAmount = priceLastUpdated > user.lastUpdate

contract InterestDistributor is IInterestDistributor {
using MathLib for uint256;

mapping(address vault => mapping(address user => InterestDetails)) internal _users;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mapping(address vault => mapping(address user => InterestDetails)) internal _users;
mapping(address vault => mapping(address user => InterestDetails)) public users;

Copy link

Coverage after merging interest-distributor into main will be

99.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Auth.sol100%100%100%100%
   CentrifugeRouter.sol88.52%57.50%96.88%97.30%104, 119, 130, 130, 147, 191, 202, 225, 225–226, 302, 310, 315, 317, 331, 53, 60, 60, 60, 87
   ERC7540Vault.sol96.28%78.13%100%100%105, 133, 138, 145, 145, 250, 263
   Escrow.sol100%100%100%100%
   InvestmentManager.sol98.41%93.83%100%100%323, 354, 359, 488, 559
   PoolManager.sol99.01%98.17%96.43%100%216, 437
   Root.sol98.65%94.44%100%100%32
src/admin
   Guardian.sol92.59%100%100%85.71%65–66
src/factories
   ERC7540VaultFactory.sol100%100%100%100%
   TrancheFactory.sol100%100%100%100%
   TransferProxyFactory.sol100%100%100%100%
src/gateway
   GasService.sol100%100%100%100%
   Gateway.sol97.42%92.94%100%99.41%127–128, 172, 176, 261–262, 76
src/gateway/adapters/axelar
   Adapter.sol100%100%100%100%
   Forwarder.sol100%100%100%100%
src/operators
   InterestDistributor.sol80%55.56%80%87.10%73, 73, 73–74, 74, 74, 76–77
src/token
   ERC20.sol100%100%100%100%
   RestrictionManager.sol100%100%100%100%
   Tranche.sol92.98%70%94.44%100%108, 123, 97

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