Repository navigation
Expand file tree
/
Copy pathDNModule.sol
More file actions
109 lines (89 loc) · 3.07 KB
/
Copy pathDNModule.sol
File metadata and controls
109 lines (89 loc) · 3.07 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "./interfaces/ICurveGauge.sol";
import "./GLPController.sol";
import "./AaveController.sol";
import {TaskDemo} from "./TaskDemo.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 DNModule is GLPController, AaveController, TaskDemo {
mapping(address => bool) public registeredSafes;
constructor(address _ops) TaskDemo(_ops) {}
function registerSafe() public {
require(!registeredSafes[msg.sender], "already safe");
registeredSafes[msg.sender] = true;
}
function initPosition(uint256 usdcAmt) public onlySafe {
GnosisSafe(msg.sender).execTransactionFromModule(
address(usdc),
0,
abi.encodeCall(usdc.transfer, (address(this), 1e6)),
Enum.Operation.Call
);
//Gelato task
registerSafe(msg.sender);
addFunds(1e6);
usdcAmt -= 1e6;
// GLP Position
GnosisSafe(msg.sender).execTransactionFromModule(
address(usdc),
0,
abi.encodeCall(usdc.approve, (address(glpManager), usdcAmt)),
Enum.Operation.Call
);
(address to, uint256 value, bytes memory callData) = GLPController
.depositUSDC(usdcAmt / 2);
GnosisSafe(msg.sender).execTransactionFromModule(
to,
value,
callData,
Enum.Operation.Call
);
// Aave Position
GnosisSafe(msg.sender).execTransactionFromModule(
address(usdc),
0,
abi.encodeCall(usdc.approve, (address(aavePool), usdcAmt / 2)),
Enum.Operation.Call
);
GnosisSafe(msg.sender).execTransactionFromModule(
address(aavePool),
0,
abi.encodeCall(
aavePool.supply,
(address(usdc), usdcAmt / 2, address(this), 0)
),
Enum.Operation.Call
);
uint256 wbtcAmt = ((usdcAmt / 2) * 1e2 * 1e8) / (10000 * 1e8);
GnosisSafe(msg.sender).execTransactionFromModule(
address(aavePool),
0,
abi.encodeCall(
aavePool.borrow,
(address(wbtc), wbtcAmt, 2, 0, address(this))
),
Enum.Operation.Call
);
}
function operateOnSafe(address safe) public {
GnosisSafe(safe).execTransactionFromModule(to, value, data, operation);
}
modifier onlySafe() {
require(registeredSafes[msg.sender], "only safe");
_;
}
}
// contract GLPRiskManager {}