Ft slither workflow#59
Conversation
| function _convertUSDCIntoLpToken(uint256 _amount) | ||
| internal | ||
| returns (uint256 receivedLpTokens) | ||
| { | ||
| uint256[2] memory liquidityAmounts = [0, _amount]; | ||
|
|
||
| // estimate amount of Lp Tokens based on stable peg i.e., 1FXS = 1 3Pool LP Token | ||
| uint256 expectedLpOut = (_amount * NORMALIZATION_FACTOR) / | ||
| fraxPool.get_virtual_price(); // 30 = normalizing 18 decimals for virutal price + 18 decimals for LP token - 6 decimals for want token | ||
| // Provide USDC liquidity to receive Lp tokens with a slippage of `maxSlippage` | ||
| receivedLpTokens = fraxPool.add_liquidity( | ||
| liquidityAmounts, | ||
| (expectedLpOut * (MAX_BPS - maxSlippage)) / (MAX_BPS) | ||
| ); | ||
| } |
Check warning
Code scanning / Slither
Divide before multiply
| function _convertLpTokenIntoUSDC(uint256 _amount) | ||
| internal | ||
| returns (uint256 receivedWantTokens) | ||
| { | ||
| int128 usdcIndexInPool = int128( | ||
| int256(uint256(FraxPoolCoinIndexes.USDC)) | ||
| ); | ||
|
|
||
| // estimate amount of USDC received based on stable peg i.e., 1FXS = 1 3Pool LP Token | ||
| uint256 expectedWantTokensOut = (_amount * | ||
| fraxPool.get_virtual_price()) / NORMALIZATION_FACTOR; // 30 = normalizing 18 decimals for virutal price + 18 decimals for LP token - 6 decimals for want token | ||
| // burn Lp tokens to receive USDC with a slippage of `maxSlippage` | ||
| receivedWantTokens = fraxPool.remove_liquidity_one_coin( | ||
| _amount, | ||
| usdcIndexInPool, | ||
| (expectedWantTokensOut * (MAX_BPS - maxSlippage)) / (MAX_BPS) | ||
| ); | ||
| } |
Check warning
Code scanning / Slither
Divide before multiply
| function _lpTokenValueInUSDC(uint256 _value) | ||
| internal | ||
| view | ||
| returns (uint256) | ||
| { | ||
| if (_value == 0) return 0; | ||
|
|
||
| return | ||
| fraxPool.calc_withdraw_one_coin( | ||
| _value, | ||
| int128(int256(uint256(FraxPoolCoinIndexes.USDC))) | ||
| ); | ||
| } |
Check warning
Code scanning / Slither
Dangerous strict equalities
| function _configHandler(address _harvester, address _wantToken) internal { | ||
| wantToken = IERC20(_wantToken); | ||
| harvester = IHarvester(_harvester); | ||
|
|
||
| // Approve max want tokens to frax2Pool. | ||
| wantToken.approve(address(fraxPool), type(uint256).max); | ||
| } |
Check warning
Code scanning / Slither
Unused return
Check warning
Code scanning / Slither
Unused return
| function _claimRewards(bytes calldata _data) internal override { | ||
| convexVault.getReward(); | ||
|
|
||
| uint256 initialUSDCBalance = wantToken.balanceOf(address(this)); | ||
|
|
||
| // get list of tokens to transfer to harvester | ||
| address[] memory rewardTokens = harvester.rewardTokens(); | ||
| //transfer them | ||
| uint256 balance; | ||
| for (uint256 i = 0; i < rewardTokens.length; i++) { | ||
| balance = IERC20(rewardTokens[i]).balanceOf(address(this)); | ||
|
|
||
| if (balance > 0) { | ||
| IERC20(rewardTokens[i]).safeTransfer( | ||
| address(harvester), | ||
| balance | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // convert all rewards to usdc | ||
| harvester.harvest(); | ||
|
|
||
| latestHarvestedRewards = | ||
| wantToken.balanceOf(address(this)) - | ||
| initialUSDCBalance; | ||
| totalCummulativeRewards += latestHarvestedRewards; | ||
|
|
||
| emit Claim(latestHarvestedRewards); | ||
| } |
Check warning
Code scanning / Slither
Unused return
| constructor() { | ||
| address _stakingVault = fraxConvexBooster.createVault(FRAX_USDC_PID); | ||
|
|
||
| // Create a staking proxy vault and get the actual staking contract | ||
| convexVault = IConvexStakingProxy(_stakingVault); | ||
| convexStaking = IConvexStaking( | ||
| IConvexStakingProxy(_stakingVault).stakingAddress() | ||
| ); | ||
|
|
||
| // Approve max LP tokens to FraxConvex booster | ||
| lpToken.approve(address(_stakingVault), type(uint256).max); | ||
| // Approve max lp tokens to frax2Pool | ||
| lpToken.approve(address(fraxPool), type(uint256).max); | ||
| } |
Check warning
Code scanning / Slither
Unused return
| constructor() { | ||
| address _stakingVault = fraxConvexBooster.createVault(FRAX_USDC_PID); | ||
|
|
||
| // Create a staking proxy vault and get the actual staking contract | ||
| convexVault = IConvexStakingProxy(_stakingVault); | ||
| convexStaking = IConvexStaking( | ||
| IConvexStakingProxy(_stakingVault).stakingAddress() | ||
| ); | ||
|
|
||
| // Approve max LP tokens to FraxConvex booster | ||
| lpToken.approve(address(_stakingVault), type(uint256).max); | ||
| // Approve max lp tokens to frax2Pool | ||
| lpToken.approve(address(fraxPool), type(uint256).max); | ||
| } |
Check warning
Code scanning / Slither
Unused return
| function _openPosition(bytes calldata _data) internal override { | ||
| _checkPosition(false); | ||
|
|
||
| AmountParams memory openPositionParams = abi.decode( | ||
| _data, | ||
| (AmountParams) | ||
| ); | ||
| require( | ||
| openPositionParams._amount <= lpToken.balanceOf(address(this)), | ||
| "INSUFFICIENT_BALANCE" | ||
| ); | ||
|
|
||
| uint256 previousLpTokenBalance = lpToken.balanceOf(address(this)); | ||
| convexVault.stakeLockedCurveLp( | ||
| openPositionParams._amount, | ||
| stakingPeriodSecs | ||
| ); | ||
|
|
||
| require( | ||
| lpToken.balanceOf(address(this)) < previousLpTokenBalance, | ||
| "STAKING_UNSUCCESSFUL" | ||
| ); | ||
| } |
Check warning
Code scanning / Slither
Unused return
No description provided.