This repository was archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Brian/require issue to start rebalance #376
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f42b3ac
Added UpdatableConstantAuctionPriceCurve.
bweick c8aa63d
SettleRebalance check that unitShares isn't 0. EndFailedAuction unitS…
bweick a32f20b
Removed unnecessary require statement.
bweick 561e529
Fixed tests.
bweick a96f0f6
Fix rebalanceAuctionModule tests.
bweick b7d6015
Add DEFAULT_GAS to fix tests.
bweick 0a4e665
Add DEFAULT_GAS to fix tests.
bweick 688e8cd
Updated some commments.
bweick abeb397
Change control logic to meet coverage requirements.
bweick 0947ad4
Consolidate unitShares checking logic.
bweick 6e4560e
Fix extraneous space
felix2feng 16ed6fd
Undo commit
felix2feng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,11 @@ library StandardSettleRebalanceLibrary { | |
| _vaultAddress | ||
| ); | ||
|
|
||
| require( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| nextUnitShares > 0, | ||
| "RebalancingSetToken.settleRebalance: Failed rebalance, unitshares equals 0. Call endFailedAuction." | ||
| ); | ||
|
|
||
| // Issue nextSet to RebalancingSetToken | ||
| ICore(_coreAddress).issueInVault( | ||
| _nextSet, | ||
|
|
@@ -132,7 +137,7 @@ library StandardSettleRebalanceLibrary { | |
| _vaultAddress, | ||
| setDetails | ||
| ); | ||
|
|
||
| // Calculate the amount of naturalUnits worth of rebalancingSetToken outstanding | ||
| uint256 naturalUnitsOutstanding = _totalSupply.div(_naturalUnit); | ||
|
|
||
|
|
@@ -201,6 +206,6 @@ library StandardSettleRebalanceLibrary { | |
| } | ||
| } | ||
|
|
||
| return maxIssueAmount; | ||
| return maxIssueAmount; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,13 +88,13 @@ library StandardStartRebalanceLibrary { | |
| // Must be in "Proposal" state before going into "Rebalance" state | ||
| require( | ||
| _rebalanceState == uint8(RebalancingHelperLibrary.State.Proposal), | ||
| "RebalancingSetToken.rebalance: State must be Proposal" | ||
| "RebalancingSetToken.startRebalance: State must be Proposal" | ||
| ); | ||
|
|
||
| // Be sure the full proposal period has elapsed | ||
| require( | ||
| block.timestamp >= _proposalStartTime.add(_proposalPeriod), | ||
| "RebalancingSetToken.rebalance: Proposal period not elapsed" | ||
| "RebalancingSetToken.startRebalance: Proposal period not elapsed" | ||
| ); | ||
|
|
||
| // Create combined array data structures and calculate minimum bid needed for auction | ||
|
|
@@ -111,6 +111,13 @@ library StandardStartRebalanceLibrary { | |
| _vaultAddress | ||
| ); | ||
|
|
||
| // Require remainingCurrentSets to be greater than minimumBid otherwise no bidding would | ||
| // be allowed | ||
| require( | ||
| biddingParameters.remainingCurrentSets >= biddingParameters.minimumBid, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also have a function in settleLibrary to reflect this equality? It's also in |
||
| "RebalancingSetToken.startRebalance: Not enough collateral to rebalance" | ||
| ); | ||
|
|
||
| return biddingParameters; | ||
| } | ||
|
|
||
|
|
||
58 changes: 58 additions & 0 deletions
58
contracts/mocks/core/lib/UpdatableConstantAuctionPriceCurve.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| Copyright 2018 Set Labs Inc. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| pragma solidity 0.4.25; | ||
| pragma experimental "ABIEncoderV2"; | ||
|
|
||
| import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
| import { ConstantAuctionPriceCurve } from "./ConstantAuctionPriceCurve.sol"; | ||
| import { RebalancingHelperLibrary } from "../../../core/lib/RebalancingHelperLibrary.sol"; | ||
|
|
||
| /** | ||
| * @title UpdatableConstantAuctionPriceCurve | ||
| * @author Set Protocol | ||
| * | ||
| * Contract used in rebalancing auction testing to return consistent price. | ||
| * !!!!!!!!!!!!! DO NOT DEPLOY !!!!!!!!!!!!! | ||
| * | ||
| */ | ||
|
|
||
| contract UpdatableConstantAuctionPriceCurve is ConstantAuctionPriceCurve { | ||
|
|
||
| constructor( | ||
| uint256 _priceNumerator, | ||
| uint256 _priceDenominator | ||
| ) | ||
| public | ||
| ConstantAuctionPriceCurve( | ||
| _priceNumerator, | ||
| _priceDenominator | ||
| ) | ||
| {} | ||
|
|
||
| /* | ||
| * Update constant auction price | ||
| * | ||
| * @param _newPrice Price to update to | ||
| */ | ||
| function updatePrice( | ||
| uint256 _newPrice | ||
| ) | ||
| public | ||
| { | ||
| priceNumerator = _newPrice; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write another function in
StandardSettleRebalanceLibrarycalled something likecanPeformSuccessfulSettlementor so instead of passing through calculatedUnitShares?