-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
SolidlyAdapter #186
Conversation
a17
commented
Nov 15, 2024
- implementation
- coverage
- deploy scripts
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
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
- reserve1Priced = reserve1 * token1Price / 10 ** token1Decimals
- props[1] = reserve1Priced * 1e18 / totalPriced
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
Codecov ReportAttention: Patch coverage is
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. |