Skip to content

Commit

Permalink
Fixed the sDAI vault (#1020)
Browse files Browse the repository at this point in the history
* Got the etching tools working

* Fixed the sDAI vault

* Implemented the etching tools for `RETH`

* Fixed the linter

* Updated the etching tools

* Fixed the linter

* Removed version from `package.json`
  • Loading branch information
jalextowle committed May 10, 2024
1 parent 299e3aa commit 40ca287
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"ethersproject",
"exitswap",
"extern",
"ezeth",
"gasleft",
"githubusercontent",
"gitmodules",
Expand All @@ -84,6 +85,7 @@
"joinswap",
"keccak",
"logx",
"lseth",
"mintable",
"mixedcase",
"mkdirp",
Expand Down
22 changes: 22 additions & 0 deletions contracts/test/MockERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,58 @@ contract MockERC4626 is ERC4626, MultiRolesAuthority {
/// Minting and Burning ///

function mint(uint256 amount) external requiresAuthDuringCompetition {
// If the sender is restricted to mint, ensure that their mint amount
// is less than the max mint amount.
if (!isUnrestricted[msg.sender]) {
require(
amount <= maxMintAmount,
"MockERC4626: Invalid mint amount"
);
}

// Mint assets to the vault.
ERC20Mintable(address(asset)).mint(convertToAssets(amount));

// Mint vault shares.
_mint(msg.sender, amount);
}

function mint(
address destination,
uint256 amount
) external requiresAuthDuringCompetition {
// If the sender is restricted to mint, ensure that their mint amount
// is less than the max mint amount.
if (!isUnrestricted[msg.sender]) {
require(
amount <= maxMintAmount,
"MockERC4626: Invalid mint amount"
);
}

// Mint assets to the vault.
ERC20Mintable(address(asset)).mint(convertToAssets(amount));

// Mint vault shares.
_mint(destination, amount);
}

function burn(uint256 amount) external requiresAuthDuringCompetition {
// Burn assets from the vault.
ERC20Mintable(address(asset)).burn(convertToAssets(amount));

// Burn the vault shares.
_burn(msg.sender, amount);
}

function burn(
address destination,
uint256 amount
) external requiresAuthDuringCompetition {
// Burn assets from the vault.
ERC20Mintable(address(asset)).burn(convertToAssets(amount));

// Burn the vault shares.
_burn(destination, amount);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "hyperdrive",
"version": "1.0.0",
"description": "Hyperdrive Smart Contracts",
"engines": {
"node": "^18"
Expand Down
15 changes: 7 additions & 8 deletions test/debug/Debugging.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IHyperdrive } from "contracts/src/interfaces/IHyperdrive.sol";
import { ETH } from "contracts/src/libraries/Constants.sol";
import { BaseTest } from "test/utils/BaseTest.sol";
import { EtchingUtils } from "test/utils/EtchingUtils.sol";
import { Lib } from "test/utils/Lib.sol";

/// @author DELV
/// @title Debugging
Expand All @@ -14,6 +15,8 @@ import { EtchingUtils } from "test/utils/EtchingUtils.sol";
/// only, and is not intended to, and does not, have any
/// particular legal or regulatory significance.
contract Debugging is BaseTest, EtchingUtils {
using Lib for *;

/// @dev A flag indicating whether or not the test should be skipped. This
/// should be set to false when debugging.
bool internal constant SHOULD_SKIP = true;
Expand All @@ -22,13 +25,13 @@ contract Debugging is BaseTest, EtchingUtils {
/// should be the block at which the transaction was failing. If you're
/// debugging a successful transaction, you may need to subtract one
/// from the block.
uint256 internal constant FORK_BLOCK = 5676348;
uint256 internal constant FORK_BLOCK = 5876130;

/// @dev The hyperdrive instance to connect to. If you're debugging a
/// Hyperdrive transaction, this should probably be the `to` address in
/// the failing transaction.
IHyperdrive internal constant HYPERDRIVE =
IHyperdrive(address(0x392839dA0dACAC790bd825C81ce2c5E264D793a8));
IHyperdrive(address(0xF2A8f3dcc019FD8F3EF286fe88F7efdd0c4D4b0c));

/// @dev The sender to use in the debugging call. If you're debugging a
/// Hyperdrive transaction, this should probably be the `from`
Expand All @@ -45,18 +48,14 @@ contract Debugging is BaseTest, EtchingUtils {
/// Hyperdrive transaction, this should probably be the calldata from
/// the failing transaction (remove the "0x" prefix from the calldata).
bytes internal constant CALLDATA =
hex"cba2e58d0000000000000000000000000000000000000000000007d9a5405edc26fa36b50000000000000000000000000000000000000000000007d7f3c7d8d354cd71990000000000000000000000000000000000000000000000000de326f195450cd200000000000000000000000000000000000000000000000000000000000000800000000000000000000000002c76cc659ec83e36323f32e6a9789c29e7b56c4b0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000";
hex"cba2e58d00000000000000000000000000000000000000000000006c6b935b8bbd400000000000000000000000000000000000000000000000000044c704eb74e081ea6600000000000000000000000000000000000000000000000008d2495c9d20228d00000000000000000000000000000000000000000000000000000000000000800000000000000000000000002c76cc659ec83e36323f32e6a9789c29e7b56c4b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000";

function test_debug() external __sepolia_fork(FORK_BLOCK) {
// Skip this test during regular execution.
vm.skip(SHOULD_SKIP);

// Etch the hyperdrive instance to add console logs.
if (HYPERDRIVE.baseToken() == ETH) {
etchStETHHyperdrive(address(HYPERDRIVE));
} else {
etchERC4626Hyperdrive(address(HYPERDRIVE));
}
etchHyperdrive(address(HYPERDRIVE));

// Log a preamble.
console.log("---------------");
Expand Down
Loading

0 comments on commit 40ca287

Please sign in to comment.