Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add continuous exponential decrease #211

Merged
merged 3 commits into from Mar 13, 2021
Merged

Conversation

kmbarry1
Copy link
Contributor

@kmbarry1 kmbarry1 commented Mar 9, 2021

There are fair arguments that maybe the stairstep functionality is not really beneficial; while step could always be set to 1 in that case, it's more gas-efficient to have a separate function that won't do the pointless SLOAD if a continuous exponential proves preferable.

@livnev
Copy link
Contributor

livnev commented Mar 9, 2021

FWIW I didn't initially appreciate the utility of the stairstep functionality for frontends, user-facing aggregators, etc. so I think as long as the tradeoffs are understood (stairstep leaks MEV while perhaps improving UX for human-driven trading) using the stairstep is not unreasonable.

@kmbarry1
Copy link
Contributor Author

kmbarry1 commented Mar 9, 2021

It might be one of those things where you just have to try it out in practice to really know. This PR isn't intended to mark a hard decision, but rather to just make sure maximally efficient options are available for both.

src/test/abaci.t.sol Outdated Show resolved Hide resolved
kmbarry1 and others added 2 commits March 11, 2021 06:14
Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>
Copy link

@WilfredTA WilfredTA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to compare the costs and benefits from gas saving vs a larger window of opportunity to bid at a specific price before a decrease for the relevant participants. Relevant metrics here are probably how the step size affects bidding behavior and, consequently, auction duration, amount of winning bid, etc.

Having said that, since this isn't a commitment to one approach vs another, but merely adding the option, it's fine by me.

Copy link
Contributor

@godsflaw godsflaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kmbarry1 kmbarry1 merged commit ca67195 into liq-2.0 Mar 13, 2021
@kmbarry1 kmbarry1 deleted the continuous-exponential branch March 13, 2021 03:54
gbalabasquer added a commit that referenced this pull request Apr 2, 2021
* Initial commit

* dapp init DutchOven

* dapp install ds-test

* paste in code from gist

* make it build

* tweak README

* add license blurb

* First draft for flash loan + removing loaf if lot is 0 + minor changes (#1)

* cmooney-20200725: various bug fixes

* done TODO checks and fixed trailing whitespace

* ONE to RAY, removed slices, bakes public

* chore: add TODO for max/min/pay variables

* SC-4072: limit amount of Dai out for liquidation (#5)

* SC-4072: limit amount of Dai out for liquidation

* remove changes for another PR

* added BLN

* fix comment

* change MILLION to MIl

* fixed up the formula

* fixed bug in MIL va. MLN

* forgot rdiv()

* missing closing )

* add comments on types

* typo, needed param to be data

* fix: update dog to fix stack to deep, compiles

* feat: update dog to use LIQ-1.2 logic

* fix: update comments, remove dunk, change bone to digs

* fix: gas optimize dink > 0 require

* fix: update comments, add spot to brace block, add cost var

* fix: change cost to due

* fix: formatting

Co-authored-by: Lucas Manuel <lucas@makerdao.com>

* fix dust check

* feat: Add Auction Reset Functionality (SC-4635) (#7)

* feat: add auction reset functionality

* fix: add storage vars, fix compilation issues

* feat: add require to warm, change to external

* fix: update comments

* fix: use safe sub, add dead auction check in warm and take

* Price decrease function interface and sample implementations (#8)

* define price decrease function interface and some trial implementations

* commit sample price decrease functions

* dapp install https://github.com/makerdao/dss.git

* feat: add testing for linear/exp price dec functions

* feat: add unit tests to stairstep, linear price decrease functions

* fix: add comments about precision

* fix: update exp test tolerance to 1e-22

* feat: tests working consistently with precision tolerance

* fix: fix wrong comments

* dapp uninstall dss

* fix: update variables, comments

Co-authored-by: Lucas Manuel <lucas@makerdao.com>

* rely on oven in Dog.file (#11)

* rename files (#13)

* Add on-chain tracking of live auctions (#3)

* Add on-chain tracking of live auctions

* rename last to move for clarity

* Add splice and count funtions for array management

* Fix index shifting

* Change _stopBaking to _remove

* Clean up and fixes

* remove list(uint256,uint256)(uint256[]) and replace with getId(uint256)(uint256)

* Replace .length-- with .pop() for forward compatibility

* Remove comment

* fix: update memes, comments

Co-authored-by: Lucas <lucas@makerdao.com>

* feat: Add Unit Testing (SC-4636) (#9)

* feat: start bake test

* dapp install ds-value

* feat: add take tests for over/under/at tab

* feat: add take test for multiple bids, tests pass

* fix: delete notes file

* fix: remove empty lib/dss

* dapp install dss

* feat: add more testing, setup

* feat: all tests pass except exp decrease

* fix: fix exp decrease step and cut values

* fix: remove rpow, change max/pay to pay/val, update dirt require

* Fix import file and rename uint to uin256

* fix: update room require

* fix: update val to price

* fix: remove vat.flux(), grab straight to oven

* fix: remove rely/deny/hope/nope from oven file in dog

* fix: update imports

* fix: update dog.digs() comment

* fix: update vat helpers, hevm.warping, address(this)

* fix: use defined CHEAT_CODE

* feat: add pos to testing

* fix: remove unused MLN, BLN vars in test

* uint to uint256

* Compile with solc 0.5 and 0.6

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* re-meme and minor cleanup (#15)

* dapp uninstall ds-test

* dapp uninstall ds-value

* dapp uninstall dss

* Remove stuff that will not be transferred

* Minor changes to make clipper tests to work

* Preliminary Circuit Breaker

Added logic to `stop` and `start` the clipper. All major functions are frozen when `stopped == true`.

* use current price, not bidder maximum

* hole per ilk (#141)

* Bit simpler tests

* Implement hole per collateral

* Fixing minor things

* fix: update hole comment

Co-authored-by: Lucas <lucas@makerdao.com>

* Clipper cleanup (#146)

* improve take arg comments

* remove comment about returning collateral incrementally

* rename warm to redo

* rename resetting event

* add Take event

* fix: format Take event, comments

Co-authored-by: Lucas <lucas@makerdao.com>

* feat: Add Auction Reset Tests (SC-6413) (#148)

* feat: add auction reset testing, tests pass

* fix: move repeated setup code to function

* feat: add try_redo() to clip tests

* fix: update to camelcase, fix comment

* Add license identifier to clip.sol

* change to levels

* Revert "Merge branch 'SC-4636' into liq-2.0"

This reverts commit 1906a89, reversing
changes made to 12d3254.

* Add license identifier to dog.sol

* Add tests

* No breaker for yank

* remove yank breaker tests

* Add tests

* No breaker for yank

* remove yank breaker tests

* fixing rebase issues

* remove `which`

* fix: read dust from vat (#151)

* feat: add chop getter API

* feat: Add Dusty `bite` Check (SC-6351) (#154)

* feat: add dusty bite check

* fix: use rate in dust revert calc

* feat: add rate to dusty check test

* fix: remove math import

* fix: update comments

* fix: get rid of jug

* feat: Add LibNote events to dog.sol, clip.sol (SC-4645) (#156)

* feat: add LibNote to dog, clip

* feat: index ids, add top to Kick and Redo, add max/price/owe to Take

* fix: remove note from functions with custom events in dog and clip

* minor gas optimizations in Clipper (#152)

* minor gas optimizations in Clipper

* fix: add dust call back, resolve conflicts

Co-authored-by: Lucas <lucas@makerdao.com>

* feat: Use custom events (#157)

* feat: add custom events across functions in dog and clip

* fix: update public to external for rely/deny in clip

* feat: update File events to differentiate types

* fix: add rely events to constructors, index id in Bark

* fix: change tab to due in Bark event

* feat: Add Keeper Liquidation Incentive (SC-6597) (#153)

* feat: add keeper liquidation incentive and testing, tests pass

* fix: use ali to bark()

* feat: add tip and chip as per ilk params for incentives

* fix: fix test failures from rebase

* fix: update wmul

* feat: update tests to assert bob balance

* fix: update comments

* feat: add custom events for rely/deny in abaci.sol (#163)

* change price API to accept seconds elapsed since auction start (#162)

* change price API to accept seconds elapsed since auction start

* reinstate 0.5.12 compatibility

* fix: add Rely event to abaci constructors

* fix: update liq incentive to use due (#164)

* feat: Upgrade dog, clip to 0.6.7, Update CI (SC-7268) (#165)

* feat: upgrade dog, clip to 0.6.7, update CI

* fix: format immutable vars, use interface in abaci.sol

* fix: update chip comment (#166)

* feat: End Integration and `yank()` (SC-6352 + SC-6353) (#161)

* draft, dog is in end w/ cat, and auction cancellation

* committing from laptop so i can pull to desktop

* committing latest changes to share

* fix: fix interace and formatting

* feat: add tests for yank and end integration

feix: formatting

* fix: use _remove in yank, remove vat.hope() in halt()

* fix: update halt to skip

* fix: update tests to use real rate, remove unnecessary testing

* fix: use vat.fold in snip test for rate

* feat: add clipper assertions from yank call

* fix: update scope of tab and lot

Co-authored-by: wilbarnes <wbarnesf@gmail.com>

* separate price decrease function tests into their own file (#168)

* feat: Add `needsRedo` Function (SC-7445) (#169)

* feat: add view function for auction reset

* feat: test for both tail and cusp

* feat: add ripe function

* fix: update ripe to done

* fix: remove sale.tab check from done function

* fix: update return bool

* feat: minor gas optimization for dink calculation (#167)

* fix: Input and state validation (#170)

* add input validation to Clipper.kick w/tests

* regularize checks for non-running auctions

* more tests

* Slither findings (#172)

* make public funcs external in Dog

* simplify cut param of StairstepExponentialDecrease

* fix revert message in StairstepExponentialDecrease

* gas optimization and test for Clipper.yank (#175)

* Compile with solc 0.6.11

* Make LinearDecrease.tau public

* fix: whitespace and BIL (#178)

* LIQ-2.0 20210114 updates (#181)

* some small changes and TODO notes

* verbose testing

* Add id to yank

* rm max TODO

Co-authored-by: Brian McMichael <brian@brianmcmichael.com>

* Add extra function to pay rewards to external address (#180)

* Add remaining art to dart to prevent unliquidatable vaults (#179)

* Add remaining art to dart to prevent unliquidatable vaults

* rm extra require

* Reuse mart

* Simplify dust check

* Modify unit test in order to work with the dust behaviour change

* rename test for clarity

* Add test TODO

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Liq 2.0 gas improvements (#184)

* Optimize gas usage in some functions

* Optimize take function and change done to status (which returns also the price)

* Fix require message

* Fix in needsRedo

* now => block.timestamp

* Add comment

* Use id as in other functions

* Fix shadow variable warning

* Add missing SPDX License Identifier for some files

* Liq 2.0: add tests for external calls (#185)

* tests for external calls

* add test for reentrancy

* test redo reentrancy

* more realistic flashsale test

* avoid third-party names

* Prevent take impersonation. (#189)

Co-authored-by: Emilio Silva Schlenker <e18r@disroot.org>

* Instead of ending auction if tab < dust, recalculate amounts (#190)

* Instead of ending auction if tab < dust, recalculate amounts

* Instead of ending auction if tab < dust, recalculate amounts

* Some changes

* Avoid if block if tab == owe

Co-authored-by: Emilio Silva Schlenker <e18r@disroot.org>
Co-authored-by: Brian McMichael <brian@brianmcmichael.com>

* fix: move incentive to kick() in redo() (SC-8390) (#188)

* fix: move incentive to kick() in redo() (SC-8390)

* removed comment

* prevent vat.suck() and move SLOAD

* pedantic security

* adding TODO comments

* LIQ-2.0: dusty test cases around dog.bark() (#186)

* create test file for dog

* dog set up

* add isDusty() function and a few tests

- test_bark_basic()
- testFail_bark_not_unsafe()
- test_bark_unliquidatable_vault()
- test_bark_dust_over_ilk_hole()
- test_bark_dust_over_Hole()
- test_bark_exactly_dust_over_Hole()

* update code to recent changes

* add some tests

- test_bark_over_ilk_hole
- test_bark_over_Hole
- test_bark_dust_under_ilk_hole
- test_bark_dust_under_Hole

* remove duplicate lines

* Redo some tests

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Add lock modifier to redo just as extra safety measure (#192)

* Change needsRedo function to getStatus which also includes the price (#193)

* Change needsRedo function to getStatus which also includes the price

* Fix comment

* Clean up warnings (#195)

* Make dog immutable and spotter manageable + check dog is not used as who in flash loan call

* Not paying incentive in redo if the auction is dusty

* Make chip and tip public + more tests (#196)

* Test for not partial purchase when tab == dust

* Make chip and tip public + adding a test to check redo incentives logic

* Addressing comments

* Fix spacing

* Avoid extra SLOAD when using chip and tip (#2)

* In case Hole < Dirt or milk.hole < milk.dirt also show revert message

* Save SLOAD in kick

* Save SLOAD in kick

* move top

* Clearer parameter name

* Yank param uint256

* Tweak breaker docs

* Custom events + int/uint with 256 + now -> block.timestamp

* Custom events + int/uint with 256 + now -> block.timestamp

* Add indexed to usr in Skip and Snip

* Move math constant to the top

* Rename all File events to just plain File name

* getPrice function

This function:

* avoids replicated code
* avoids stack-too-deep brackets

* Fix comment take param

* Add snip to End code documentation

* Add snip to End code documentation

* Text changes

* Liq 2.0 formulas

* Add formulas for `take`

* add brief `top` formula for kick and redo

* formulas for `bark`

* made formulas for bark clearer

* general equation for bark

* added the case when `dart` creates a dusty vault

* corrected typos

* adding formulas for abaci linear and exponential decrease for price

* Updating explanation of cut

* New formulas for bark and take (#199)

* New formulas for bark

* New formulas for take

* Fix bark formula

* Format some text

* Minor fixes

Co-authored-by: Emilio Silva Schlenker <e18r@disroot.org>
Co-authored-by: tannr <tannr@makerdao.com>

* Optimize deletion: don't shift if element is last

* Optimize deletion: don't shift if element is last

* Add test of element removal

* Add more assertions and a test of out-of-range failure

* document test

* unused var

* dig entire tab when full lot is purchased

* Address PwC finding 6.6

* revamp dog partial liquidation logic

* add tests for not creating dusty auctions

* Update src/test/dog.t.sol

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Update src/test/dog.t.sol

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* fix try_bark

* improve clarity of dusty vault & dusty room test

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Add lock modifier to every auth function + make SetBreaker part of th…

* Add lock modifier to every auth function + make SetBreaker part of the file function

* Update src/clip.sol

Co-authored-by: Kurt Barry <kurt@makerdao.com>

Co-authored-by: Kurt Barry <kurt@makerdao.com>

* Make dog can be changed on the clipper

* Save extra SLOAD calling kicks

* Addp kpr to Kick and Redo events

* Addp kpr to Kick and Redo events

* Log amount is being paid to kpr

* Rename kprAmt to coin

* Use one storage slot for chip and tip

* Use one storage slot for chip and tip

* Fix for Kurt and Brian

* Remove LibNote in order to be able to compile with solc 0.6 optimized

* Remove LibNote in order to be able to compile with solc 0.6 optimized

* Add runs to the Makefile

* Require top > 0 for kicking and resetting (#205)

* Don't set unstable default values in stairstep constructor (#204)

* Update to 0.6.12 (#206)

* changing wards uint to uint256

* Remove list(), use active() (#207)

* validation for chop (#209)

* Fix state mutability warning in one test contract (#210)

* Add list(), remove getId() (#212)

* add continuous exponential decrease (#211)

* add continuous exponential decrease

* Update src/test/abaci.t.sol

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* harmonize comments

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Gas Optimization: Cache the dust value and allow public modification. (#214)

* More efficient lock in case tx reverts or if in future there are not … (#213)

* More efficient lock in case tx reverts or if in future there are not refunds

* Fix spacing

Co-authored-by: Brian McMichael <brian@brianmcmichael.com>

* validate Clipper ilk when filing in Dog (#216)

* Revert "More efficient lock in case tx reverts or if in future there are not … (#213)" (#217)

This reverts commit 628d6f9.

* Return lot size with getStatus (#215)

* Return lot size with getStatus

* Add tab to getStatus

* Add a breaker level that prevents kick and redo but not take (#220)

* add a breaker level to disable kick and redo but not take

* test re-enabling taking

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* fix tests

* fix tests post-rebase

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Dog and Clipper comment updates (#221)

* update Dog comment

* typos and phrasing

* improve kick param comments

* change kpr comments for kick and redo

* rename getPrice() to getFeedPrice() and price to feedPrice (#224)

* rename getPrice to getFeedPrice

Note that this is inconsistent with daiwanese practices

* rename the return value of getFeedPrice()

* gas tests and don't use optimizations (#226)

* gas tests and don't use optimizations

* update shell.nix to not compile w/optimizations

* properly account for chop in dust checks in the Clipper (#222)

* properly account for chop in dust checks in the Clipper

* cached chost, uniform checks, tests

* update take comment

* Cache chost

* Remove unused variable

* Change _ position

* don't set upchost in constructor

* cache ilk, fix comment

* actually don't cache, ilk is immutable

* remove underscore

* remove extra comma

Co-authored-by: Gonzalo Balabasquer <gbalabasquer@gmail.com>

* Rename abaci file event (#229)

* remove extra newline

Co-authored-by: Kurt Barry <kurt.m.barry@gmail.com>
Co-authored-by: Christopher Mooney <chris@dod.net>
Co-authored-by: Lucas Manuel <lucas@makerdao.com>
Co-authored-by: Kurt Barry <kurt@makerdao.com>
Co-authored-by: Brian L. McMichael <brian@brianmcmichael.com>
Co-authored-by: andy8052 <andychorlian@gmail.com>
Co-authored-by: wilbarnes <wbarnesf@gmail.com>
Co-authored-by: Emilio Silva Schlenker <e18r@disroot.org>
Co-authored-by: tannr <tannr@makerdao.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants