Curve Adapter (Stable and Crypto Swap) (#29)

* feat: Initial manifest structure

* feat: Adapter initial development and price function implementation

* feat: Implemented getPoolIDs

* feat: Implemented getTokens

* feat: Implemented getCapabilities

* feat: Implemented getLimits

* feat: Implemented swap

* feat: Created Adapter version for CurveV2 pools uint256

* fix: Review Fixes

* chore: Formatted code and code adjustments

* feat: Separated contracts and finished tests for Curve Exchange(Crypto and StableSwap)

* feat: Adjusted naming and formatted tests code

* chore: Initial merging of swaps

* merge CurveCryptoSwapAdapter and CurveStableSwapAdapter into CurveAdapter

* Fix and Test: fixes on CurveAdapter.sol and created CurveAdapter.t.sol

* review and fixes

* removed unused test and parameters

* chore: Initial MetaPool underlying swap and ETH native implementation

* chore: expanded swap and sell functions to support seap for underlying tokens and LPS

* chore: expanded functionalities of CurveAdapter and fixed getTokens function

* fix: fixed registry.is_meta

* chore: fixes

* chore: extended adapter and implementing tests for new pools

* chore: updated Adapter, implementing final tests

* fixing eth transfer

* fix and tests: fixed adapter and finishing tests implementation

* using adapter with try catch

* feat: Final fixes for pools support, using try-catch

* chore: Removed chunk files

* chore: Formatted code and removed unused condition

* fix: Fixed calculatedAmount in sell function when receiveToken=ETH

* chore: Adjusted ETH pools check

* corrected metaregistry address

* fix: fixed int128 conversion to unit256

* feat: Removed registry from adapter

* feat: Implemented price()

* fix: Propeller review fixes

* review fixes

* fix: Final fixes for custom custom int128 pools

* chore: Removed unused test

* fix: Fixed price error in custom pools

* feat: Improved isInt128Pool function to support any coin

* fix: Fixed price for custom pools using ETH balance when token0 is WETH

* fix: Fixed price function and added AdapterTest support in test

* fix: Fixed divisions in getPriceAt

* feat: Added secondary ETH pool support, e.g. stETH

* refactor(curve-adapter): Avoid calling WETH contract if possible. (#65)

* refactor(curve-adapter): Avoid calling WETH contract if possible.

This PR aims to use native ETH instead of WETH when possible, this is to avoid having to index WETH contract.

* style(adapter): apply `forge fmt`

* refactor(curve): change limit factor to 2

---------

Co-authored-by: Florian Pellissier <111426680+flopell@users.noreply.github.com>

* refactor: fix Curve Adapter test after rebase

* fix: remove PriceFunction capability for Curve

This was wrongly implemented: it return the price for a quote and not the marginal price after the swap.

* refactor: improve adapter test and fix failing test for etherfi

---------

Co-authored-by: domenicodev <domenico.romeo3919@gmail.com>
Co-authored-by: mp-web3 <mp.web3.t@gmail.com>
Co-authored-by: Zizou <111426680+zizou0x@users.noreply.github.com>
Co-authored-by: Florian Pellissier <111426680+flopell@users.noreply.github.com>
Co-authored-by: Diana Carvalho <diana@propellerheads.xyz>
This commit is contained in:
Domenico
2025-06-27 12:03:32 +02:00
committed by GitHub
parent 1885467616
commit 7f9a995e8a
5 changed files with 1077 additions and 7 deletions

View File

@@ -28,7 +28,10 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
receive() external payable {}
function testPriceFuzzEtherfi(uint256 amount0, uint256 amount1) public {
function testPriceFuzzEtherfi(uint256 amount0, uint256 amount1)
public
view
{
bytes32 pair = bytes32(0);
uint256[] memory limits = adapter.getLimits(
pair, address(address(weEth)), address(address(eEth))
@@ -319,10 +322,10 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
weEth_.balanceOf(address(this)) - weEth_balance
);
/// @dev Transfer function contains rounding errors because of
/// rewards in eETH contract, therefore we assume a +/-2
/// rewards in eETH contract, therefore we assume a +/-4
/// tolerance
assertLe(
specifiedAmount - 2,
specifiedAmount - 4,
weEth_.balanceOf(address(this)) - weEth_balance
);
assertEq(
@@ -386,6 +389,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
function testGetCapabilitiesEtherfi(bytes32 pair, address t0, address t1)
public
view
{
Capability[] memory res =
adapter.getCapabilities(pair, address(t0), address(t1));
@@ -393,14 +397,14 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
assertEq(res.length, 3);
}
function testGetTokensEtherfi() public {
function testGetTokensEtherfi() public view {
bytes32 pair = bytes32(0);
address[] memory tokens = adapter.getTokens(pair);
assertEq(tokens.length, 3);
}
function testGetLimitsEtherfi() public {
function testGetLimitsEtherfi() public view {
bytes32 pair = bytes32(0);
uint256[] memory limits =
adapter.getLimits(pair, address(eEth), address(weEth));