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

EF, BWF #200

Merged
merged 20 commits into from
Jan 3, 2025
Merged

EF, BWF #200

merged 20 commits into from
Jan 3, 2025

Conversation

a17
Copy link
Member

@a17 a17 commented Dec 29, 2024

EF

Implementation

  • integration interfaces
  • constants
  • routes
  • farms
  • skeleton
  • universal test
  • implementation
  • deploy script

Deployment

  • deploy Solidly adapter 0xE3374041F173FFCB0026A82C6EEf94409F713Cf9
  • deploy EF strategy 0xA1f5Ce440fa7F05e303DD7a41fAd1C131bB5bB85
  • add strategy config
  • add Solidly adapter to platform
  • setup swapper router
  • setup swapper thresholds
  • add farms

Bugs

  • 1.0.1: initVariants 0x9B093877eCe3232013516fAf0ca6297A8535141B
  • 1.0.2: _compound 0x7146efaab12A083b9826c66162062c21eC70fe3c
  • change impl

BWF

Implementation

  • implementation
  • deploy script

Deployment

  • deploy BWF strategy 0x8f59BB791Da8fb1E2FedbDeAc576F0f622479059
  • add farms

@a17 a17 self-assigned this Dec 29, 2024
@a17 a17 added the 📜 STRATEGY Strategy logic proposed for implementation label Dec 29, 2024
Comment on lines +125 to +127
if (farm.status == 0 && CommonLib.eq(farm.strategyLogicId, strategyLogicId())) {
++localTtotal;
}

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-nested-if Note

Using nested is cheaper than using && multiple check combinations.
There are more advantages, such as easier to read code and better coverage reports.
Comment on lines +138 to +143
if (farm.status == 0 && CommonLib.eq(farm.strategyLogicId, strategyLogicId())) {
nums[localTtotal] = i;
//slither-disable-next-line calls-loop
variants[localTtotal] = _generateDescription(farm, _ammAdapter);
++localTtotal;
}

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-nested-if Note

Using nested is cheaper than using && multiple check combinations.
There are more advantages, such as easier to read code and better coverage reports.
Comment on lines +212 to +221
function _depositAssets(uint[] memory amounts, bool) internal override returns (uint value) {
IFactory.Farm memory farm = _getFarm();
address[] memory _assets = assets();
bool stable = ISolidlyPool(farm.pool).stable();
(,, value) = IRouter(farm.addresses[1]).addLiquidity(
_assets[0], _assets[1], stable, amounts[0], amounts[1], 0, 0, address(this), block.timestamp
);
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
$base.total += value;
}
src/strategies/EqualizerFarmStrategy.sol Fixed Show fixed Hide fixed

function _calcAssetsAmounts(uint shares) internal view returns (uint[] memory amounts_) {
IFactory.Farm memory farm = _getFarm();
address pool = farm.pool;

Check notice

Code scanning / Slither

Local variable shadowing Low

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 99.32886% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.86%. Comparing base (47e8d47) to head (cb5a5ee).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
src/strategies/BeetsWeightedFarm.sol 98.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #200      +/-   ##
==========================================
+ Coverage   92.52%   92.86%   +0.33%     
==========================================
  Files          75       77       +2     
  Lines        6610     6906     +296     
  Branches      585      598      +13     
==========================================
+ Hits         6116     6413     +297     
  Misses        462      462              
+ Partials       32       31       -1     

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

@a17 a17 linked an issue Jan 2, 2025 that may be closed by this pull request
Comment on lines +146 to +148
if (farm.status == 0 && CommonLib.eq(farm.strategyLogicId, strategyLogicId())) {
++localTtotal;
}

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-nested-if Note

Using nested is cheaper than using && multiple check combinations.
There are more advantages, such as easier to read code and better coverage reports.
Comment on lines +159 to +164
if (farm.status == 0 && CommonLib.eq(farm.strategyLogicId, strategyLogicId())) {
nums[localTtotal] = i;
//slither-disable-next-line calls-loop
variants[localTtotal] = _generateDescription(farm, _ammAdapter);
++localTtotal;
}

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-nested-if Note

Using nested is cheaper than using && multiple check combinations.
There are more advantages, such as easier to read code and better coverage reports.
override(StrategyBase, LPStrategyBase)
returns (uint[] memory, uint)
{
revert("Not supported");

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-custom-error-not-require Note

Consider using custom errors as they are more gas efficient while allowing developers
to describe the error in detail using NatSpec.
Comment on lines +286 to +288
if (amountsToDeposit[0] > 2500 && amountsToDeposit[1] > 2500) {
_depositAssets(amountsToDeposit, true);
}

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-nested-if Note

Using nested is cheaper than using && multiple check combinations.
There are more advantages, such as easier to read code and better coverage reports.
Comment on lines +229 to +256
function _depositAssets(uint[] memory amounts, bool) internal override returns (uint value) {
ILPStrategy.LPStrategyBaseStorage storage $lp = _getLPStrategyBaseStorage();
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
IBWeightedPoolMinimal _pool = IBWeightedPoolMinimal($lp.pool);
BalancerMethodVars memory v;

v.poolId = _pool.getPoolId();
(v.poolTokens,,) = IBVault(_pool.getVault()).getPoolTokens(v.poolId);

value = IERC20(address(_pool)).balanceOf(address(this));

IBVault(_pool.getVault()).joinPool(
v.poolId,
address(this),
address(this),
IBVault.JoinPoolRequest({
assets: v.poolTokens,
maxAmountsIn: amounts,
userData: abi.encode(IBVault.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT, amounts, 0),
fromInternalBalance: false
})
);
value = IERC20(address(_pool)).balanceOf(address(this)) - value;
$base.total += value;

IFactory.Farm memory farm = _getFarm();
IBalancerGauge(farm.addresses[0]).deposit(value);
}

Check warning

Code scanning / Slither

Unused return Medium

ILPStrategy.LPStrategyBaseStorage storage $lp = _getLPStrategyBaseStorage();
StrategyBaseStorage storage $base = _getStrategyBaseStorage();
IBWeightedPoolMinimal _pool = IBWeightedPoolMinimal($lp.pool);
BalancerMethodVars memory v;

Check warning

Code scanning / Slither

Uninitialized local variables Medium

BeetsWeightedFarm._depositAssets(uint256[],bool).v is a local variable never initialized
Comment on lines +268 to +302
function _withdrawAssets(uint value, address receiver) internal override returns (uint[] memory amountsOut) {
IFactory.Farm memory farm = _getFarm();
IBWeightedPoolMinimal _pool = IBWeightedPoolMinimal(pool());
BalancerMethodVars memory v;

(v.poolTokens,,) = IBVault(_pool.getVault()).getPoolTokens(_pool.getPoolId());

IBalancerGauge(farm.addresses[0]).withdraw(value);

address[] memory __assets = assets();
v.len = __assets.length;
amountsOut = new uint[](v.len);
for (uint i; i < v.len; ++i) {
amountsOut[i] = IERC20(__assets[i]).balanceOf(receiver);
}

IBVault(_pool.getVault()).exitPool(
_pool.getPoolId(),
address(this),
payable(receiver),
IBVault.ExitPoolRequest({
assets: v.poolTokens,
minAmountsOut: new uint[](v.poolTokens.length),
userData: abi.encode(1, value),
toInternalBalance: false
})
);

for (uint i; i < v.len; ++i) {
amountsOut[i] = IERC20(__assets[i]).balanceOf(receiver) - amountsOut[i];
}

StrategyBaseStorage storage $base = _getStrategyBaseStorage();
$base.total -= value;
}
function _withdrawAssets(uint value, address receiver) internal override returns (uint[] memory amountsOut) {
IFactory.Farm memory farm = _getFarm();
IBWeightedPoolMinimal _pool = IBWeightedPoolMinimal(pool());
BalancerMethodVars memory v;

Check warning

Code scanning / Slither

Uninitialized local variables Medium

BeetsWeightedFarm._withdrawAssets(uint256,address).v is a local variable never initialized
Comment on lines +409 to +418
function _calcAssetsAmounts(uint shares) internal view returns (uint[] memory amounts_) {
IBWeightedPoolMinimal _pool = IBWeightedPoolMinimal(pool());
(, uint[] memory balances,) = IBVault(_pool.getVault()).getPoolTokens(_pool.getPoolId());
uint supply = IERC20(address(_pool)).totalSupply();
uint len = balances.length;
amounts_ = new uint[](len);
for (uint i; i < len; ++i) {
amounts_[i] = shares * balances[i] / supply;
}
}

Check warning

Code scanning / Slither

Unused return Medium

@a17 a17 linked an issue Jan 3, 2025 that may be closed by this pull request
@a17 a17 changed the title EF EF, BWF Jan 3, 2025
@a17 a17 added bug Something isn't working BASE STRATEGY Base strategy implementation related tasks STRATEGY UPGRADE Required strategy upgrades labels Jan 3, 2025
@a17 a17 merged commit acd62f6 into main Jan 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BASE STRATEGY Base strategy implementation related tasks bug Something isn't working STRATEGY UPGRADE Required strategy upgrades 📜 STRATEGY Strategy logic proposed for implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📜 [DEV] Equalizer Farm 📜 [DEV] Beets Weighted Farm
1 participant