-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Use DSROracle in invariant tests (SC-484) (#16)
* feat: first test working * feat: use larger numbers: * feat: test with initial burn amount passing * feat: update tests to work with updated burn logic, move conversion functions around and use previews * feat: remove todos * fix: update to remove console and update comment * feat: get swap tests working * feat: get all swap tests working * fix: update for three assets in logic * feat: all tests passing * fix: rm commented out test * feat: add preview swap tests * feat: move logic out of single use internal and use conversion rate everywhere * feat: move divRoundUp out of single use internal * feat: add full coverage for conversion tests * feat: add more preview cases * feat: refactor PSM to use three assets * fix: rm comment * feat: add interface, natspec, events, referral code, tests passing * fix: update to rm consolegp * feat: add events testing * feat: make precisions internal and add state var natspec * feat: finish natspec * feat: add readme * feat: add referral code note * fix: update constructor test * fix: update links * fix: reformatting * fix: update testing section * fix: improve overview * feat: add emojis * feat: remove all share burn logic, get all non inflation attack tests to pass * fix: cleanup diff * fix: update to use initial deposit instead of burn * feat: add readme section explaining attack * fix: minimize diff * fix: address bartek comments * feat: update all tests to work with new interfaces * feat: add deposit failure mode tests * feat: update to add assertions for return in deposit * feat: add withdraw failure tests * feat: update to address comments outside sharesToBurn * feat: update inflation attack test and readme * fix: update readme * feat: update test to constrain deposit/withdraw * feat: update to add both cases * feat: update per review * feat: update to use underscore bound, fix test * fix: typo * feat: add overrides, remove referrals, update referral type * fix: update expect emit * feat: update name and remove todos * feat: move files and set up structure * feat: update to rename files, contracts, and errors * fix: rm dup file, update toml * feat: get deposits working * chore: refactor into proper inheritance structure * feat: get all functions working with reverts * feat: update conversion * feat: get swaps working without reverts * feat: add fully working deposit/withdraw/swaps, invariant_B failing * ci: update for ci * fix: update name * chore: rm basly cased file * chore: re add * fix: re add invariant * ci: experiment with 2 million total calls * ci: add show progress flag * fix: move file back * ci: update verbosity * ci: add PR profile * fix: rm redundant files * feat: update from review changes * feat: add afterInvariant hook * fix: update invariant * fix: add fuzz failure * chore: rm indexing comment * feat: refactor structure * feat: both invariants working * fix: update comment * feat: add rate setting logic * fix: update toml * fix: rm redundant files from merge * fix: update tolerances * feat: update to add seeding as part of invariants * fix: update toml * fix: rm redundant files from merge * fix: update tolerances * fix: rm invariant logs * fix: update tolerance * forge install: xchain-dsr-oracle v1.0.0 * feat: setup timebased handler, refactor rate provider structure * feat: tests passing * chore: first cleanup * fix: test names * fix: update dsr value, change chi approach
- Loading branch information
1 parent
fafd16e
commit ebef16e
Showing
16 changed files
with
246 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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 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
Submodule xchain-dsr-oracle
added at
a02e59
This file contains 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 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,6 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.13; | ||
|
||
interface IRateProviderLike { | ||
function getConversionRate() external view returns (uint256); | ||
} |
This file contains 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 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 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 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,47 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.8.13; | ||
|
||
import { StdCheats } from "forge-std/StdCheats.sol"; | ||
import { StdUtils } from "forge-std/StdUtils.sol"; | ||
|
||
import { DSRAuthOracle } from "lib/xchain-dsr-oracle/src/DSRAuthOracle.sol"; | ||
import { IDSROracle } from "lib/xchain-dsr-oracle/src/interfaces/IDSROracle.sol"; | ||
|
||
contract TimeBasedRateHandler is StdCheats, StdUtils { | ||
|
||
uint256 public dsr; | ||
uint256 public chi; | ||
uint256 public rho; | ||
|
||
uint256 constant ONE_HUNDRED_PCT_APY_DSR = 1.000000021979553151239153027e27; | ||
|
||
DSRAuthOracle public dsrOracle; | ||
|
||
uint256 public setRateCount; | ||
|
||
constructor(DSRAuthOracle dsrOracle_) { | ||
dsrOracle = dsrOracle_; | ||
} | ||
|
||
// This acts as a receiver on an L2. | ||
function setPotData(uint256 newDsr, uint256 newRho) external { | ||
dsr = _bound(newDsr, 1e27, ONE_HUNDRED_PCT_APY_DSR); | ||
rho = _bound(newRho, rho, block.timestamp); | ||
|
||
// If chi hasn't been set yet, set to 1e27, else recalculate it in the same way it would | ||
// happen during a refresh. | ||
uint256 rate = dsrOracle.getConversionRate(); | ||
uint256 chi = rate == 0 ? 1e27 : rate; | ||
|
||
dsrOracle.setPotData(IDSROracle.PotData({ | ||
dsr: uint96(dsr), | ||
chi: uint120(chi), | ||
rho: uint40(rho) | ||
})); | ||
} | ||
|
||
function warp(uint256 skipTime) external { | ||
skip(_bound(skipTime, 0, 45 days)); | ||
} | ||
|
||
} |
Oops, something went wrong.