Skip to content

Commit

Permalink
debugging work
Browse files Browse the repository at this point in the history
  • Loading branch information
crispymangoes committed Mar 19, 2024
1 parent 1a3f425 commit 3863f87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 52 deletions.
41 changes: 10 additions & 31 deletions src/modules/adaptors/Curve/CurveHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ contract CurveHelper {
ERC20[] memory underlyingTokens,
uint256[] memory orderedMinimumUnderlyingTokenAmountsOut,
bool useUnderlying,
FixedOrDynamic fixedOrDynamic

FixedOrDynamic fixedOrDynamic
) external nonReentrant returns (uint256[] memory balanceDelta) {
if (underlyingTokens.length != orderedMinimumUnderlyingTokenAmountsOut.length)
revert CurveHelper___MismatchedLengths();
Expand Down Expand Up @@ -287,9 +286,9 @@ contract CurveHelper {
finalEncodedArgOrEmpty = abi.encode(true);
}

data = abi.encodePacked(
data = abi.encodeWithSelector(
_curveAddLiquidityEncodeSelector(orderedTokenAmounts.length, useUnderlying, fixedOrDynamic),
abi.encodePacked(orderedTokenAmounts),
orderedTokenAmounts,
minLPAmount,
finalEncodedArgOrEmpty
);
Expand All @@ -308,19 +307,9 @@ contract CurveHelper {
finalArgOrEmpty = ",bool";
}

if(fixedOrDynamic == FixedOrDynamic.Dynamic) {
return
bytes4(
keccak256(
abi.encodePacked(
"add_liquidity(uint256[],",
"uint256",
finalArgOrEmpty,
")"
)
)
);
}
if (fixedOrDynamic == FixedOrDynamic.Dynamic) {
return bytes4(keccak256(abi.encodePacked("add_liquidity(uint256[],", "uint256", finalArgOrEmpty, ")")));
}

// if not dynamic, it is fixed

Expand Down Expand Up @@ -376,19 +365,9 @@ contract CurveHelper {
finalArgOrEmpty = ",bool";
}

if(fixedOrDynamic == FixedOrDynamic.Dynamic) {
return
bytes4(
keccak256(
abi.encodePacked(
"remove_liquidity(uint256[],",
"uint256",
finalArgOrEmpty,
")"
)
)
);
}
if (fixedOrDynamic == FixedOrDynamic.Dynamic) {
return bytes4(keccak256(abi.encodePacked("remove_liquidity(uint256[],", "uint256", finalArgOrEmpty, ")")));
}

// if not dynamic, it is fixed

Expand Down Expand Up @@ -440,7 +419,7 @@ contract CurveHelper {
* @notice Helper function to get the underlying tokens in a Curve pool.
* 1st, it just checks if it'll revert with checking coins(i). So if we're expecting a large amount of coins, like 5, and it only has 3 coins in it, then it'll revert.
* 2nd, it tries 1 more than the index for the coins length of the pool... so if we are working with a pool with two coins, then it'll try pool.coins(2), but we know that it should max out at pool.coins(1). So why do the first check?
* For the try-catch, let's say we have
* For the try-catch, let's say we have
*/
function _getPoolUnderlyingTokens(
CurvePool pool,
Expand Down
35 changes: 14 additions & 21 deletions test/testAdaptors/CurveAdaptorNewPools.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ contract CurveAdaptorNewPoolsTest is MainnetStarterTest, AdaptorHelperFunctions
registry.trustPosition(
WeEthWethPoolPosition,
address(curveAdaptor),
abi.encode(WeEthWethPool, WeEthWethToken, WeEthWethGauge, CurvePool.withdraw_admin_fees.selector)
abi.encode(WeEthWethPool, WeEthWethToken, WeEthWethGauge, bytes4(keccak256(abi.encodePacked("D_oracle()"))))
);
registry.trustPosition(
WeethRswEthPoolPosition,
Expand Down Expand Up @@ -242,19 +242,19 @@ contract CurveAdaptorNewPoolsTest is MainnetStarterTest, AdaptorHelperFunctions
// TODO - assess if we need to do this test too
function testWithdrawLogic(uint256 assets) external {}

/// TODO - EIN happy path dynamic array pool tests - unsure why
/// TODO - EIN happy path dynamic array pool tests - unsure why

// weethWeth
function testManagingLiquidityInDynamicArrayPool0() external {
// assets = bound(assets, 1e6, 1_000_000e6);
uint256 assets = 1e6;
uint256 assets = 1_000_000e6;
_manageLiquidityIn2PoolDynamicArraysNoETH(
assets,
WeEthWethPool,
WeEthWethToken,
WeEthWethGauge,
0.0005e18,
CurvePool.withdraw_admin_fees.selector
0.01e18,
bytes4(keccak256(abi.encodePacked("D_oracle()")))
);
}

Expand Down Expand Up @@ -303,24 +303,17 @@ contract CurveAdaptorNewPoolsTest is MainnetStarterTest, AdaptorHelperFunctions
// ========================================= Reverts =========================================

// TODO - do we want to test this too?
function testSlippageRevertsNoETH( ) external {

}
function testSlippageRevertsNoETH() external {}

// TODO - do we want to test this too?
function testSlippageRevertsWithETH( ) external {

}
function testSlippageRevertsWithETH() external {}

// TODO - do we want to test this too?
function testReentrancyProtection3( ) external {
}
function testReentrancyProtection3() external {}
// ========================================= Reverts =========================================

// TODO - do we want to test this too?
function testInteractingWithPositionThatIsNotUsed() external {

}
function testInteractingWithPositionThatIsNotUsed() external {}

// TODO - assess if we need to do this test too
function testMismatchedArrayLengths() external {}
Expand Down Expand Up @@ -1034,10 +1027,10 @@ contract CurveAdaptorNewPoolsTest is MainnetStarterTest, AdaptorHelperFunctions
vm.roll(block.number + blocksToRoll);
mockWETHdataFeed.setMockUpdatedAt(block.timestamp);
mockUSDCdataFeed.setMockUpdatedAt(block.timestamp);
mockDAI_dataFeed.setMockUpdatedAt(block.timestamp);
mockUSDTdataFeed.setMockUpdatedAt(block.timestamp);
mockFRAXdataFeed.setMockUpdatedAt(block.timestamp);
mockSTETdataFeed.setMockUpdatedAt(block.timestamp);
mockRETHdataFeed.setMockUpdatedAt(block.timestamp);
// mockDAI_dataFeed.setMockUpdatedAt(block.timestamp);
// mockUSDTdataFeed.setMockUpdatedAt(block.timestamp);
// mockFRAXdataFeed.setMockUpdatedAt(block.timestamp);
// mockSTETdataFeed.setMockUpdatedAt(block.timestamp);
// mockRETHdataFeed.setMockUpdatedAt(block.timestamp);
}
}

0 comments on commit 3863f87

Please sign in to comment.