Skip to content

Commit cddfd4b

Browse files
committed
refactor: rename depositAsset to asset
1 parent 791763f commit cddfd4b

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

contracts/helpers/BaseHarvester.sol

+21-21
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import "../interfaces/IHarvester.sol";
1313

1414
struct YieldBearingParams {
1515
// Address of the asset used to mint the yield bearing asset
16-
address depositAsset;
16+
address asset;
1717
// Target exposure to the collateral yield bearing asset used
1818
uint64 targetExposure;
1919
// Maximum exposure within the Transmuter to the deposit asset
@@ -92,23 +92,23 @@ abstract contract BaseHarvester is IHarvester, AccessControl {
9292
/**
9393
* @notice Set the yieldBearingAsset data
9494
* @param yieldBearingAsset address of the yieldBearingAsset
95-
* @param depositAsset address of the depositAsset
95+
* @param asset address of the asset
9696
* @param targetExposure target exposure to the yieldBearingAsset asset used
97-
* @param minExposure minimum exposure within the Transmuter to the depositAsset
98-
* @param maxExposure maximum exposure within the Transmuter to the depositAsset
97+
* @param minExposure minimum exposure within the Transmuter to the asset
98+
* @param maxExposure maximum exposure within the Transmuter to the asset
9999
* @param overrideExposures whether limit exposures should be overriden or read onchain through the Transmuter
100100
*/
101101
function setYieldBearingAssetData(
102102
address yieldBearingAsset,
103-
address depositAsset,
103+
address asset,
104104
uint64 targetExposure,
105105
uint64 minExposure,
106106
uint64 maxExposure,
107107
uint64 overrideExposures
108108
) external onlyGuardian {
109109
_setYieldBearingAssetData(
110110
yieldBearingAsset,
111-
depositAsset,
111+
asset,
112112
targetExposure,
113113
minExposure,
114114
maxExposure,
@@ -117,13 +117,13 @@ abstract contract BaseHarvester is IHarvester, AccessControl {
117117
}
118118

119119
/**
120-
* @notice Set the limit exposures to the depositAsset linked to the yield bearing asset
120+
* @notice Set the limit exposures to the asset linked to the yield bearing asset
121121
* @param yieldBearingAsset address of the yield bearing asset
122122
*/
123123
function updateLimitExposuresYieldAsset(address yieldBearingAsset) public virtual {
124124
YieldBearingParams storage yieldBearingInfo = yieldBearingData[yieldBearingAsset];
125125
if (yieldBearingInfo.overrideExposures == 2)
126-
_updateLimitExposuresYieldAsset(yieldBearingInfo.depositAsset, yieldBearingInfo);
126+
_updateLimitExposuresYieldAsset(yieldBearingInfo.asset, yieldBearingInfo);
127127
}
128128

129129
/**
@@ -180,39 +180,39 @@ abstract contract BaseHarvester is IHarvester, AccessControl {
180180
(uint256 stablecoinsFromYieldBearingAsset, uint256 stablecoinsIssued) = transmuter.getIssuedByCollateral(
181181
yieldBearingAsset
182182
);
183-
(uint256 stablecoinsFromDepositAsset, ) = transmuter.getIssuedByCollateral(yieldBearingInfo.depositAsset);
183+
(uint256 stablecoinsFromAsset, ) = transmuter.getIssuedByCollateral(yieldBearingInfo.asset);
184184
uint256 targetExposureScaled = yieldBearingInfo.targetExposure * stablecoinsIssued;
185185
if (stablecoinsFromYieldBearingAsset * 1e9 > targetExposureScaled) {
186186
// Need to decrease exposure to yield bearing asset
187187
amount = stablecoinsFromYieldBearingAsset - targetExposureScaled / 1e9;
188188
uint256 maxValueScaled = yieldBearingInfo.maxExposure * stablecoinsIssued;
189189
// These checks assume that there are no transaction fees on the stablecoin->collateral conversion and so
190190
// it's still possible that exposure goes above the max exposure in some rare cases
191-
if (stablecoinsFromDepositAsset * 1e9 > maxValueScaled) amount = 0;
192-
else if ((stablecoinsFromDepositAsset + amount) * 1e9 > maxValueScaled)
193-
amount = maxValueScaled / 1e9 - stablecoinsFromDepositAsset;
191+
if (stablecoinsFromAsset * 1e9 > maxValueScaled) amount = 0;
192+
else if ((stablecoinsFromAsset + amount) * 1e9 > maxValueScaled)
193+
amount = maxValueScaled / 1e9 - stablecoinsFromAsset;
194194
} else {
195195
// In this case, exposure after the operation might remain slightly below the targetExposure as less
196196
// collateral may be obtained by burning stablecoins for the yield asset and unwrapping it
197197
increase = 1;
198198
amount = targetExposureScaled / 1e9 - stablecoinsFromYieldBearingAsset;
199199
uint256 minValueScaled = yieldBearingInfo.minExposure * stablecoinsIssued;
200-
if (stablecoinsFromDepositAsset * 1e9 < minValueScaled) amount = 0;
201-
else if (stablecoinsFromDepositAsset * 1e9 < minValueScaled + amount * 1e9)
202-
amount = stablecoinsFromDepositAsset - minValueScaled / 1e9;
200+
if (stablecoinsFromAsset * 1e9 < minValueScaled) amount = 0;
201+
else if (stablecoinsFromAsset * 1e9 < minValueScaled + amount * 1e9)
202+
amount = stablecoinsFromAsset - minValueScaled / 1e9;
203203
}
204204
}
205205

206206
function _setYieldBearingAssetData(
207207
address yieldBearingAsset,
208-
address depositAsset,
208+
address asset,
209209
uint64 targetExposure,
210210
uint64 minExposure,
211211
uint64 maxExposure,
212212
uint64 overrideExposures
213213
) internal virtual {
214214
YieldBearingParams storage yieldBearingInfo = yieldBearingData[yieldBearingAsset];
215-
yieldBearingInfo.depositAsset = depositAsset;
215+
yieldBearingInfo.asset = asset;
216216
if (targetExposure >= 1e9) revert InvalidParam();
217217
yieldBearingInfo.targetExposure = targetExposure;
218218
yieldBearingInfo.overrideExposures = overrideExposures;
@@ -222,22 +222,22 @@ abstract contract BaseHarvester is IHarvester, AccessControl {
222222
yieldBearingInfo.minExposure = minExposure;
223223
} else {
224224
yieldBearingInfo.overrideExposures = 2;
225-
_updateLimitExposuresYieldAsset(depositAsset, yieldBearingInfo);
225+
_updateLimitExposuresYieldAsset(asset, yieldBearingInfo);
226226
}
227227
}
228228

229229
function _updateLimitExposuresYieldAsset(
230-
address depositAsset,
230+
address asset,
231231
YieldBearingParams storage yieldBearingInfo
232232
) internal virtual {
233233
uint64[] memory xFeeMint;
234-
(xFeeMint, ) = transmuter.getCollateralMintFees(depositAsset);
234+
(xFeeMint, ) = transmuter.getCollateralMintFees(asset);
235235
uint256 length = xFeeMint.length;
236236
if (length <= 1) yieldBearingInfo.maxExposure = 1e9;
237237
else yieldBearingInfo.maxExposure = xFeeMint[length - 2];
238238

239239
uint64[] memory xFeeBurn;
240-
(xFeeBurn, ) = transmuter.getCollateralBurnFees(depositAsset);
240+
(xFeeBurn, ) = transmuter.getCollateralBurnFees(asset);
241241
length = xFeeBurn.length;
242242
if (length <= 1) yieldBearingInfo.minExposure = 0;
243243
else yieldBearingInfo.minExposure = xFeeBurn[length - 2];

contracts/helpers/GenericHarvester.sol

+8-8
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ contract GenericHarvester is BaseHarvester, IERC3156FlashBorrower, RouterSwapper
112112
(SwapType swapType, bytes memory data) = abi.decode(extraData, (SwapType, bytes));
113113

114114
if (amount > 0) {
115-
try transmuter.updateOracle(yieldBearingInfo.depositAsset) {} catch {}
115+
try transmuter.updateOracle(yieldBearingInfo.asset) {} catch {}
116116

117117
adjustYieldExposure(
118118
amount,
119119
increase,
120120
yieldBearingAsset,
121-
yieldBearingInfo.depositAsset,
121+
yieldBearingInfo.asset,
122122
(amount * (1e9 - maxSlippage)) / 1e9,
123123
swapType,
124124
data
@@ -136,7 +136,7 @@ contract GenericHarvester is BaseHarvester, IERC3156FlashBorrower, RouterSwapper
136136
uint256 amountStablecoins,
137137
uint8 increase,
138138
address yieldBearingAsset,
139-
address depositAsset,
139+
address asset,
140140
uint256 minAmountOut,
141141
SwapType swapType,
142142
bytes memory extraData
@@ -145,7 +145,7 @@ contract GenericHarvester is BaseHarvester, IERC3156FlashBorrower, RouterSwapper
145145
IERC3156FlashBorrower(address(this)),
146146
address(agToken),
147147
amountStablecoins,
148-
abi.encode(msg.sender, increase, yieldBearingAsset, depositAsset, minAmountOut, swapType, extraData)
148+
abi.encode(msg.sender, increase, yieldBearingAsset, asset, minAmountOut, swapType, extraData)
149149
);
150150
}
151151

@@ -167,19 +167,19 @@ contract GenericHarvester is BaseHarvester, IERC3156FlashBorrower, RouterSwapper
167167
address tokenIn;
168168
{
169169
address yieldBearingAsset;
170-
address depositAsset;
171-
(sender, typeAction, yieldBearingAsset, depositAsset, minAmountOut, swapType, callData) = abi.decode(
170+
address asset;
171+
(sender, typeAction, yieldBearingAsset, asset, minAmountOut, swapType, callData) = abi.decode(
172172
data,
173173
(address, uint256, address, address, uint256, SwapType, bytes)
174174
);
175175
if (typeAction == 1) {
176176
// Increase yield exposure action: we bring in the yield bearing asset
177177
tokenOut = yieldBearingAsset;
178-
tokenIn = depositAsset;
178+
tokenIn = asset;
179179
} else {
180180
// Decrease yield exposure action: we bring in the deposit asset
181181
tokenIn = yieldBearingAsset;
182-
tokenOut = depositAsset;
182+
tokenOut = asset;
183183
}
184184
}
185185
uint256 amountOut = transmuter.swapExactInput(

contracts/helpers/MultiBlockHarvester.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ contract MultiBlockHarvester is BaseHarvester {
131131
amount,
132132
0,
133133
address(agToken),
134-
yieldBearingInfo.depositAsset,
134+
yieldBearingInfo.asset,
135135
address(this),
136136
block.timestamp
137137
);
138-
_checkSlippage(amount, amountOut, yieldBearingInfo.depositAsset, depositAddress, false);
138+
_checkSlippage(amount, amountOut, yieldBearingInfo.asset, depositAddress, false);
139139
if (yieldBearingAsset == XEVT) {
140-
_adjustAllowance(yieldBearingInfo.depositAsset, address(depositAddress), amountOut);
140+
_adjustAllowance(yieldBearingInfo.asset, address(depositAddress), amountOut);
141141
(uint256 shares, ) = IPool(depositAddress).deposit(amountOut, address(this));
142142
_adjustAllowance(yieldBearingAsset, address(transmuter), shares);
143143
amountOut = transmuter.swapExactInput(
@@ -149,7 +149,7 @@ contract MultiBlockHarvester is BaseHarvester {
149149
block.timestamp
150150
);
151151
} else if (yieldBearingAsset == USDM) {
152-
IERC20(yieldBearingInfo.depositAsset).safeTransfer(depositAddress, amountOut);
152+
IERC20(yieldBearingInfo.asset).safeTransfer(depositAddress, amountOut);
153153
}
154154
} else {
155155
uint256 amountOut = transmuter.swapExactInput(

0 commit comments

Comments
 (0)