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

SolidlyAdapter #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

SolidlyAdapter #186

wants to merge 1 commit into from

Conversation

a17
Copy link
Member

@a17 a17 commented Nov 15, 2024

  • implementation
  • coverage
  • deploy scripts

@a17 a17 self-assigned this Nov 15, 2024
@a17 a17 linked an issue Nov 15, 2024 that may be closed by this pull request
@a17 a17 added the ADAPTER Adapter implementation label Nov 15, 2024
ISolidlyPool(pool).swap(amount0Out, amount1Out, recipient, new bytes(0));

uint priceAfter = getPrice(pool, tokenIn, tokenOut, amount1);
uint priceImpact = (priceBefore - priceAfter) * ConstantsLib.DENOMINATOR / priceBefore;

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.security.basic-arithmetic-underflow Note

Possible arithmetic underflow
Comment on lines +122 to +137
function getProportions(address pool) external view returns (uint[] memory props) {
props = new uint[](2);
if (ISolidlyPool(pool).stable()) {
address token1 = ISolidlyPool(pool).token1();
uint token1Decimals = IERC20Metadata(token1).decimals();
uint token1Price = getPrice(pool, token1, address(0), 10 ** token1Decimals);
(uint reserve0, uint reserve1) = _getReserves(pool);
uint reserve1Priced = reserve1 * token1Price / 10 ** token1Decimals;
uint totalPriced = reserve0 + reserve1Priced;
props[0] = reserve0 * 1e18 / totalPriced;
props[1] = reserve1Priced * 1e18 / totalPriced;
} else {
props[0] = 5e17;
props[1] = 5e17;
}
}

Check warning

Code scanning / Slither

Divide before multiply Medium

Comment on lines +158 to +163
function _getReserves(address pool) internal view returns (uint reserveA, uint reserveB) {
address[] memory tokens = poolTokens(pool);
(address token0,) = _sortTokens(tokens[0], tokens[1]);
(uint reserve0, uint reserve1,) = ISolidlyPool(pool).getReserves();
(reserveA, reserveB) = tokens[0] == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}

Check warning

Code scanning / Slither

Unused return Medium

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 82.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 97.14%. Comparing base (2c51274) to head (0b0e93b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/adapters/SolidlyAdapter.sol 82.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
- Coverage   97.30%   97.14%   -0.17%     
==========================================
  Files          64       65       +1     
  Lines        4643     4693      +50     
  Branches      516      521       +5     
==========================================
+ Hits         4518     4559      +41     
- Misses        107      116       +9     
  Partials       18       18              

☔ 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
ADAPTER Adapter implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💱 Solidly AMM adapter
1 participant