@@ -40,13 +40,13 @@ contract BaseConvertor is BaseHealthCheck {
4040 IMerklDistributor (0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae );
4141
4242 /// @notice Token converted to/from strategy `asset`.
43- ERC20 public immutable want ;
43+ ERC20 public immutable WANT ;
4444
4545 /// @notice Auction selling `asset` into `want`.
46- Auction public immutable sellAssetAuction ;
46+ Auction public immutable SELL_ASSET_AUCTION ;
4747
4848 /// @notice Auction selling `want` into `asset`.
49- Auction public immutable buyAssetAuction ;
49+ Auction public immutable BUY_ASSET_AUCTION ;
5050
5151 /// @notice Morpho-style oracle with answer = asset per want, scaled 1e36.
5252 address public oracle;
@@ -75,7 +75,7 @@ contract BaseConvertor is BaseHealthCheck {
7575 address _want ,
7676 address _oracle
7777 ) BaseHealthCheck (_asset, _name) {
78- want = ERC20 (_want);
78+ WANT = ERC20 (_want);
7979
8080 AuctionFactory factory = AuctionFactory (
8181 0xbA7FCb508c7195eE5AE823F37eE2c11D7ED52F8e
@@ -87,16 +87,18 @@ contract BaseConvertor is BaseHealthCheck {
8787 _sellAssetAuction.enable (_asset);
8888 _sellAssetAuction.setStepDecayRate (1 );
8989 _sellAssetAuction.setGovernanceOnlyKick (true );
90- sellAssetAuction = _sellAssetAuction;
90+ SELL_ASSET_AUCTION = _sellAssetAuction;
9191
9292 Auction _buyAssetAuction = Auction (
9393 factory.createNewAuction (_asset, address (this ), address (this ))
9494 );
9595 _buyAssetAuction.enable (_want);
9696 _buyAssetAuction.setStepDecayRate (1 );
9797 _buyAssetAuction.setGovernanceOnlyKick (true );
98- buyAssetAuction = _buyAssetAuction;
98+ BUY_ASSET_AUCTION = _buyAssetAuction;
9999
100+ // We store the default decay rate in case a custom one
101+ // is ever used for a specific auction we can reset it to the default.
100102 decayRate = 1 ;
101103
102104 _setStartingPriceBps (uint16 (MAX_BPS + 10 ));
@@ -130,6 +132,8 @@ contract BaseConvertor is BaseHealthCheck {
130132 _setStartingPriceBps (_startingPriceBps);
131133 }
132134
135+ /// @notice Set the default decay rate used for want/asset auctions.
136+ /// Reward token auctions always use DEFAULT_AUCTION_DECAY_RATE.
133137 function setDecayRate (uint256 _decayRate ) external onlyManagement {
134138 _setDecayRate (_decayRate);
135139 }
@@ -144,14 +148,6 @@ contract BaseConvertor is BaseHealthCheck {
144148 _setMaxGasPriceToTend (_maxGasPriceToTend);
145149 }
146150
147- /// @notice Management passthrough to set auction step decay rate.
148- function setAuctionStepDecayRate (
149- address _from ,
150- uint256 _stepDecayRate
151- ) external onlyManagement {
152- _auctionForToken (_from).setStepDecayRate (_stepDecayRate);
153- }
154-
155151 /// @notice Management passthrough to set auction step duration.
156152 function setAuctionStepDuration (
157153 address _from ,
@@ -182,23 +178,25 @@ contract BaseConvertor is BaseHealthCheck {
182178 }
183179
184180 function _kickAuction (address _from ) internal virtual returns (uint256 ) {
185- if (_from == address (asset )) {
186- return _kickConfiguredAuction (sellAssetAuction , _from);
181+ if (_from == address (WANT )) {
182+ return _kickConfiguredAuction (BUY_ASSET_AUCTION , _from);
187183 }
188- return _kickConfiguredAuction (buyAssetAuction , _from);
184+ return _kickConfiguredAuction (SELL_ASSET_AUCTION , _from);
189185 }
190186
191187 function kickable (address _from ) public view virtual returns (uint256 ) {
192- if (_from == address (asset )) {
193- return _kickableFromAuction (sellAssetAuction , _from);
188+ if (_from == address (WANT )) {
189+ return _kickableFromAuction (BUY_ASSET_AUCTION , _from);
194190 }
195- return _kickableFromAuction (buyAssetAuction , _from);
191+ return _kickableFromAuction (SELL_ASSET_AUCTION , _from);
196192 }
197193
194+ /// @notice We use trigger to go from asset -> want.
195+ /// We cannot assume loose want should be converted, so it does not go back.
198196 function auctionTrigger (
199197 address _from
200198 ) external view returns (bool shouldKick , bytes memory data ) {
201- if (_from == address (want )) return (false , bytes ("want " ));
199+ if (_from == address (WANT )) return (false , bytes ("want " ));
202200
203201 if (! (_isBaseFeeAcceptable ())) return (false , bytes ("base fee " ));
204202
@@ -247,15 +245,15 @@ contract BaseConvertor is BaseHealthCheck {
247245 }
248246
249247 function balanceOfWant () public view virtual returns (uint256 ) {
250- return want .balanceOf (address (this ));
248+ return WANT .balanceOf (address (this ));
251249 }
252250
253251 function balanceOfAssetInAuction () public view virtual returns (uint256 ) {
254- return asset.balanceOf (address (sellAssetAuction ));
252+ return asset.balanceOf (address (SELL_ASSET_AUCTION ));
255253 }
256254
257255 function balanceOfWantInAuction () public view virtual returns (uint256 ) {
258- return want .balanceOf (address (buyAssetAuction ));
256+ return WANT .balanceOf (address (BUY_ASSET_AUCTION ));
259257 }
260258
261259 function availableWithdrawLimit (
@@ -272,6 +270,10 @@ contract BaseConvertor is BaseHealthCheck {
272270 require (_oracle != address (0 ), "ZERO ADDRESS " );
273271
274272 oracle = _oracle;
273+
274+ // Call _oraclePrice() to ensure the oracle is valid.
275+ _oraclePrice ();
276+
275277 emit OracleSet (_oracle);
276278 }
277279
@@ -337,7 +339,6 @@ contract BaseConvertor is BaseHealthCheck {
337339 }
338340
339341 _available = _kickableFromAuction (_auction, _from);
340- if (_available < minAmountToSell) return 0 ;
341342
342343 _setAuctionPricing (_auction, _from, _available);
343344
@@ -385,8 +386,8 @@ contract BaseConvertor is BaseHealthCheck {
385386 function _auctionForToken (
386387 address _from
387388 ) internal view returns (Auction _auction ) {
388- if (_from == address (asset )) return sellAssetAuction ;
389- return buyAssetAuction ;
389+ if (_from == address (WANT )) return BUY_ASSET_AUCTION ;
390+ return SELL_ASSET_AUCTION ;
390391 }
391392
392393 function _oraclePrice () internal view virtual returns (uint256 _price ) {
@@ -407,7 +408,8 @@ contract BaseConvertor is BaseHealthCheck {
407408 uint256 _stepDecayRate
408409 )
409410 {
410- if (_from != address (asset) && _from != address (want)) {
411+ // If non want/asset tokens, use the default auction pricing.
412+ if (_from != address (asset) && _from != address (WANT)) {
411413 return (
412414 DEFAULT_AUCTION_STARTING_PRICE,
413415 0 ,
@@ -424,6 +426,7 @@ contract BaseConvertor is BaseHealthCheck {
424426 Math.Rounding.Up
425427 );
426428
429+ // Auction starting price is a lot size, so we need to adjust for amount.
427430 _startingPrice = Math.mulDiv (
428431 _amount,
429432 startUnitPrice,
@@ -446,10 +449,10 @@ contract BaseConvertor is BaseHealthCheck {
446449 if (_from == address (asset)) {
447450 uint256 oneAsset = 10 ** asset.decimals ();
448451 uint256 quoteWant = _quoteWantFromAsset (oneAsset);
449- return Math.mulDiv (quoteWant, 1e18 , 10 ** want .decimals ());
452+ return Math.mulDiv (quoteWant, 1e18 , 10 ** WANT .decimals ());
450453 }
451454
452- uint256 oneWant = 10 ** want .decimals ();
455+ uint256 oneWant = 10 ** WANT .decimals ();
453456 uint256 quoteAsset = _quoteAssetFromWant (oneWant);
454457 return Math.mulDiv (quoteAsset, 1e18 , 10 ** asset.decimals ());
455458 }
0 commit comments