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

Features/hdev 1991 new asset #36

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

Conversation

0xAplki
Copy link
Contributor

@0xAplki 0xAplki commented May 8, 2024

Description of Changes

Link to Jira Ticket

How To Test

Developer Checklist:

  • I have followed the guidelines in our Contributing document
  • This PR has a corresponding JIRA ticket
  • My branch conforms with our naming convention i.e. feature/HDEV-XXX-description
  • I have written new tests for your core changes, as applicable
  • I have successfully ran tests locally
  • I have formatted my code using format document in VSCode

Reviewers Checklist:

  • Code is readable and understandable; any unclear parts have explanations
  • UI/UX changes match the corresponding figma/other design resources, if applicable
  • I have successfully ran tests locally

@0xAplki 0xAplki requested a review from andreiashu May 8, 2024 10:43
function configureAssets(DistributionTypes.AssetConfigInput[] calldata assetsConfigInput) external override {
require(msg.sender == EMISSION_MANAGER, 'ONLY_EMISSION_MANAGER');

for (uint256 i = 0; i < assetsConfigInput.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

cache assetsConfigInput.length in a local var, should save some gas

function _claimRewards(address user, DistributionTypes.UserStakeInput[] memory stakes) internal returns (uint256) {
uint256 accruedRewards = 0;

for (uint256 i = 0; i < stakes.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same, cache stakes.length to save some gas

) internal view returns (uint256) {
uint256 accruedRewards = 0;

for (uint256 i = 0; i < stakes.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

cache stakes.length to save some gas

uint256 reserveIndex,
uint256 userIndex
) internal pure returns (uint256) {
return principalUserBalance.mul(reserveIndex.sub(userIndex)).div(10 ** uint256(PRECISION));
Copy link
Contributor

Choose a reason for hiding this comment

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

because PRECISION is in 18 decimals, this line of code assumes principalUserBalance and reserveIndex and userIndex are also in 18 decimals. Is that ALWAYS going to be the case?

uint256 timeDelta = currentTimestamp.sub(lastUpdateTimestamp);
//console.log("timeDelta: ", timeDelta);
//console.log("emissionPerSecond: ", emissionPerSecond);
return emissionPerSecond.mul(timeDelta).mul(10 ** uint256(PRECISION)).div(totalBalance).add(currentIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

emissionPerSecond * timeDelta * 1e18 / totalBalance + currentIndex
I don't understand why currentIndex is being added here.

script/LendingPoolAddNewAsset.s.sol Show resolved Hide resolved
address constant aTokenAddress = address(0); // @todo change
address constant sdtAddress = address(0); // @todo change
address constant vdtAddress = address(0); // @todo change
address constant aTokenImplAddress = address(0); // @todo change
Copy link
Contributor

Choose a reason for hiding this comment

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

are the vars necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will transform this to a config!

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