Skip to content

Commit

Permalink
fix: zappers approvals fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lekhovitsky committed Sep 19, 2023
1 parent c1b5425 commit 5b70b95
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions contracts/interfaces/zappers/IZapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pragma solidity ^0.8.17;
interface IZapper {
function pool() external view returns (address);

function unwrappedToken() external view returns (address);

function tokenOut() external view returns (address);

function unwrappedToken() external view returns (address);

function wrappedToken() external view returns (address);

function previewDeposit(uint256 amount) external view returns (uint256 shares);
Expand Down
2 changes: 1 addition & 1 deletion contracts/zappers/WATokenZapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract WATokenZapper is WERC20ZapperBase {
/// @param pool_ Pool to connect this zapper to
constructor(address pool_) WERC20ZapperBase(pool_) {
_aToken = WrappedAToken(wrappedToken).aToken();
_resetWrapperAllowance();
super._resetWrapperAllowance();
}

/// @notice aToken address
Expand Down
4 changes: 2 additions & 2 deletions contracts/zappers/WERC20ZapperBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {ZapperBase} from "./ZapperBase.sol";
/// @notice Base contract for zappers allowing users to deposit/withdraw an ERC20 token
/// to/from a Gearbox pool with its wrapper as underlying in a single operation
/// @dev Default implementation assumes that unwrapped token has no transfer fees
/// @dev Derived zappers must call `_resetWrapperAllowance` in their constructor after
/// initializing `unwrappedToken()`
/// @dev Derived zappers must call `super._resetWrapperAllowance()` in their constructor
/// after initializing `unwrappedToken()`
abstract contract WERC20ZapperBase is ZapperBase, IWERC20Zapper {
using SafeERC20 for IERC20;

Expand Down
4 changes: 1 addition & 3 deletions contracts/zappers/WETHZapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ contract WETHZapper is ZapperBase, IWETHZapper {

/// @notice Constructor
/// @param pool_ Pool to connect this zapper to
constructor(address pool_) ZapperBase(pool_) {
super._resetPoolAllowance();
}
constructor(address pool_) ZapperBase(pool_) {}

/// @notice Allows this contract to unwrap WETH and forbids other direct ETH transfers
receive() external payable {
Expand Down
2 changes: 1 addition & 1 deletion contracts/zappers/WstETHZapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract WstETHZapper is WERC20ZapperBase {
/// @param pool_ Pool to connect this zapper to
constructor(address pool_) WERC20ZapperBase(pool_) {
_stETH = IwstETH(wrappedToken).stETH();
_resetWrapperAllowance();
super._resetWrapperAllowance();
}

/// @notice stETH address
Expand Down
11 changes: 6 additions & 5 deletions contracts/zappers/ZapperBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ abstract contract ZapperBase is IZapper {
/// @notice Underlying token of the pool
address public immutable override wrappedToken;

/// @notice Token this zapper returns when deposit (underlying / staked one)
address public immutable override tokenOut;

/// @notice Constructor
/// @param pool_ Pool to connect this zapper to
constructor(address pool_) {
pool = pool_;
wrappedToken = IPoolV3(pool_).asset();
tokenOut = pool_;
_resetPoolAllowance();
ZapperBase._resetPoolAllowance();
}

/// @notice Token that this zapper produces (might differ from the pool share token)
function tokenOut() public view virtual override returns (address) {
return pool;
}

/// @notice Returns number of pool shares one would receive for depositing `amount` of unwrapped token
Expand Down

0 comments on commit 5b70b95

Please sign in to comment.