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

Fuzz final 4.0.0 #1184

Merged
merged 509 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
509 commits
Select commit Hold shift + click to select a range
543cada
nit
akshatmittal Mar 15, 2024
f04be8e
Update README.md (#1094)
0xCeletia Mar 18, 2024
4bb9913
initial import removals
tbrent Mar 18, 2024
265cc8d
Merge branch '3.2.0' into 3.3.0
akshatmittal Mar 19, 2024
07f6f59
Merge branch 'master' into 3.2.0
akshatmittal Mar 19, 2024
61d7056
Meta morpho (#1097)
tbrent Mar 22, 2024
63f2a07
Merge branch '3.3.0' into 3.4.0
tbrent Mar 22, 2024
a5f7d20
3.3.0 eUSD plugin upgrade (#1093)
tbrent Mar 22, 2024
aa351cb
Merge branch '3.3.0' of github.com:reserve-protocol/protocol into 3.3.0
tbrent Mar 22, 2024
e2f0a62
Merge branch '3.3.0' into 3.4.0
tbrent Mar 22, 2024
9fe3186
Meta morpho scripts (#1098)
tbrent Mar 25, 2024
23918a7
Add Convex PayPool Plugin (#1090)
akshatmittal Mar 26, 2024
18e851c
initial import removals
tbrent Mar 18, 2024
fcd6c59
paypool mainnet address
tbrent Mar 26, 2024
3985c12
Merge branch '3.3.0' into 3.4.0
tbrent Mar 26, 2024
592c67f
Base plugin deployments and cUSDCv3 change (#1100)
julianmrodri Mar 27, 2024
100f79d
verify_convex_stable_rtoken_metapool.ts: add wrapper verification
tbrent Mar 27, 2024
4c3b62a
add script for verifying COMP
tbrent Mar 27, 2024
0aa2b07
deploy COMP/CRV/CVX assets
tbrent Mar 27, 2024
122ffd3
add deployed base USDC collateral
tbrent Mar 27, 2024
cd9ddff
Merge branch '3.3.0' into 3.4.0
tbrent Mar 27, 2024
5c48f60
Upgrade checker hyusd (#1102)
tbrent Apr 1, 2024
5c2778b
Make StaticATokenV3LM.claimRewards() work for markets without rewards…
tbrent Apr 1, 2024
2af9975
Upgrade OZ & Use Time Based Governor
akshatmittal Apr 2, 2024
ce79856
Update StaticATokenV3LM to reflect latest bdg-labs impl (#1106)
tbrent Apr 2, 2024
5868cfd
An obvious mistake
akshatmittal Apr 2, 2024
639f232
Require new collateral is sound when normalizing weights of a new bas…
tbrent Apr 2, 2024
725f1f0
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
tbrent Apr 3, 2024
32a6d07
Patch facade maxIssuable + maxIssuableByAmounts (#1109)
tbrent Apr 3, 2024
285b526
do not use IReadFacet interface
tbrent Apr 4, 2024
f55034c
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
tbrent Apr 4, 2024
99ff714
First pass
akshatmittal Apr 4, 2024
6c0da97
You were so young NetworkConfigLib
akshatmittal Apr 4, 2024
b32ab2a
nit
akshatmittal Apr 4, 2024
863d5c2
Change min unstaking delay
akshatmittal Apr 4, 2024
e8e1dd5
one quick fix
akshatmittal Apr 4, 2024
0c1dbe0
smaller things
akshatmittal Apr 5, 2024
ebf54b8
fix broker tests
julianmrodri Apr 8, 2024
9d8ce34
fix FacadeWrite tests
julianmrodri Apr 8, 2024
b73c874
fix some furnace tests
julianmrodri Apr 8, 2024
d654577
fix governance test
julianmrodri Apr 8, 2024
0e72abc
fix voting tests in StRSR
julianmrodri Apr 8, 2024
1ce22aa
fix cancel unstakes test
julianmrodri Apr 8, 2024
77598a1
fix additional test in stake reset
julianmrodri Apr 8, 2024
ba58d78
fix strsr tests
julianmrodri Apr 8, 2024
81f8a90
refactor some furnace tests
julianmrodri Apr 8, 2024
7d82dc6
fix revenue tests
julianmrodri Apr 8, 2024
a2bd49e
fix one recoll test
julianmrodri Apr 8, 2024
6762f9d
fix scenario complex basket
julianmrodri Apr 8, 2024
47ec3e3
fix lint
julianmrodri Apr 8, 2024
6d46874
Arbitrum initial plugins (#1101)
tbrent Apr 8, 2024
a21fc5f
fix strsr p0 tests
julianmrodri Apr 8, 2024
a305b11
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
akshatmittal Apr 8, 2024
a28c982
comment nit
tbrent Apr 8, 2024
480db04
switch rewardRatio in fixtures to be per-second values
tbrent Apr 8, 2024
68e2c9b
CHANGELOG
tbrent Apr 8, 2024
d9fc27d
Furnace.test.ts
tbrent Apr 8, 2024
d5f4d4a
Recollateralization.test.ts
tbrent Apr 8, 2024
3b5b992
1s period in tests
tbrent Apr 8, 2024
d3b2d5a
BadERC20.test.ts
tbrent Apr 8, 2024
1a81db0
EXTREME=1 Broker.test.ts
tbrent Apr 8, 2024
c1bdcac
act facet
tbrent Apr 8, 2024
d73510e
Facade.test.ts
tbrent Apr 9, 2024
136f223
RToken.test.ts
tbrent Apr 9, 2024
74a3fb5
ZZStRSR.test.ts
tbrent Apr 9, 2024
f88ecbc
Governance as timelock canceller (#1112)
tbrent Apr 9, 2024
337b1f2
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
akshatmittal Apr 9, 2024
513766b
Fix upgrade compatibility
akshatmittal Apr 9, 2024
1b724e4
reenable extreme test
julianmrodri Apr 9, 2024
ac92b3c
fix lint
julianmrodri Apr 9, 2024
18c2c62
MetaMorpho vaults + Convex crvUSD LPs + sFraxETH (#1107)
tbrent Apr 9, 2024
57d092d
Arbitrum initial scripts (#1104)
tbrent Apr 9, 2024
bf345c3
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
akshatmittal Apr 9, 2024
d10c23d
EXTREME=1 Broker.test.ts
tbrent Apr 10, 2024
0980b54
EXTREME=1 Broker.test.ts
tbrent Apr 10, 2024
b0ff821
comments
akshatmittal Apr 10, 2024
969617d
// is actually a timestamp {s}
pmckelvy1 Apr 10, 2024
2dc9688
comments
akshatmittal Apr 10, 2024
7f3b28d
Coverage 3.3.0 - Phase 1 (#1083)
julianmrodri Apr 11, 2024
ad724d3
New facademonitor impls addresses (#1114)
julianmrodri Apr 11, 2024
0cfe968
Convex ETH+/ETH Collateral Plugin (#1113)
tbrent Apr 11, 2024
b30d125
get StRSR under contract size limit
tbrent Apr 11, 2024
da02862
fix RToken.test.ts
tbrent Apr 12, 2024
67c68ed
repeat fix
akshatmittal Apr 12, 2024
694ecbe
RToken.test.ts
tbrent Apr 12, 2024
3469e58
RToken.test.ts again
tbrent Apr 12, 2024
ae323aa
1
tbrent Apr 15, 2024
e680b19
ETH+/ETH deployment/verification scripts (#1115)
tbrent Apr 15, 2024
3e257b6
3
tbrent Apr 15, 2024
436bbb3
5
tbrent Apr 15, 2024
6f0a1f3
12
tbrent Apr 15, 2024
8ed46a2
12
tbrent Apr 15, 2024
e6822fb
14
tbrent Apr 15, 2024
c8991f7
15
tbrent Apr 15, 2024
a770d07
16
tbrent Apr 15, 2024
331bac9
17
tbrent Apr 15, 2024
5e6cefe
small things
akshatmittal Apr 15, 2024
34d50c2
19
tbrent Apr 15, 2024
642e3e4
20
tbrent Apr 15, 2024
870c222
remove useless cast
akshatmittal Apr 15, 2024
374d0f8
21
tbrent Apr 15, 2024
6f1fbef
25
tbrent Apr 15, 2024
15c2b4d
28
tbrent Apr 15, 2024
aecd1db
29
tbrent Apr 15, 2024
39e8fc8
30
tbrent Apr 15, 2024
3ab9646
34
tbrent Apr 15, 2024
96f16b4
35
tbrent Apr 15, 2024
5bc93df
CTokenSelfReferentialCollateral
tbrent Apr 15, 2024
1190e7c
scenario tests
tbrent Apr 15, 2024
3836934
prepare for review
tbrent Apr 15, 2024
cc71d97
kruft
tbrent Apr 15, 2024
1986c24
comment
tbrent Apr 15, 2024
14ff65a
Collateral.test.ts
tbrent Apr 15, 2024
b61351b
ComplexBasket.test.ts
tbrent Apr 15, 2024
fe48e31
Merge branch 'oz-upgrade-governor-upgrade' into solidified-audit
tbrent Apr 15, 2024
3f3762c
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
tbrent Apr 15, 2024
e61b635
Merge branch 'oz-upgrade-governor-upgrade' into solidified-audit
tbrent Apr 15, 2024
baa8f1f
remove stakedao contracts that went in early by accident
tbrent Apr 15, 2024
df0a62d
Merge branch '3.4.0' into oz-upgrade-governor-upgrade
tbrent Apr 15, 2024
f181e61
Merge branch 'oz-upgrade-governor-upgrade' into solidified-audit
tbrent Apr 15, 2024
6c8ac51
Remove PERIOD
akshatmittal Apr 16, 2024
217fe74
the fix
akshatmittal Apr 16, 2024
bb5df5d
13
tbrent Apr 16, 2024
abfe115
27
tbrent Apr 16, 2024
4294c52
undo 12
tbrent Apr 16, 2024
2cf64ee
fix integration tests
tbrent Apr 16, 2024
9a2d786
Merge branch 'oz-upgrade-governor-upgrade' into solidified-audit
tbrent Apr 16, 2024
5a1902c
Merge pull request #1031 from reserve-protocol/3.2.0
tbrent Apr 16, 2024
ca3261b
Merge branch 'master' into 3.3.0
tbrent Apr 16, 2024
bc81210
Merge pull request #1077 from reserve-protocol/3.3.0
akshatmittal Apr 16, 2024
ffb7aa6
comment nit
tbrent Apr 17, 2024
2fe43e6
Upgrade `openzeppelin/contracts`, and upgrade protocol to always use …
akshatmittal Apr 17, 2024
3e4c72e
Merge branch '3.4.0' into solidified-audit
tbrent Apr 17, 2024
0d01a0d
deprecate sUSD tests
tbrent Apr 17, 2024
eadfa32
route around broken EURT feed
tbrent Apr 17, 2024
1ba5480
fix EURT tests
tbrent Apr 17, 2024
74c6793
fix Main.test.ts to correctly test index vs non-index basketHandlers
tbrent Apr 17, 2024
0ca65e0
update suggested rewardRatio vals
tbrent Apr 17, 2024
dd49c6a
nit
tbrent Apr 17, 2024
201e682
more nitting
tbrent Apr 17, 2024
cd4085f
P0 _msgSender()
tbrent Apr 19, 2024
1e82edd
Merge branch 'master' into 3.4.0
julianmrodri Apr 19, 2024
8ae3ac4
Merge branch '3.4.0' into solidified-audit
tbrent Apr 19, 2024
8fd2b06
rename test
tbrent Apr 19, 2024
abdf9c5
CHANGELOG
tbrent Apr 19, 2024
db72e40
Merge pull request #1117 from reserve-protocol/solidified-audit
tbrent Apr 19, 2024
9c528d8
Review blacklist Scenario test (#1119)
julianmrodri Apr 23, 2024
de6025e
Misc changes (#1121)
akshatmittal Apr 24, 2024
b192d59
New arbitrum addresses (#1116)
tbrent Apr 24, 2024
5ff5c2b
StakeDAO recursive collateral (#1111)
tbrent Apr 25, 2024
71c2490
Starting of new release
akshatmittal Apr 26, 2024
1eb5441
StakeDAO USDC/USDC+ plugin scripts (#1122)
tbrent Apr 29, 2024
17213b7
docs/deployment-variables.md
tbrent Apr 29, 2024
eaff6b3
add claimRewards to MorphoSelfReferentialCollateral
tbrent Apr 29, 2024
b5d40cb
3.4.0 deployment (#1126)
tbrent Apr 30, 2024
7de4274
add task for forking governor anastasius from existing governor alexios
tbrent Apr 30, 2024
6e99d50
Proposal validator (#1132)
pmckelvy1 May 3, 2024
9f74dd5
fix extreme tests for new backup limit (#1128)
julianmrodri May 3, 2024
71cef57
Trust metamorpho mitigations (#1129)
tbrent May 6, 2024
7acd6d8
CHANGELOG
tbrent May 6, 2024
102a761
include slitherin detectors (#1136)
julianmrodri May 7, 2024
61d54e4
README
tbrent May 9, 2024
ebccd3c
deployment-variables.md
tbrent May 9, 2024
d96e0cb
plugin-addresses.md
tbrent May 9, 2024
a319f95
Solidified Audit Report April 25 2024 (#1138)
KevinMoll-ls May 9, 2024
9c2111c
Arbitrum convex stable plugins (#1130)
julianmrodri May 10, 2024
30058cc
use direct claim_rewards() (#1139)
tbrent May 13, 2024
b185743
Update writing-collateral-plugins.md (#1145)
pmckelvy1 May 20, 2024
5aecbfc
arbitrum crvusd crvusdt deployments (#1142)
julianmrodri May 23, 2024
932f8e2
ETH+/ETH collateral feedback (#1141)
tbrent May 29, 2024
8045fe6
Add RPGF Verification
akshatmittal May 29, 2024
9a65ace
deploy facade monitor on arbitrum (#1151)
julianmrodri May 30, 2024
a414183
3.4.0 spell (#1134)
tbrent May 30, 2024
1b8919a
CHANGELOG
tbrent May 30, 2024
e5b5ab4
Merge branch 'master' into 3.4.0
tbrent May 30, 2024
78152ed
CHANGELOG
tbrent May 30, 2024
db80197
Merge pull request #1096 from reserve-protocol/3.4.0
tbrent May 30, 2024
f28d127
Merge branch 'master' into 4.0.0
akshatmittal May 30, 2024
a21fedd
fix GnosisTrade approval (#1150)
tbrent May 31, 2024
2641099
upload 3.4.0 solidified audit
tbrent Jun 10, 2024
915c14f
filename change
tbrent Jun 10, 2024
d2f8627
Registries Setup (#1140)
akshatmittal Jun 12, 2024
e135fab
Reset fork on every plugin test (#1155)
julianmrodri Jun 12, 2024
bf2308f
Merge branch 'master' into 4.0.0
tbrent Jun 12, 2024
718b22d
CHANGELOG
tbrent Jun 12, 2024
dd288e7
Fix Rtoken Exteme test (#1157)
julianmrodri Jun 14, 2024
35057d7
Tweaks
akshatmittal Jun 17, 2024
80a9fea
fix comment
tbrent Jun 17, 2024
448b633
distributor small simplification
tbrent Jun 17, 2024
9972e7e
change name of priceNotDecayed function
tbrent Jun 17, 2024
62542ec
document DAO fee rounding
tbrent Jun 18, 2024
9571eb8
rename to pricedAtTimestamp
tbrent Jun 18, 2024
94ef476
uncomment .skip
tbrent Jun 18, 2024
4c1be60
add test cases for >uint96 amounts in Broker.openTrade
tbrent Jun 18, 2024
edc464a
switch to better approach of tracking worst case price at qTok level
tbrent Jun 18, 2024
80c2344
lint clean
tbrent Jun 18, 2024
f486bdc
Role Registry
akshatmittal Jun 19, 2024
b894407
Merge branch '4.0.0' into registry-roles
akshatmittal Jun 19, 2024
84440a0
Fix tests
akshatmittal Jun 19, 2024
e4c3ed8
Role Registry (#1158)
akshatmittal Jun 19, 2024
93d2831
Scenario test large decimals (#1159)
julianmrodri Jun 19, 2024
e17a559
reserveGas()
tbrent Jun 21, 2024
8c9aa67
update mev docs with issuance/redemption instructions
tbrent Jun 21, 2024
25a3525
Update DAO Fee Registry
akshatmittal Jun 21, 2024
5ad47d9
Merge branch 'registry-roles' into 4.0.0
akshatmittal Jun 21, 2024
349c922
upgrade mismatch check
akshatmittal Jun 21, 2024
6c1740c
Fix test
akshatmittal Jun 21, 2024
2683d0d
fix issue/redeem interface
tbrent Jun 21, 2024
49e4d01
fix base address
tbrent Jun 21, 2024
aaae971
make proposal validator able to simulate proposal to execution from a…
tbrent Jun 23, 2024
de7b0fe
spell pt 2 validation
tbrent Jun 23, 2024
2f0e735
add 1e9 precision to GnosisTrade price calculations
tbrent Jun 24, 2024
9598658
Usdm plugin and scripts (#1146)
julianmrodri Jun 26, 2024
1a434f3
Deployed addresses - Docs (#1160)
julianmrodri Jun 26, 2024
8702fed
Document up to 21 decimals supported (#1162)
julianmrodri Jun 26, 2024
5e0717b
upload metamorpho audit
tbrent Jul 3, 2024
9dd5218
upload ETH+/ETH LP audit
tbrent Jul 3, 2024
6c654f6
rename
tbrent Jul 3, 2024
16b615d
add rounding to _quantity()
tbrent Jul 4, 2024
321a216
remove comment
tbrent Jul 5, 2024
841d927
add clarifying trackStatus() comments
tbrent Jul 5, 2024
49e8334
add comment
tbrent Jul 5, 2024
0e3fd42
Add comment in version registry (#1170)
julianmrodri Jul 5, 2024
f4cb39a
Add new deployed addrs (#1169)
julianmrodri Jul 5, 2024
dc42b06
Run prettier (#1168)
julianmrodri Jul 5, 2024
297d06e
Add explicit rounding direction (#1167)
julianmrodri Jul 5, 2024
b5469ee
Merge branch 'master' into 4.0.0
tbrent Jul 5, 2024
f25f6c3
fix revenue hiding test (#1171)
julianmrodri Jul 9, 2024
d47d996
easy auction test case
julianmrodri Jul 9, 2024
d9283c6
document 21 decimals with caveats
tbrent Jul 9, 2024
792e193
document non-manipulable price
tbrent Jul 9, 2024
7050979
high price for trade sizing (#1172)
tbrent Jul 11, 2024
e592536
upload june plugin audit
tbrent Jul 11, 2024
2b4a529
few additional comments
tbrent Jul 12, 2024
72d9278
revert over selling large lot
tbrent Jul 15, 2024
a2f9eba
document bm should not sell unpriced assets
tbrent Jul 15, 2024
a44bbb4
add revert for [>0, FIX_MAX] case
tbrent Jul 15, 2024
d0315e7
nit
tbrent Jul 15, 2024
6f68240
fix sDAI whale
tbrent Jul 16, 2024
429eaa6
Merge branch 'master' into 4.0.0
tbrent Jul 22, 2024
63bdb51
update backing buffer description
tbrent Jul 24, 2024
a743a05
Issuance Premium v2 (#1175)
tbrent Jul 25, 2024
5a82ec4
Merge branch 'master' into 4.0.0
tbrent Jul 25, 2024
1c961c9
upload 4.0.0 audit
tbrent Jul 26, 2024
72fc1f6
Registry tests (#1176)
tbrent Jul 29, 2024
5e9523f
Merge branch '4.0.0' into fuzz-final-4.0.0
julianmrodri Aug 14, 2024
867d818
get to compile
julianmrodri Aug 14, 2024
efc88eb
fix tests
julianmrodri Aug 14, 2024
b5fe7a5
remove console
julianmrodri Aug 14, 2024
cf4400b
set issuance premium
julianmrodri Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
restore-keys: |
hardhat-network-fork-${{ runner.os }}-
hardhat-network-fork-
- run: npx hardhat test ./test/plugins/individual-collateral/{aave-v3,compoundv3,curve/cvx}/*.test.ts
- run: npx hardhat test ./test/plugins/individual-collateral/{aave-v3,compoundv3,curve/cvx,mountain}/*.test.ts
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
Expand Down Expand Up @@ -314,3 +314,17 @@ jobs:
FORK_NETWORK: mainnet
FORK: 1
PROTO_IMPL: 1

registry-tests:
name: 'Registry Tests'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'yarn'
- run: yarn install --immutable
- run: yarn test:registries
env:
NODE_OPTIONS: '--max-old-space-size=32768'
43 changes: 35 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,67 @@

This release prepares the core protocol for veRSR through the introduction of 3 registries (`DAOFeeRegistry`, `AssetPluginRegistry`, and `VersionRegistry`) and through restricting component upgrades to be handled by `Main`, where upgrade constraints can be enforced.

The release also expands collateral decimal support from 18 to 27.
The release also expands collateral decimal support from 18 to 21, with some caveats about minimum token value. See [docs/solidity-style.md](./docs/solidity-style.md#Collateral-decimals) for more details.

Finally, it adds resistance to toxic issuance by charging more when the collateral is under peg.

## Upgrade Steps

TODO
Upgrade to 4.0.0 is expected to occur by spell. This section is still TODO, but some important notes for steps that should be hit:

Make sure distributor table sums to >10000.
- Distributor table must sum to >=10000
- Opt RTokens into the issuance premium by default
- Upgrade all collateral plugins and RTokenAsset
- ...

## Core Protocol Contracts

All components: make Main the only component that can call `upgradeTo()`

- `AssetRegistry`
- Prevent registering assets that are not in the `AssetPluginRegistry`
- Add `validateCurrentAssets() view`
- `Broker`
- Make setters only callable by `Main`
- `BackingManager`
- Switch from sizing trades using the low price to the high price
- `BasketHandler`
- Add `issuancePremium() view returns (uint192)`
- Add `setIssuancePremiumEnabled(bool)`, callable by governance. Begins disabled by default for upgraded RTokens
- Add `quote(uint192 amount, bool applyIssuancePremium, RoundingMode rounding)`
- Modify `quote(uint192 amount, RoundingMode rounding)` to include the issuance premium
- Add `price(bool applyIssuancePremium)`
- Modify `price()` to include the issuance premium
- Remove `lotPrice()`
- Minor changes to require error strings
- `Deployer`
- Add `enableIssuancePremium` parameter to `IDeployer.DeploymentParams`
- `Distributor`
- Add `setDistributions()` function to parallel `setDistribution()`
- Take DAO fee out account in `distribute()` and `totals()`
- Take DAO fee into account in `distribute()` and `totals()`
- Add new revenue share table invariant: must sum to >=10000 (for precision reasons)
- `Main`
- Add `versionRegistry()`/`assetPluginRegistry()`/`daoFeeRegistry()` getters
- Add `setVersionRegistry()`/`setAssetPluginRegistry()`/`setDaoFeeRegistry()` setters
- Add `upgradeMainTo()` + `upgradeRTokenTo()` functions to handle upgrade of Main + Components
- Make Main the only caller that can upgrade Main
- `RevenueTrader`
- Switch from sizing trades using the low price to the high price

## Plugins

### Assets

No functional change. FLOOR rounding added explicitly to `shiftl_toFix`
- Support expanded from 18 to 21 decimals, with minimum collateral token value requirement of `$0.001` at-peg.
- FLOOR rounding added explicitly to `shiftl_toFix` everywhere

#### Collateral

Add `savedPegPrice` to `ICollateral` interface

### Trading

Small bugfix to `GnosisTrade`. Should prevent donated tokens from causing the trade to revert.
- `GnosisTrade`
- Change units of `worstCasePrice()` from {buyTok/sellTok} to {qBuyTok/qSellTok}
- Small fix to prevent donated tokens from being able to cause the trade to revert

### Facades

Expand Down
Binary file added audits/Reserve_June_Plugins_v1.pdf
Binary file not shown.
Binary file added audits/Reserve_PR_4_0_0_v1.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions common/blockchain-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export const getChainId = async (hre: HardhatRuntimeEnvironment): Promise<string
switch (useEnv('FORK_NETWORK').toLowerCase()) {
case 'mainnet':
_chainId = '1'
break;
break
case 'base':
_chainId = '8453'
break;
break
case 'arbitrum':
_chainId = '42161'
break;
break
}
}
return _chainId
Expand Down
8 changes: 8 additions & 0 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export interface ITokens {
bbUSDT?: string
steakPYUSD?: string
Re7WETH?: string

// Mountain
USDM?: string
wUSDM?: string
}

export type ITokensKeys = Array<keyof ITokens>
Expand Down Expand Up @@ -541,6 +545,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
saArbUSDCn: '', // TODO our wrapper. remove from deployment script after placing here
aArbUSDT: '0x6ab707aca953edaefbc4fd23ba73294241490620',
saArbUSDT: '', // TODO our wrapper. remove from deployment script after placing here
USDM: '0x59d9356e565ab3a36dd77763fc0d87feaf85508c',
wUSDM: '0x57f5e098cad7a3d1eed53991d4d66c45c9af7812',
},
chainlinkFeeds: {
ARB: '0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6',
Expand All @@ -550,6 +556,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
USDT: '0x3f3f5dF88dC9F13eac63DF89EC16ef6e7E25DdE7',
RSR: '0xcfF9349ec6d027f20fC9360117fef4a1Ad38B488',
crvUSD: '0x0a32255dd4BB6177C994bAAc73E0606fDD568f66',
wUSDM: '0xdC6720c996Fad27256c7fd6E0a271e2A4687eF18',
},
GNOSIS_EASY_AUCTION: '0xcD033976a011F41D2AB6ef47984041568F818E73', // our deployment
COMET_REWARDS: '0x88730d254A2f7e6AC8388c3198aFd694bA9f7fae',
Expand Down Expand Up @@ -592,6 +599,7 @@ export interface IConfig {
withdrawalLeak: BigNumber
warmupPeriod: BigNumber
reweightable: boolean
enableIssuancePremium: boolean
tradingDelay: BigNumber
batchAuctionLength: BigNumber
dutchAuctionLength: BigNumber
Expand Down
6 changes: 4 additions & 2 deletions contracts/facade/facets/MaxIssuableFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../interfaces/IBasketHandler.sol";
import "../../interfaces/IRToken.sol";
import "../../libraries/Fixed.sol";
import "../../p1/BasketHandler.sol";

/**
* @title MaxIssuableFacet
Expand All @@ -21,7 +22,8 @@ contract MaxIssuableFacet {
/// @return {qRTok} How many RToken `account` can issue given current holdings
/// @custom:static-call
function maxIssuable(IRToken rToken, address account) external returns (uint256) {
(address[] memory erc20s, ) = rToken.main().basketHandler().quote(FIX_ONE, FLOOR);
BasketHandlerP1 bh = BasketHandlerP1(address(rToken.main().basketHandler()));
(address[] memory erc20s, ) = bh.quote(FIX_ONE, FLOOR);
uint256[] memory balances = new uint256[](erc20s.length);
for (uint256 i = 0; i < erc20s.length; ++i) {
balances[i] = IERC20(erc20s[i]).balanceOf(account);
Expand All @@ -45,7 +47,7 @@ contract MaxIssuableFacet {
main.assetRegistry().refresh();

// Get basket ERC20s
IBasketHandler bh = main.basketHandler();
BasketHandlerP1 bh = BasketHandlerP1(address(main.basketHandler()));
(address[] memory erc20s, uint256[] memory quantities) = bh.quote(FIX_ONE, CEIL);

// Compute how many baskets we can mint with the collateral amounts
Expand Down
22 changes: 11 additions & 11 deletions contracts/facade/facets/ReadFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract ReadFacet {

// Cache components
IRToken rTok = rToken;
IBasketHandler bh = main.basketHandler();
BasketHandlerP1 bh = BasketHandlerP1(address(main.basketHandler()));
IAssetRegistry reg = main.assetRegistry();

// Poke Main
Expand All @@ -69,9 +69,7 @@ contract ReadFacet {
uint192 mid = (low + high) / 2;

// {UoA} = {tok} * {UoA/Tok}
depositsUoA[i] = shiftl_toFix(deposits[i], -int8(asset.erc20Decimals()), FLOOR).mul(
mid
);
depositsUoA[i] = shiftl_toFix(deposits[i], -int8(asset.erc20Decimals()), CEIL).mul(mid);
}
}

Expand All @@ -93,7 +91,7 @@ contract ReadFacet {

// Cache Components
IRToken rTok = rToken;
IBasketHandler bh = main.basketHandler();
BasketHandlerP1 bh = BasketHandlerP1(address(main.basketHandler()));

// Poke Main
main.assetRegistry().refresh();
Expand Down Expand Up @@ -175,7 +173,7 @@ contract ReadFacet {
{
uint256[] memory deposits;
IAssetRegistry assetRegistry = rToken.main().assetRegistry();
IBasketHandler basketHandler = rToken.main().basketHandler();
BasketHandlerP1 basketHandler = BasketHandlerP1(address(rToken.main().basketHandler()));

// solhint-disable-next-line no-empty-blocks
try rToken.main().furnace().melt() {} catch {} // <3.1.0 RTokens may revert while frozen
Expand Down Expand Up @@ -301,7 +299,8 @@ contract ReadFacet {

/// @return tokens The ERC20s backing the RToken
function basketTokens(IRToken rToken) external view returns (address[] memory tokens) {
(tokens, ) = rToken.main().basketHandler().quote(FIX_ONE, RoundingMode.FLOOR);
BasketHandlerP1 bh = BasketHandlerP1(address(rToken.main().basketHandler()));
(tokens, ) = bh.quote(FIX_ONE, RoundingMode.FLOOR);
}

/// Returns the backup configuration for a given targetName
Expand Down Expand Up @@ -337,10 +336,11 @@ contract ReadFacet {
uint192 uoaNeeded; // {UoA}
uint192 uoaHeldInBaskets; // {UoA}
{
(address[] memory basketERC20s, uint256[] memory quantities) = rToken
.main()
.basketHandler()
.quote(basketsNeeded, FLOOR);
BasketHandlerP1 bh = BasketHandlerP1(address(rToken.main().basketHandler()));
(address[] memory basketERC20s, uint256[] memory quantities) = bh.quote(
basketsNeeded,
FLOOR
);

IAssetRegistry reg = rToken.main().assetRegistry();
IBackingManager bm = rToken.main().backingManager();
Expand Down
84 changes: 34 additions & 50 deletions contracts/fuzz/CollateralMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,56 +123,40 @@ contract CollateralMock is OracleErrorMock, AppreciatingFiatCollateral {
}
}

// DEPRECATED
// A CollateralMock that does not use decaying lotPrice()s, but instead just returns the last saved
// value. Needed for DiffTest, because refresh() doesn't always happen in the same block on both P0
// and P1.
contract CollateralNoDecay is CollateralMock {
function lotPrice()
external
view
virtual
override(Asset, IAsset)
returns (uint192 lotLow, uint192 lotHigh)
{
try this.tryPrice() returns (uint192 low, uint192 high, uint192) {
// if the price feed is still functioning, use that
return (low, high);
} catch (bytes memory errData) {
// see: docs/solidity-style.md#Catching-Empty-Data
if (errData.length == 0) revert(); // solhint-disable-line reason-string
return (savedLowPrice, savedHighPrice);
}
}

constructor(
// Collateral base-class arguments
IERC20Metadata erc20_,
uint192 maxTradeVolume_,
uint48 priceTimeout_,
uint192 oracleError_,
uint192 defaultThreshold_,
uint48 delayUntilDefault_,
bytes32 targetName_,
// Price Models
PriceModel memory refPerTokModel_, // Ref units per token
PriceModel memory targetPerRefModel_, // Target units per ref unit
PriceModel memory uoaPerTargetModel_, // Units-of-account per target unit
PriceModel memory deviationModel_,
uint192 revenueHiding
)
CollateralMock(
erc20_,
maxTradeVolume_,
priceTimeout_,
oracleError_,
defaultThreshold_,
delayUntilDefault_,
targetName_,
refPerTokModel_,
targetPerRefModel_,
uoaPerTargetModel_,
deviationModel_,
revenueHiding
)
{}
}
// contract CollateralNoDecay is CollateralMock {
// constructor(
// // Collateral base-class arguments
// IERC20Metadata erc20_,
// uint192 maxTradeVolume_,
// uint48 priceTimeout_,
// uint192 oracleError_,
// uint192 defaultThreshold_,
// uint48 delayUntilDefault_,
// bytes32 targetName_,
// // Price Models
// PriceModel memory refPerTokModel_, // Ref units per token
// PriceModel memory targetPerRefModel_, // Target units per ref unit
// PriceModel memory uoaPerTargetModel_, // Units-of-account per target unit
// PriceModel memory deviationModel_,
// uint192 revenueHiding
// )
// CollateralMock(
// erc20_,
// maxTradeVolume_,
// priceTimeout_,
// oracleError_,
// defaultThreshold_,
// delayUntilDefault_,
// targetName_,
// refPerTokModel_,
// targetPerRefModel_,
// uoaPerTargetModel_,
// deviationModel_,
// revenueHiding
// )
// {}
// }
2 changes: 1 addition & 1 deletion contracts/fuzz/FuzzP0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ contract RTokenP0Fuzz is IRTokenFuzz, RTokenP0 {
? basketsNeeded.muluDivu(amount, totalSupply()) // {BU * qRTok / qRTok}
: uint192(amount); // {qRTok / qRTok}

return main.basketHandler().quote(baskets, roundingMode);
return main.basketHandler().quote(baskets, true, roundingMode);
}

function _msgSender() internal view virtual override returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/fuzz/FuzzP1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ contract RTokenP1Fuzz is IRTokenFuzz, RTokenP1 {
? basketsNeeded.muluDivu(amount, totalSupply()) // {BU * qRTok / qRTok}
: uint192(amount); // {qRTok / qRTok}

return main.basketHandler().quote(baskets, roundingMode);
return main.basketHandler().quote(baskets, true, roundingMode);
}

function _msgSender() internal view virtual override returns (address) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/fuzz/MainP0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ contract MainP0Fuzz is IMainFuzz, MainP0 {
params.minTradeVolume
);

basketHandler.init(this, params.warmupPeriod, params.reweightable);
basketHandler.init(this, params.warmupPeriod, params.reweightable, params.enableIssuancePremium);
rsrTrader.init(this, rsr, params.maxTradeSlippage, params.minTradeVolume);
rTokenTrader.init(
this,
Expand Down
2 changes: 1 addition & 1 deletion contracts/fuzz/MainP1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ contract MainP1Fuzz is IMainFuzz, MainP1 {
params.minTradeVolume
);

basketHandler.init(this, params.warmupPeriod, params.reweightable);
basketHandler.init(this, params.warmupPeriod, params.reweightable, params.enableIssuancePremium);
rsrTrader.init(this, rsr, params.maxTradeSlippage, params.minTradeVolume);
rTokenTrader.init(
this,
Expand Down
3 changes: 2 additions & 1 deletion contracts/fuzz/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function defaultParams() pure returns (DeploymentParams memory params) {
issuanceThrottle: tParams,
redemptionThrottle: tParams,
warmupPeriod: 259200,
reweightable: false
reweightable: false,
enableIssuancePremium: true
});
}

Expand Down
4 changes: 4 additions & 0 deletions contracts/fuzz/scenarios/ChaosOps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,10 @@ contract ChaosOpsScenario {
main.setLongFreeze(freeze);
}

function setIssuancePremiumEnabled(uint256 seed) public {
BasketHandlerP1(address(main.basketHandler())).setIssuancePremiumEnabled((seed % 2) == 0);
}

// Grant/Revoke Roles
function grantRole(uint8 which, uint8 userID) public {
address user = main.someAddr(userID);
Expand Down
Loading
Loading