generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
TestDeFiAdapter.sol
210 lines (190 loc) · 6.03 KB
/
TestDeFiAdapter.sol
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IAdapterFull } from "@optyfi/defi-legos/interfaces/defiAdapters/contracts/IAdapterFull.sol";
import { MultiCall } from "../utils/MultiCall.sol";
///////////////////////////////////////
/// THIS CONTRACTS MOCKS AS A VAULT ///
///////////////////////////////////////
////////////////////////////////
/// DO NOT USE IN PRODUCTION ///
////////////////////////////////
contract TestDeFiAdapter is MultiCall {
function testGetDepositAllCodes(
address _underlyingToken,
address _liquidityPool,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getDepositAllCodes(payable(address(this)), _underlyingToken, _liquidityPool),
"depositAll"
);
}
function testGetDepositSomeCodes(
address _underlyingToken,
address _liquidityPool,
address _adapter,
uint256 _amount
) external {
executeCodes(
IAdapterFull(_adapter).getDepositSomeCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_amount
),
"depositSome"
);
}
function testGetBorrowAllCodes(
address _liquidityPool,
address _underlyingToken,
address _outputToken,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getBorrowAllCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_outputToken
),
"borrowAll"
);
}
function testGetStakeAllCodes(
address _liquidityPool,
address _underlyingToken,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getStakeAllCodes(payable(address(this)), _underlyingToken, _liquidityPool),
"stakeAll!"
);
}
function testGetStakeSomeCodes(
address _liquidityPool,
uint256 _stakeAmount,
address _adapter
) external {
executeCodes(IAdapterFull(_adapter).getStakeSomeCodes(_liquidityPool, _stakeAmount), "stakeSome!");
}
function testClaimRewardTokenCode(address _liquidityPool, address _adapter) external {
executeCodes(
IAdapterFull(_adapter).getClaimRewardTokenCode(payable(address(this)), _liquidityPool),
"claimReward"
);
}
function testGetHarvestAllCodes(
address _liquidityPool,
address _underlyingToken,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getHarvestAllCodes(payable(address(this)), _underlyingToken, _liquidityPool),
"harvestAll"
);
}
function testGetHarvestSomeCodes(
address _liquidityPool,
address _underlyingToken,
address _adapter,
uint256 _rewardTokenAmount
) external {
executeCodes(
IAdapterFull(_adapter).getHarvestSomeCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_rewardTokenAmount
),
"harvestSome"
);
}
function testGetUnstakeAllCodes(address _liquidityPool, address _adapter) external {
executeCodes(IAdapterFull(_adapter).getUnstakeAllCodes(payable(address(this)), _liquidityPool), "unstakeAll");
}
function testGetUnstakeSomeCodes(
address _liquidityPool,
uint256 _stakeAmount,
address _adapter
) external {
executeCodes(IAdapterFull(_adapter).getUnstakeSomeCodes(_liquidityPool, _stakeAmount), "unstakeAll");
}
function testGetWithdrawAllCodes(
address _underlyingToken,
address _liquidityPool,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getWithdrawAllCodes(payable(address(this)), _underlyingToken, _liquidityPool),
"withdrawAll"
);
}
function testGetWithdrawSomeCodes(
address _underlyingToken,
address _liquidityPool,
address _adapter,
uint256 _amount
) external {
executeCodes(
IAdapterFull(_adapter).getWithdrawSomeCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_amount
),
"withdrawSome"
);
}
function testGetRepayAndWithdrawAllCodes(
address _liquidityPool,
address _underlyingToken,
address _outputToken,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getRepayAndWithdrawAllCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_outputToken
),
"repayAndWithdrawAll"
);
}
function testGetUnstakeAndWithdrawAllCodes(
address _liquidityPool,
address _underlyingToken,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getUnstakeAndWithdrawAllCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool
),
"unstakeAndWithdrawAll"
);
}
function testGetUnstakeAndWithdrawSomeCodes(
address _liquidityPool,
address _underlyingToken,
uint256 _redeemAmount,
address _adapter
) external {
executeCodes(
IAdapterFull(_adapter).getUnstakeAndWithdrawSomeCodes(
payable(address(this)),
_underlyingToken,
_liquidityPool,
_redeemAmount
),
"unstakeAndWithdrawSome"
);
}
function getERC20TokenBalance(address _token, address _account) external view returns (uint256) {
return ERC20(_token).balanceOf(_account);
}
}