Repository navigation
Expand file tree
/
Copy pathCurveModule.sol
More file actions
54 lines (48 loc) · 1.69 KB
/
Copy pathCurveModule.sol
File metadata and controls
54 lines (48 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "./interfaces/ICurveGauge.sol";
import "./Enum.sol";
interface GnosisSafe {
/// @dev Allows a Module to execute a Safe transaction without any further confirmations.
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModule(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation
) external returns (bool success);
}
contract CurveModule {
/// @dev Address that this module will pass transactions to.
ICurveGauge internal curveGauge =
ICurveGauge(0x9633E0749faa6eC6d992265368B88698d6a93Ac0);
function harvest(address safe, address keeper)
public
claimGas(safe, keeper)
returns (bool success)
{
success = GnosisSafe(safe).execTransactionFromModule(
address(curveGauge),
0,
abi.encodeWithSignature("claim_rewards()"),
Enum.Operation.Call
);
return success;
}
modifier claimGas(address safe, address recipient) {
uint256 startGas = gasleft();
_;
uint256 endGas = gasleft();
uint256 totalFee = (startGas - endGas + 50000) * tx.gasprice; // Adding 50k for additional eth transfer using gnosis
bool success = GnosisSafe(safe).execTransactionFromModule(
recipient,
totalFee,
abi.encodeWithSignature(""),
Enum.Operation.Call
);
require(success);
}
}