From d55b71c27a7d3b290e7a8d66959f2c9fdb9e362b Mon Sep 17 00:00:00 2001 From: Shivaansh Kapoor Date: Mon, 9 Dec 2024 14:41:33 -0800 Subject: [PATCH] fix tether approvals --- src/WrappedVault.sol | 2 +- test/DebugWV.t.sol | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/DebugWV.t.sol diff --git a/src/WrappedVault.sol b/src/WrappedVault.sol index 69cf4c7..6bc6a6a 100644 --- a/src/WrappedVault.sol +++ b/src/WrappedVault.sol @@ -148,7 +148,7 @@ contract WrappedVault is Ownable, InitializableERC20, IWrappedVault { _mint(address(0), 10_000); // Burn 10,000 wei to stop 'first share' front running attacks on depositors - DEPOSIT_ASSET.approve(vault, type(uint256).max); + DEPOSIT_ASSET.safeApprove(vault, type(uint256).max); } /// @param rewardsToken The new reward token / points program to be used as incentives diff --git a/test/DebugWV.t.sol b/test/DebugWV.t.sol new file mode 100644 index 0000000..add8090 --- /dev/null +++ b/test/DebugWV.t.sol @@ -0,0 +1,45 @@ +// SPDX-Liense-Identifier: AGPL-3.0-only +pragma solidity ^0.8.0; + +import { MockERC20 } from "test/mocks/MockERC20.sol"; +import { MockERC4626 } from "test/mocks/MockERC4626.sol"; + +import { ERC20 } from "lib/solmate/src/tokens/ERC20.sol"; +import { ERC4626 } from "lib/solmate/src/tokens/ERC4626.sol"; + +import { WrappedVault } from "src/WrappedVault.sol"; +import { WrappedVaultFactory } from "src/WrappedVaultFactory.sol"; + +import { FixedPointMathLib } from "lib/solmate/src/utils/FixedPointMathLib.sol"; +import { Owned } from "lib/solmate/src/auth/Owned.sol"; +import { Ownable2Step, Ownable } from "lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol"; + +import { PointsFactory } from "src/PointsFactory.sol"; +import { Ownable as SoladyOwnable } from "lib/solady/src/auth/Ownable.sol"; + +import { Test, console } from "forge-std/Test.sol"; + +contract WrappedVaultTest is Test { + using FixedPointMathLib for *; + + WrappedVaultFactory testFactory; + uint256 mainnetFork; + address owner = 0x85De42e5697D16b853eA24259C42290DaCe35190; + + function setUp() public { + mainnetFork = vm.createFork("https://gateway.tenderly.co/public/mainnet"); + vm.selectFork(mainnetFork); + + testFactory = WrappedVaultFactory(0x75E502644284eDf34421f9c355D75DB79e343Bca); + } + + function testTetherVault() external { + address wvi = address(new WrappedVault()); + + vm.startPrank(owner); + testFactory.updateWrappedVaultImplementation(wvi); + vm.stopPrank(); + + testFactory.wrapVault(ERC4626(0x5C20B550819128074FD538Edf79791733ccEdd18), 0x9FC3da866e7DF3a1c57adE1a97c9f00a70f010c8, "Test123", 5_000_000_000_000_000); + } +}