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

Builder #157

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

Builder #157

wants to merge 3 commits into from

Conversation

a17
Copy link
Member

@a17 a17 commented Jun 25, 2024

No description provided.

@a17 a17 self-assigned this Jun 25, 2024
@a17 a17 linked an issue Jun 25, 2024 that may be closed by this pull request
9 tasks
@a17 a17 added the PLATFORM UPGRADE Upgrading platform core contracts with the described changes label Jun 25, 2024
Comment on lines +69 to +103
function invest(address asset, uint amount) external nonReentrant returns (uint48 amountUSD) {
IPriceReader priceReader = IPriceReader(IPlatform(platform()).priceReader());
(uint price, bool trusted) = priceReader.getPrice(asset);
if (!trusted) {
revert NotTrustedPriceFor(asset);
}
amountUSD = uint48(amount * price / 10 ** IERC20Metadata(asset).decimals() * USD_DENOMINATOR / 1e18);
if (amountUSD == 0) {
revert ZeroAmountToInvest();
}

BuilderStorage storage $ = _getStorage();
uint tokenId = $.ownedToken[msg.sender];

if (tokenId == 0) {
if (amountUSD < MIN_AMOUNT_FOR_MINTING) {
revert TooLittleAmountToInvest(amountUSD, MIN_AMOUNT_FOR_MINTING);
}
tokenId = $.newTokenId;
$.newTokenId = tokenId + 1;
$.ownedToken[msg.sender] = tokenId;
_mint(msg.sender, tokenId);
} else {
if (amountUSD < MIN_AMOUNT_FOR_ADDING) {
revert TooLittleAmountToInvest(amountUSD, MIN_AMOUNT_FOR_ADDING);
}
}

TokenData storage tokenData = $.tokenData[tokenId];
tokenData.invested += amountUSD;

IERC20(asset).safeTransferFrom(msg.sender, address(this), amount);

emit Invested(msg.sender, tokenId, asset, amount, amountUSD);
}

Check warning

Code scanning / Slither

Divide before multiply Medium

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 79.31034% with 6 lines in your changes missing coverage. Please review.

Project coverage is 98.00%. Comparing base (43e38cc) to head (6670e7f).

Files Patch % Lines
src/core/Builder.sol 79.31% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   94.76%   98.00%   +3.24%     
==========================================
  Files          60       61       +1     
  Lines        4428     4456      +28     
  Branches      477      481       +4     
==========================================
+ Hits         4196     4367     +171     
- Misses         77       82       +5     
+ Partials      155        7     -148     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PLATFORM UPGRADE Upgrading platform core contracts with the described changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Builder: profile NFT
1 participant