feat: Add TokenTransfer class to Curve
- This needed to be in Curve so that the executor can also take care of transfers from the user into the tycho router, to avoid having transfer actions mixed between the router and executors
This commit is contained in:
committed by
Diana Carvalho
parent
dbc9042a2f
commit
462be5463b
@@ -3,6 +3,7 @@ pragma solidity ^0.8.26;
|
||||
|
||||
import "@interfaces/IExecutor.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||
import "./TokenTransfer.sol";
|
||||
|
||||
error CurveExecutor__AddressZero();
|
||||
|
||||
@@ -32,12 +33,14 @@ interface CryptoPoolETH {
|
||||
// slither-disable-end naming-convention
|
||||
}
|
||||
|
||||
contract CurveExecutor is IExecutor {
|
||||
contract CurveExecutor is IExecutor, TokenTransfer {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
address public immutable nativeToken;
|
||||
|
||||
constructor(address _nativeToken) {
|
||||
constructor(address _nativeToken, address _permit2)
|
||||
TokenTransfer(_permit2)
|
||||
{
|
||||
if (_nativeToken == address(0)) {
|
||||
revert CurveExecutor__AddressZero();
|
||||
}
|
||||
@@ -57,9 +60,12 @@ contract CurveExecutor is IExecutor {
|
||||
uint8 poolType,
|
||||
int128 i,
|
||||
int128 j,
|
||||
bool tokenApprovalNeeded
|
||||
bool tokenApprovalNeeded,
|
||||
TransferType transferType
|
||||
) = _decodeData(data);
|
||||
|
||||
_transfer(tokenIn, msg.sender, pool, amountIn, transferType);
|
||||
|
||||
if (tokenApprovalNeeded && tokenIn != nativeToken) {
|
||||
// slither-disable-next-line unused-return
|
||||
IERC20(tokenIn).approve(address(pool), type(uint256).max);
|
||||
@@ -105,7 +111,8 @@ contract CurveExecutor is IExecutor {
|
||||
uint8 poolType,
|
||||
int128 i,
|
||||
int128 j,
|
||||
bool tokenApprovalNeeded
|
||||
bool tokenApprovalNeeded,
|
||||
TransferType transferType
|
||||
)
|
||||
{
|
||||
tokenIn = address(bytes20(data[0:20]));
|
||||
@@ -115,6 +122,7 @@ contract CurveExecutor is IExecutor {
|
||||
i = int128(uint128(uint8(data[61])));
|
||||
j = int128(uint128(uint8(data[62])));
|
||||
tokenApprovalNeeded = data[63] != 0;
|
||||
transferType = TransferType(uint8(data[64]));
|
||||
}
|
||||
|
||||
receive() external payable {
|
||||
|
||||
Reference in New Issue
Block a user