-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multicall and converter in LockstakeEngine (#7)
* Support multicall for LockstakeEngine * Sketch use of converter inside LockstakeEngine * Send out ngt from converter, separate events * Add index parameter to open() * Approve tokens to mkrNgt in the constructor * gov => mkr, stkGov => stkMkr * public => external Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com> * Change revert message * new line at end of file Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com> * Put ngt functions after regular ones * Change order of events as well Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com> * ngt tests and testing open with wrong index --------- Co-authored-by: sunbreak <sunbreak1211@proton.me> Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
- Loading branch information
1 parent
87b9a68
commit bc63780
Showing
4 changed files
with
399 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// Based on https://github.com/Uniswap/v3-periphery/blob/697c2474757ea89fec12a4e6db16a574fe259610/contracts/base/Multicall.sol | ||
|
||
pragma solidity ^0.8.16; | ||
|
||
// Enables calling multiple methods in a single call to the contract | ||
abstract contract Multicall { | ||
function multicall(bytes[] calldata data) external returns (bytes[] memory results) { | ||
results = new bytes[](data.length); | ||
for (uint256 i = 0; i < data.length; i++) { | ||
(bool success, bytes memory result) = address(this).delegatecall(data[i]); | ||
|
||
if (!success) { | ||
// Next 5 lines from https://ethereum.stackexchange.com/a/83577 | ||
if (result.length < 68) revert(); | ||
assembly { | ||
result := add(result, 0x04) | ||
} | ||
revert(abi.decode(result, (string))); | ||
} | ||
|
||
results[i] = result; | ||
} | ||
} | ||
} |
Oops, something went wrong.