-
Notifications
You must be signed in to change notification settings - Fork 59
Brian/linear auction library #219
Conversation
|
Integrations with RebalancingSetToken will come next. The interface and constantPriceLibrary I'll be using for integration/tests are already included in this PR. |
…uld not be run in coverage.
Pull Request Test Coverage Report for Build 1947
💛 - Coveralls |
|
|
||
|
|
||
| /** | ||
| * @title LinearAuctionLibrary |
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.
Knit: ConstantPriceAuctionLibrary
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.
Whoops...yes +1
| import { SafeMath } from "zeppelin-solidity/contracts/math/SafeMath.sol"; | ||
|
|
||
| /** | ||
| * @title LinearAuctionLibrary |
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.
IMO, we can remove the suffix Library. The other lib files do not have it. Thus, it would be consistent.
| * | ||
| */ | ||
|
|
||
| contract ConstantPriceAuctionLibrary { |
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.
If a manager proposes a constant price library, couldn't it be very likely that a rebalance could never end?
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.
It's for testing, not for actual deployment. Why I threw it in the mocks folder.
| subjectAuctionStartPrice | ||
| ); | ||
| expect(returnedPrice).to.be.bignumber.equal(expectedPrice); | ||
| }); |
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.
What happens if the price hits 0? If possible, what if it becomes negative?
Maybe we can add unit test cases for these.
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.
It can't hit 0...
utils/RebalancingTokenWrapper.ts
Outdated
| return {unitShares, issueAmount}; | ||
| } | ||
|
|
||
| public getExpectedLinearAuctionPrice( |
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.
Knit: spacing
utils/RebalancingTokenWrapper.ts
Outdated
| curveCoefficient: BigNumber, | ||
| auctionStartPrice: BigNumber | ||
| ): BigNumber { | ||
| const contractTimeIncrement = new BigNumber(30); |
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.
Put this in a constant file?
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.
+1
asoong
left a comment
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.
Specs for constant price curve?
| pragma solidity 0.4.24; | ||
|
|
||
| import { SafeMath } from "zeppelin-solidity/contracts/math/SafeMath.sol"; | ||
|
|
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.
For the future. Inconsistent spacing. Two lines here
| * Contract used in rebalancing auctions to calculate price based off of a linear curve | ||
| * | ||
| */ | ||
|
|
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.
None here
| uint256 _curveCoefficient | ||
| ) | ||
| external | ||
| returns (uint256) |
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.
view modifier?
| returns (uint256) | ||
| { | ||
| // Increment price every 30 seconds | ||
| uint256 timeIncrement = 30; |
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.
Don't need to define this since it's not being reused. Clarify the 30 in the comment below
| uint256 _curveCoefficient | ||
| ) | ||
| external | ||
| returns (uint256) |
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.
view
| * @title ConstantAuctionPriceCurve | ||
| * @author Set Protocol | ||
| * | ||
| * Contract used in rebalancing auctions to calculate price based off of a linear curve |
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.
Update comment here. What does constant curve mean? Constant ratio right?
| /* | ||
| * Return constant price amount | ||
| * | ||
| * @param _auctionStartTime Time of auction start |
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.
Remove these parameters and clarify they are unused but there to conform to IAuctionLibrary. See: https://github.com/SetProtocol/set-protocol-contracts/pull/218/files
| * @param _curveCoefficient The slope (or convexity) of the price curve | ||
| */ | ||
| function getCurrentPrice( | ||
| uint256 _auctionStartTime, |
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.
Remove these parameter names. Just leave uint256,
| import { ERC20Wrapper } from '@utils/erc20Wrapper'; | ||
| import { CoreWrapper } from '@utils/coreWrapper'; | ||
| import { RebalancingTokenWrapper } from '@utils/RebalancingTokenWrapper'; | ||
|
|
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.
Remove whitespace
utils/constants.ts
Outdated
| export const STANDARD_QUANTITY_ISSUED: BigNumber = ether(10); | ||
| export const UNLIMITED_ALLOWANCE_IN_BASE_UNITS = new BigNumber(2).pow(256).minus(1); | ||
| export const ZERO: BigNumber = new BigNumber(0); | ||
| export const AUCTION_TIME_INCREMENT = new BigNumber(30); |
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.
What does time denote in these tests? Blocks? Or unix time
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.
unix seconds. Like it does on the blockchain.
…ctionPriceCurve and hard-coded instead. Added view modifier to getCurrentPrice function.
felix2feng
left a comment
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.
Approve sans knits
| pragma solidity 0.4.24; | ||
|
|
||
| /** | ||
| * @title IAuctionLibrary |
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.
Knit IAuctionPriceCurve
| * @title IAuctionLibrary | ||
| * @author Set Protocol | ||
| * | ||
| * The IAuctionLibrary interface provides a structured way to interact with any AuctionLibrary |
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.
Knit IAuctionPriceCurve
| const { expect } = chai; | ||
|
|
||
|
|
||
| contract('LinearAuctionLibrary', accounts => { |
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.
LinearAuctionPriceCurve
No description provided.