Skip to content

Commit 9090a0d

Browse files
committed
got debug working
1 parent 884e5bd commit 9090a0d

16 files changed

+60
-4296
lines changed

contracts/src/interfaces/ISwapRouter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
pragma solidity ^0.8.22;
2+
pragma solidity ^0.8.20;
33

44
interface ISwapRouter {
55
struct ExactInputSingleParams {

contracts/src/interfaces/IUniV3Zap.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
33

44
import { IHyperdrive } from "./IHyperdrive.sol";
55
import { ISwapRouter } from "./ISwapRouter.sol";
6+
import { IWETH } from "./IWETH.sol";
67

78
/// @title IUniV3Zap
89
/// @author DELV
@@ -286,4 +287,8 @@ interface IUniV3Zap {
286287
/// @notice Returns the Uniswap swap router.
287288
/// @return The Uniswap swap router.
288289
function swapRouter() external view returns (ISwapRouter);
290+
291+
/// @notice Returns the Uniswap swap router.
292+
/// @return The Uniswap swap router.
293+
function weth() external view returns (IWETH);
289294
}

contracts/src/zaps/UniV3Zap.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
pragma solidity 0.8.22;
2+
pragma solidity 0.8.20;
3+
4+
// FIXME
5+
import { console2 as console } from "forge-std/console2.sol";
36

47
import { ERC20 } from "openzeppelin/token/ERC20/ERC20.sol";
58
import { ReentrancyGuard } from "openzeppelin/utils/ReentrancyGuard.sol";
@@ -371,12 +374,14 @@ contract UniV3Zap is IUniV3Zap, ReentrancyGuard {
371374
bool _shouldWrap
372375
) external nonReentrant returns (uint256 proceeds) {
373376
// Validate the zap parameters.
377+
console.log("closeLongZap: 1");
374378
address proceedsAsset = _validateZapOut(
375379
_hyperdrive,
376380
_options,
377381
_swapParams,
378382
_shouldWrap
379383
);
384+
console.log("closeLongZap: 2");
380385

381386
// Take custody of the long position.
382387
_hyperdrive.transferFrom(
@@ -385,6 +390,7 @@ contract UniV3Zap is IUniV3Zap, ReentrancyGuard {
385390
address(this),
386391
_bondAmount
387392
);
393+
console.log("closeLongZap: 3");
388394

389395
// Close the long, zap the proceeds into the target asset, and send
390396
// them to the trader.
@@ -395,7 +401,10 @@ contract UniV3Zap is IUniV3Zap, ReentrancyGuard {
395401
// tokens. As a consequence, we don't need the output value of closing
396402
// the long position.
397403
_hyperdrive.closeLong(_maturityTime, _bondAmount, _minOutput, _options);
404+
console.log("closeLongZap: 4");
398405
proceeds = _zapOut(_swapParams, proceedsAsset, _shouldWrap);
406+
console.log("closeLongZap: 5");
407+
console.log("proceeds = %s", proceeds);
399408

400409
return proceeds;
401410
}
@@ -946,7 +955,8 @@ contract UniV3Zap is IUniV3Zap, ReentrancyGuard {
946955
}
947956
// Otherwise, we can use the built-in `convertToShares` function.
948957
else {
949-
return _hyperdrive.convertToShares(_baseAmount);
958+
revert("");
959+
// return _hyperdrive.convertToShares(_baseAmount);
950960
}
951961
}
952962
}

test/debug/Debug.t.sol

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
pragma solidity 0.8.20;
33

44
import { console2 as console } from "forge-std/console2.sol";
5-
import { IHyperdriveCore } from "contracts/src/interfaces/IHyperdriveCore.sol";
6-
import { IMultiTokenCore } from "contracts/src/interfaces/IMultiTokenCore.sol";
7-
import { ETH } from "contracts/src/libraries/Constants.sol";
8-
import { BaseTest } from "test/utils/BaseTest.sol";
9-
import { EtchingUtils } from "test/utils/EtchingUtils.sol";
10-
import { Lib } from "test/utils/Lib.sol";
5+
import { IHyperdriveCore } from "../../contracts/src/interfaces/IHyperdriveCore.sol";
6+
import { IMultiTokenCore } from "../../contracts/src/interfaces/IMultiTokenCore.sol";
7+
import { IUniV3Zap } from "../../contracts/src/interfaces/IUniV3Zap.sol";
8+
import { ETH } from "../../contracts/src/libraries/Constants.sol";
9+
import { UniV3Zap } from "../../contracts/src/zaps/UniV3Zap.sol";
10+
import { BaseTest } from "../utils/BaseTest.sol";
11+
import { EtchingUtils } from "../utils/EtchingUtils.sol";
12+
import { Lib } from "../utils/Lib.sol";
1113

1214
/// @author DELV
1315
/// @title Debugging
@@ -68,12 +70,22 @@ contract Debug is BaseTest, EtchingUtils {
6870
/// @dev Debugs the provided Hyperdrive transaction.
6971
/// @param _tx The transaction to debug.
7072
function debug(Transaction memory _tx) internal {
73+
// Etch the UniV3Zap contract.
74+
console.log("test: 1");
75+
IUniV3Zap zap = IUniV3Zap(_tx.to);
76+
{
77+
UniV3Zap template = new UniV3Zap("", zap.swapRouter(), zap.weth());
78+
vm.etch(address(zap), address(template).code);
79+
}
80+
console.log("test: 2");
81+
7182
// Etch the hyperdrive instance to add console logs.
7283
(
7384
string memory name,
7485
string memory kind,
7586
string memory version
76-
) = etchHyperdrive(_tx.to);
87+
) = etchHyperdrive(address(0x324395D5d835F84a02A75Aa26814f6fD22F25698));
88+
console.log("test: 3");
7789

7890
// Log a preamble with the Hyperdrive name, version, and the function
7991
// that will be called.

test/utils/EtchingUtils.sol

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity 0.8.20;
33

4+
// FIXME
5+
import { console2 as console } from "forge-std/console2.sol";
6+
47
import { Test } from "forge-std/Test.sol";
58
import { ERC4626Hyperdrive } from "contracts/src/instances/erc4626/ERC4626Hyperdrive.sol";
69
import { ERC4626Target0 } from "contracts/src/instances/erc4626/ERC4626Target0.sol";
@@ -53,24 +56,25 @@ contract EtchingUtils is Test {
5356
// Ensure that the contract's version matches.
5457
IHyperdrive hyperdrive = IHyperdrive(_hyperdrive);
5558
string memory version = hyperdrive.version();
56-
if (!hyperdrive.version().eq(VERSION)) {
57-
revert(
58-
vm.replace(
59-
vm.replace(
60-
"EtchingUtils: The checked-out version is %0 but the target version is %1. Consider checking out the target version",
61-
"%0",
62-
VERSION
63-
),
64-
"%1",
65-
version
66-
)
67-
);
68-
}
59+
// if (!hyperdrive.version().eq(VERSION)) {
60+
// revert(
61+
// vm.replace(
62+
// vm.replace(
63+
// "EtchingUtils: The checked-out version is %0 but the target version is %1. Consider checking out the target version",
64+
// "%0",
65+
// VERSION
66+
// ),
67+
// "%1",
68+
// version
69+
// )
70+
// );
71+
// }
6972

7073
// Using the name, decide which type of Hyperdrive instance needs to
7174
// be etched.
7275
string memory kind = hyperdrive.kind();
7376
if (kind.eq(ERC4626_HYPERDRIVE_KIND)) {
77+
console.log("erc4626 vault");
7478
etchERC4626Hyperdrive(_hyperdrive);
7579
} else if (kind.eq(EZETH_HYPERDRIVE_KIND)) {
7680
etchEzETHHyperdrive(_hyperdrive);
@@ -98,44 +102,15 @@ contract EtchingUtils is Test {
98102
// used to load immutables that will be used during the etching process.
99103
IHyperdrive hyperdrive = IHyperdrive(_hyperdrive);
100104

101-
// Etch the base contract.
102-
{
103-
ERC20Mintable target = ERC20Mintable(hyperdrive.baseToken());
104-
ERC20Mintable template = new ERC20Mintable(
105-
target.name(),
106-
target.symbol(),
107-
target.decimals(),
108-
address(0),
109-
target.isCompetitionMode(),
110-
target.maxMintAmount()
111-
);
112-
vm.etch(address(target), address(template).code);
113-
}
114-
115-
// TODO: Remove this once we leave testnet.
116-
//
117-
// Etch the vault contract.
118-
{
119-
MockERC4626 target = MockERC4626(hyperdrive.vaultSharesToken());
120-
MockERC4626 template = new MockERC4626(
121-
ERC20Mintable(address(target.asset())),
122-
target.name(),
123-
target.symbol(),
124-
0,
125-
address(0),
126-
target.isCompetitionMode(),
127-
target.maxMintAmount()
128-
);
129-
vm.etch(address(target), address(template).code);
130-
}
131-
132105
// Etch the target0 contract.
106+
console.log("etchERC4626Hyperdrive: 1");
133107
{
134108
ERC4626Target0 template = new ERC4626Target0(
135109
hyperdrive.getPoolConfig()
136110
);
137111
vm.etch(hyperdrive.target0(), address(template).code);
138112
}
113+
console.log("etchERC4626Hyperdrive: 2");
139114

140115
// Etch the target1 contract.
141116
{
@@ -144,6 +119,7 @@ contract EtchingUtils is Test {
144119
);
145120
vm.etch(hyperdrive.target1(), address(template).code);
146121
}
122+
console.log("etchERC4626Hyperdrive: 3");
147123

148124
// Etch the target2 contract.
149125
{
@@ -152,6 +128,7 @@ contract EtchingUtils is Test {
152128
);
153129
vm.etch(hyperdrive.target2(), address(template).code);
154130
}
131+
console.log("etchERC4626Hyperdrive: 4");
155132

156133
// Etch the target3 contract.
157134
{
@@ -160,6 +137,7 @@ contract EtchingUtils is Test {
160137
);
161138
vm.etch(hyperdrive.target3(), address(template).code);
162139
}
140+
console.log("etchERC4626Hyperdrive: 5");
163141

164142
// Etch the hyperdrive contract.
165143
{
@@ -175,6 +153,7 @@ contract EtchingUtils is Test {
175153
);
176154
vm.etch(address(hyperdrive), address(template).code);
177155
}
156+
console.log("etchERC4626Hyperdrive: 6");
178157
}
179158

180159
function etchEzETHHyperdrive(address _hyperdrive) internal {

0 commit comments

Comments
 (0)