-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(StakeVault): make unstaking actually work
Unstaking didn't actually work because it was using `transferFrom()` on the `StakeVault` with the `from` address being the vault itself. This would result in an approval error because the vault isn't creating any approvals to spend its own funds. The solution is to use `transfer` instead and ensuring the return value is checked.
- Loading branch information
Showing
5 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.19; | ||
|
||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract BrokenERC20 is ERC20 { | ||
constructor() ERC20("Mock SNT", "SNT") { | ||
_mint(msg.sender, 1_000_000_000_000_000_000); | ||
} | ||
|
||
// solhint-disable-next-line no-unused-vars | ||
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { | ||
return false; | ||
} | ||
|
||
// solhint-disable-next-line no-unused-vars | ||
function transfer(address recipient, uint256 amount) public override returns (bool) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.19; | ||
|
||
import { BaseScript } from "../../script/Base.s.sol"; | ||
import { StakeManager } from "../../contracts/StakeManager.sol"; | ||
import { VaultFactory } from "../../contracts/VaultFactory.sol"; | ||
import { BrokenERC20 } from "../mocks/BrokenERC20.s.sol"; | ||
|
||
contract DeployBroken is BaseScript { | ||
function run() public returns (VaultFactory, StakeManager, address) { | ||
BrokenERC20 token = new BrokenERC20(); | ||
|
||
vm.startBroadcast(broadcaster); | ||
StakeManager stakeManager = new StakeManager(address(token), address(0)); | ||
VaultFactory vaultFactory = new VaultFactory(address(stakeManager)); | ||
vm.stopBroadcast(); | ||
|
||
return (vaultFactory, stakeManager, address(token)); | ||
} | ||
} |