Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
9664127
ICollateralizationOracle
Aug 16, 2021
5d30487
Mock Collateralzation Oracle
Aug 16, 2021
95dae5f
Implement StableSwapOperatorV1
eswak Aug 20, 2021
ab04e1d
Add mock contracts for StableSwapOperatorV1
eswak Aug 20, 2021
a0279ff
Add unit tests for StableSwapOperatorV1
eswak Aug 20, 2021
4e86d8d
Add deploy script for StableSwapOperatorV1
eswak Aug 20, 2021
bf73d00
Add e2e tests for StableSwapOperatorV1
eswak Aug 20, 2021
f8d6877
Set private variables as immutable for gas optimization
eswak Aug 22, 2021
cde454d
Fix typo
eswak Aug 22, 2021
2b04064
Use safeApprove for DAI & USDC, like for USDT
eswak Aug 22, 2021
7e3f254
Fix comments around 'emit event' in deposit()
eswak Aug 22, 2021
c4316c2
Remove withdraw 0 = all logic (now reverts)
eswak Aug 22, 2021
23d203b
Remove FEI burns on deposit() & withdraw()
eswak Aug 22, 2021
9663e29
Open deposit() to all (not only PCV controller)
eswak Aug 24, 2021
390e26e
Add slippage check on metapool deposit
eswak Aug 24, 2021
04e3175
Account for 0.015% fees on withdraw_liquidity_one_coin()
eswak Aug 24, 2021
e695c37
Add call to withdraw() in e2e tests
eswak Aug 24, 2021
7e55e30
Joey's 2nd review
eswak Aug 25, 2021
9a9405f
Merge branch 'master' into feature-curve-deposit
eswak Aug 25, 2021
ff5b4fb
Merge branch 'master' into feat/v2
Sep 3, 2021
e3cdc84
Add first draft of Collateralization Oracle
eswak Aug 24, 2021
f057f91
Update CollateralizationOracle.sol to implement Joey's interface
eswak Aug 31, 2021
fe9131f
Add CollateralizationOracle mock contracts & unit tests
eswak Aug 31, 2021
91a2c84
Update CR Oracle events
eswak Sep 4, 2021
61b4efc
CR Oracle : spell the words x2y -> xToY
eswak Sep 4, 2021
f8c4eba
CR Oracle : isTokenInPcv uint8 -> bool
eswak Sep 4, 2021
3023db5
CR Oracle : break on !found & pop() on find
eswak Sep 4, 2021
69260fe
CR Oracle : break on !found & pop() on find
eswak Sep 4, 2021
590a830
CR Oracle : small gas optimization on multiplication
eswak Sep 4, 2021
b261efe
CR Oracle : update interfaces & less reverts
eswak Sep 4, 2021
2ddc62b
CR Oracle : add swapDeposit(old, new) function
eswak Sep 4, 2021
92b32fe
No hardcoded oracle price of 0 for FEI
eswak Sep 4, 2021
2c5dd58
Revert isOvercollateralized() if reading is invalid
eswak Sep 4, 2021
925e94e
Remove .only in ERC20Dripper
eswak Sep 4, 2021
9339dc6
Add mapping of excludedDeposits set by guardian
eswak Sep 4, 2021
031a983
Remove pcvDeposits array
eswak Sep 4, 2021
a30c1b9
Use EnumerableSet & add getters
eswak Sep 4, 2021
02b7700
Use signed int256 for protocol equity
eswak Sep 4, 2021
344aa49
TribeSplitter
Sep 5, 2021
2f5dfef
Name return variables in ICollateralizationOracle::pcvStats()
eswak Sep 5, 2021
0a65c4e
CR oracle : remove unused code
eswak Sep 5, 2021
f99e3f9
Update IPCVDepositV2 balanceAndFei() -> resistantBalanceAndFei()
eswak Sep 5, 2021
2a5fe44
CR Oracle : simplify code of swapDeposit (call remove & add)
eswak Sep 5, 2021
982a70a
Add check in setOracle for non-zero token & oracle
eswak Sep 5, 2021
09574a5
CR Oracle : fetch oracle price outside of deposit loop
eswak Sep 5, 2021
bf29d9e
Remove check on similar token in swapDeposit
eswak Sep 5, 2021
ff99edb
Merge pull request #146 from eswak/feature-collateralization-oracle
eswak Sep 5, 2021
4f93032
rate limited minter
Sep 5, 2021
50e399c
ERC20 splitter
Sep 5, 2021
080b7ea
resistant balances
Sep 6, 2021
3343160
PCVDepositWrapper
Sep 6, 2021
27e308f
remove .only
Sep 6, 2021
411af53
add tests
Sep 7, 2021
e030d53
split ratelimited and ratelimitedMinter
Sep 7, 2021
46071e3
tribe reserve stabilizer
Aug 16, 2021
4f5bd08
update reserve stabilizer logic + tests
Sep 3, 2021
d118de3
allow non-tribe ERC20 withdrawals
Sep 3, 2021
3d786e4
add comments
Sep 6, 2021
72bd82d
use token consistently
Sep 6, 2021
d36706f
add rate limit
Sep 7, 2021
9b0a15c
temp
Aug 18, 2021
610da9b
update logic and add getters
Sep 4, 2021
b59dbca
rename to FEI timed minter and split
Sep 5, 2021
8ec5bb0
FeiTimedMinter test
Sep 5, 2021
01034fa
Add first draft of Collateralization Oracle
eswak Aug 24, 2021
ef896e0
Update CollateralizationOracle.sol to implement Joey's interface
eswak Aug 31, 2021
5e143bb
Add CollateralizationOracle mock contracts & unit tests
eswak Aug 31, 2021
c1cd53e
Update CR Oracle events
eswak Sep 4, 2021
b377631
CR Oracle : spell the words x2y -> xToY
eswak Sep 4, 2021
a745558
CR Oracle : isTokenInPcv uint8 -> bool
eswak Sep 4, 2021
3d7a212
CR Oracle : break on !found & pop() on find
eswak Sep 4, 2021
aebc226
CR Oracle : break on !found & pop() on find
eswak Sep 4, 2021
3e41f4d
CR Oracle : small gas optimization on multiplication
eswak Sep 4, 2021
6f7eb14
CR Oracle : update interfaces & less reverts
eswak Sep 4, 2021
2f7eadc
CR Oracle : add swapDeposit(old, new) function
eswak Sep 4, 2021
19be12b
No hardcoded oracle price of 0 for FEI
eswak Sep 4, 2021
904ba47
Revert isOvercollateralized() if reading is invalid
eswak Sep 4, 2021
13dcae7
Remove .only in ERC20Dripper
eswak Sep 4, 2021
a05a359
Add mapping of excludedDeposits set by guardian
eswak Sep 4, 2021
b580f75
Remove pcvDeposits array
eswak Sep 4, 2021
fbb5714
Use EnumerableSet & add getters
eswak Sep 4, 2021
d7f3453
Use signed int256 for protocol equity
eswak Sep 4, 2021
19027a1
Name return variables in ICollateralizationOracle::pcvStats()
eswak Sep 5, 2021
cd1a4de
CR oracle : remove unused code
eswak Sep 5, 2021
b518e36
Update IPCVDepositV2 balanceAndFei() -> resistantBalanceAndFei()
eswak Sep 5, 2021
b026acc
CR Oracle : simplify code of swapDeposit (call remove & add)
eswak Sep 5, 2021
320b9a0
Add check in setOracle for non-zero token & oracle
eswak Sep 5, 2021
323a5db
CR Oracle : fetch oracle price outside of deposit loop
eswak Sep 5, 2021
71ed330
Remove check on similar token in swapDeposit
eswak Sep 5, 2021
1e60cfa
safecast PCVEquityMinter
Sep 5, 2021
0f34b33
remove 0 check on initialMintAmount
Sep 5, 2021
988855e
PCV Equity Minter tests
Sep 5, 2021
57a450c
lint
Sep 5, 2021
6916744
add rate limited minter to pcv equity minter
Sep 7, 2021
dca6263
Merge branch 'feat/v2' into feat/v2-TribeRewardsController
Sep 7, 2021
d2f4278
fix test
Sep 7, 2021
4bd7579
Add first draft of CollateralizationMemoizer
eswak Sep 7, 2021
c71f0e4
rename revert strings
Sep 7, 2021
5c6c54b
add comments
Sep 7, 2021
9cbaead
add a comment
Sep 9, 2021
7ca741b
Joey review 1/2
eswak Sep 10, 2021
9e603b3
Joey review 2/2
eswak Sep 10, 2021
491fff8
Add unit tests for CollateralizationOracleWrapper
eswak Sep 10, 2021
ca1b000
CR Oracle wrapper : Joey 2nd review
eswak Sep 10, 2021
056f9c4
install balancer
Sep 10, 2021
47c1829
add balancer swapper
Sep 10, 2021
898dcbe
add deployment scripts, e2e, and updated logic
Sep 11, 2021
a98a5d1
Merge pull request #157 from eswak/feat/v2-CROracleMemoizer
Joeysantoro Sep 11, 2021
dddd734
Merge pull request #156 from fei-protocol/feat/v2-PCVDepositWrapper
Joeysantoro Sep 11, 2021
cdc5d84
Merge pull request #154 from fei-protocol/feat/v2-RatelimitedMinter
Joeysantoro Sep 11, 2021
85bf2c4
Merge pull request #153 from fei-protocol/feat/v2-TribeSplitter
Joeysantoro Sep 11, 2021
28342c8
Merge pull request #151 from fei-protocol/feat/v2-TribeReserveStabilizer
Joeysantoro Sep 11, 2021
a6086b1
Merge branch 'feat/v2' into feature-curve-deposit
Joeysantoro Sep 11, 2021
b93d2e0
Merge pull request #137 from eswak/feature-curve-deposit
Joeysantoro Sep 11, 2021
922eed2
Merge branch 'feat/v2-RatelimitedMinter' into feat/v2-TribeRewardsCon…
Joeysantoro Sep 11, 2021
76785f6
Merge branch 'feat/v2' into feat/v2-TribeRewardsController
Joeysantoro Sep 11, 2021
a069af1
Merge pull request #160 from fei-protocol/feat/v2-TribeRewardsController
Joeysantoro Sep 11, 2021
d60950b
add hook to Fei Timed Minter
Sep 11, 2021
fdf0783
refactor collateralization oracle wrapper + add keeper
Sep 12, 2021
d645549
test cleanup
Sep 12, 2021
0355d36
add comments
Sep 12, 2021
26a62ba
remove .only
Sep 12, 2021
21d2f2a
Collateralization oracle utilities
Sep 12, 2021
5bbda8a
fix tests
Sep 12, 2021
2a5e70f
add initialize + tests
Sep 12, 2021
0fb19d4
linting
Sep 12, 2021
538434d
move IPCVSwapper interface
Sep 12, 2021
5552fce
settable global vars
Sep 12, 2021
f5ae827
constants lib
Sep 12, 2021
0aa4acd
Merge pull request #155 from fei-protocol/feat/v2-Add-Resistant-Balances
Joeysantoro Sep 12, 2021
830fb9d
Merge pull request #161 from fei-protocol/feat/v2-Enhance-Timed-Minter
Joeysantoro Sep 12, 2021
5a21384
Merge branch 'feat/v2' into feat/v2-CollateralizationOracleWrapperRef…
Sep 12, 2021
b1707ea
use afterMint hook
Sep 12, 2021
736011b
comment fix
Sep 12, 2021
ffbb44f
doc
Sep 12, 2021
f122131
Merge branch 'feat/v2' into feat/v2-Constants-Lib
Joeysantoro Sep 12, 2021
29224df
Merge pull request #165 from fei-protocol/feat/v2-Constants-Lib
Joeysantoro Sep 12, 2021
b100d60
Merge branch 'feat/v2' into feat/v2-Collateralization-Oracle-Utilities
Joeysantoro Sep 12, 2021
7e0156c
Merge pull request #163 from fei-protocol/feat/v2-Collateralization-O…
Joeysantoro Sep 12, 2021
bd9ebda
Merge pull request #164 from fei-protocol/feat/v2-CR-Wrapper-Proxy
Joeysantoro Sep 12, 2021
9cd6200
Merge pull request #162 from fei-protocol/feat/v2-CollateralizationOr…
Joeysantoro Sep 12, 2021
e12fa9b
weth constants
Sep 12, 2021
54c3292
split PCVDeposit interface
Sep 12, 2021
7d0ba56
Merge pull request #166 from fei-protocol/feat/v2-Constants-Pt2
Joeysantoro Sep 12, 2021
9682f70
doc
Sep 12, 2021
1458b2c
Merge pull request #167 from fei-protocol/feat/v2-Split-IPCVDeposit
Joeysantoro Sep 12, 2021
307b192
Merge branch 'feat/v2' into feat/v2-balancer-LBP
Sep 12, 2021
398b4cf
LBPSwapper comments
Sep 12, 2021
f1c2855
fix init logic
Sep 12, 2021
d3ed707
fix import
Sep 12, 2021
2f8200f
comments on balancer code
Sep 12, 2021
2a506ab
test
Sep 12, 2021
cef92a6
batched setters in constructor + tests
Sep 12, 2021
e3c46be
Merge pull request #168 from fei-protocol/feat/v2-CR-Oracle-Constructor
Joeysantoro Sep 12, 2021
4734654
Merge pull request #159 from fei-protocol/feat/v2-balancer-LBP
Joeysantoro Sep 12, 2021
8c05dd1
temp
Sep 12, 2021
4ae238e
Add resistantBalanceAndFei to Curve deposit
eswak Sep 12, 2021
b125167
in-progress test updates
xklob Sep 12, 2021
2bde65d
fix remaining two tests
xklob Sep 13, 2021
334ad57
fix some magic numbers & add in governance for ratios
xklob Sep 13, 2021
f859001
fix linter issues
xklob Sep 13, 2021
cb47e63
v2 Deploy part 1
Sep 13, 2021
3ebf201
update hardhat config to add enable_mainnet_forking env
xklob Sep 13, 2021
724f029
Deploy Pt 2
Sep 13, 2021
d9bf115
static wrapper test
Sep 13, 2021
93238e3
rename price
Sep 13, 2021
7d676b1
fix test
Sep 13, 2021
ae2fe46
add internal methods for min/max ratios
xklob Sep 13, 2021
c5d21ed
Merge pull request #170 from fei-protocol/feat/v2-doc-and-cleanup-upd…
Joeysantoro Sep 13, 2021
f050c5e
fixed bugs
xklob Sep 13, 2021
4ba1e6e
end to end tests
Sep 13, 2021
2d63a77
test fix
Sep 13, 2021
bbdc802
Merge branch 'feat/v2' into feat/v2-Deploy
Joeysantoro Sep 13, 2021
a10b3f7
Merge pull request #171 from fei-protocol/feat/v2-Deploy
Joeysantoro Sep 13, 2021
7a83461
Merge pull request #172 from fei-protocol/feat/v2-Deploy-Pt2
Joeysantoro Sep 13, 2021
58bd231
Merge branch 'feat/v2' into feat/v2-curve-deposit-balance
Joeysantoro Sep 13, 2021
8552a81
Merge pull request #169 from eswak/feat/v2-curve-deposit-balance
Joeysantoro Sep 13, 2021
e44fb6f
update StableSwapOperator, add coverage tests, fix bugs
xklob Sep 13, 2021
a5c23f6
remove .only
Sep 13, 2021
3b8d220
fix compile
Sep 13, 2021
96e35db
Merge pull request #174 from fei-protocol/feat/v2-code-coverage
Joeysantoro Sep 13, 2021
334306d
Merge pull request #173 from fei-protocol/feat/v2-e2e
Joeysantoro Sep 13, 2021
96eaf0a
Merge pull request #175 from fei-protocol/feat/v2-Deploy-Pt2
Joeysantoro Sep 13, 2021
35e94c2
cleanup
Sep 14, 2021
fb7bd9b
update e2e
Sep 14, 2021
a2bf430
remove unused param
Sep 14, 2021
5e3e2ab
Merge pull request #179 from fei-protocol/feat/cleanup-lbp-withdrawal
Joeysantoro Sep 15, 2021
f00dcb3
fix test
Sep 18, 2021
1e98fb2
Merge branch 'master' into feat/v2
Joeysantoro Sep 20, 2021
479e83b
lint
Sep 20, 2021
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
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"configureYulOptimizer": true
};
18 changes: 17 additions & 1 deletion contract-addresses/mainnetAddresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"aaveGovernanceV2Address" : {"artifact" : "IAaveGovernanceV2", "address" : "0xEC568fffba86c094cf06b22134B23074DFE2252c"},
"aaveIncentivesControllerAddress" : {"address": "0xd784927ff2f95ba542bfc824c8a8a98f3495f6b5"},
"aaveLendingPoolAddress" : {"artifact" : "ILendingPool", "address": "0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9"},
"aaveRaiPCVDeposit": {"artifact" : "AavePCVDeposit", "address": "0xd2174d78637a40448112aa6B30F9B19e6CF9d1F9"},
"aaveRaiPCVDepositAddress": {"artifact" : "AavePCVDeposit", "address": "0xd2174d78637a40448112aa6B30F9B19e6CF9d1F9"},
"aaveTribeIncentivesControllerAddress" : {"artifact": "IAaveIncentivesController", "address": "0xDee5c1662bBfF8f80f7c572D8091BF251b3B0dAB"},
"aaveTribeIncentivesControllerProxyAddress" : {"artifact": "TransparentUpgradeableProxy", "address": "0xDee5c1662bBfF8f80f7c572D8091BF251b3B0dAB"},
"aaveTribeIncentivesControllerImplAddress" : {"address": "0xFF865335401F12B88fa3FF5A3a51685A7f224191"},
Expand All @@ -16,6 +16,10 @@
"aFeiVariableDebtAddress" : {"artifact" : "IERC20", "address": "0xC2e10006AccAb7B45D9184FcF5b7EC7763f5BaAe"},
"aRaiAddress" : {"address": "0xc9BC48c72154ef3e5425641a3c747242112a46AF"},
"aWETHAddress" : {"address": "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e"},
"balancerAdminAddress" : {"address" : "0x10A19e7eE7d7F8a52822f6817de8ea18204F2e4f"},
"balancerAuthorizerAddress" : {"artifact": "Permissions", "address" : "0xA331D84eC860Bf466b4CdCcFb4aC09a1B43F3aE6"},
"balancerLBPoolFactoryAddress" : {"artifact" : "ILiquidityBootstrappingPoolFactory", "address": "0x751A0bC0e3f75b38e01Cf25bFCE7fF36DE1C87DE"},
"balancerVaultAddress" : {"artifact": "IVault", "address" : "0xBA12222222228d8Ba445958a75a0704d566BF2C8"},
"bentoBoxAddress" : { "artifact" : "IMasterContractManager", "address" : "0xF5BCE5077908a1b7370B9ae04AdC565EBd643966" },
"bondingCurveAddress": { "artifact": "BondingCurve", "address": "0xe1578B4a32Eaefcd563a9E6d0dc02a4213f673B7"},
"chainlinkDaiUsdOracleAddress": { "address": "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9"},
Expand All @@ -29,6 +33,7 @@
"chainlinkRaiEthOracleAddress": {"address": "0x4ad7B025127e89263242aB68F0f9c4E5C033B489"},
"chainlinkRaiEthOracleWrapperAddress": { "artifact": "ChainlinkOracleWrapper", "address": "0x3d49573ee6aFCBDe606F8a1c2AA1C498048E7190"},
"chainlinkRaiUsdCompositOracleAddress": { "artifact": "CompositeOracle", "address": "0x392b1d29eDab680c5CA778D3A32b8284859BFBB0"},
"chainlinkTribeEthOracleAddress": {"address": "0x84a24deCA415Acc0c395872a9e6a63E27D6225c8"},
"communalFarmAddress" : { "address": "0x0639076265e9f88542C91DCdEda65127974A5CA5"},
"compositeOracleAddress": { "artifact": "CompositeOracle", "address": "0x8721f9EAba0B9081069970bCBce38763D3D4f28E"},
"compoundDaiAddress" : { "address" : "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643"},
Expand All @@ -39,6 +44,9 @@
"coreAddress": { "artifact": "Core", "address": "0x8d5ED43dCa8C2F7dFB20CF7b53CC7E593635d7b9" },
"creamFeiAddress" : { "artifact" : "CErc20Delegator", "address": "0x8C3B7a4320ba70f8239F83770c4015B5bc4e6F91" },
"creamFeiPCVDepositAddress" : { "artifact" : "ERC20CompoundPCVDeposit", "address": "0x243C601CC5DaA3Ac250B14509804188347bd2aFB" },
"curve3crvAddress": { "artifact": "IStableSwap3", "address": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490"},
"curve3poolAddress": { "artifact": "IStableSwap3", "address": "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"},
"curveMetapoolAddress": { "artifact": "IStableSwap2", "address": "0x06cb22615ba53e60d67bf6c341a0fd5e718e1655"},
"curve3MetapoolAddress": {"artifact" : "IERC20", "address": "0x06cb22615BA53E60D67Bf6C341a0fD5E718E1655" },
"daiAddress" : {"artifact" : "IERC20", "address" : "0x6B175474E89094C44Da98b954EedeAC495271d0F"},
"daiBondingCurveAddress": { "artifact": "BondingCurve", "address": "0xC0afe0E649e32528666F993ce63822c3840e941a"},
Expand Down Expand Up @@ -76,6 +84,12 @@
"proxyAdminAddress" : { "artifact" : "ProxyAdmin", "address": "0xf8c2b645988b7658E7748BA637fE25bdD46A704A"},
"raiAddress": {"artifact" : "IERC20", "address" : "0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919"},
"raiBondingCurveAddress": { "artifact": "BondingCurve", "address": "0x25d60212D47Dd8F6Ff0469367E4c6C98Cd3411A5"},
"rariPool19DpiAddress": { "artifact" : "CErc20Delegator", "address": "0xf06f65a6b7d2c401fcb8b3273d036d21fe2a5963"},
"rariPool19DpiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0x3dD3d945C4253bAc5B4Cc326a001B7d3f9C4DD66"},
"rariPool18FeiAddress": { "artifact" : "CErc20Delegator", "address": "0x17b1A2E012cC4C31f83B90FF11d3942857664efc"},
"rariPool18FeiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0x5A8CB4556e5D5935Af06beab8292905f48131479"},
"rariPool19FeiAddress": { "artifact" : "CErc20Delegator", "address": "0x04281F6715Dea6A8EbBCE143D86ea506FF326531"},
"rariPool19FeiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0xD6960adba53212bBE96E54a7AFeDA2066437D000"},
"rariPool24FeiAddress": { "artifact" : "CErc20Delegator", "address": "0xb5A817E5354736eafe3A0C85620433eE75daA649"},
"rariPool24FeiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0x1434F99EDB2bD03DECCCFe21288767b8324B7403"},
"rariPool25FeiAddress": { "artifact" : "CErc20Delegator", "address": "0xE468D0244D75b9b18B27cb682AeC3ab35d33663B"},
Expand All @@ -100,6 +114,8 @@
"rariPool8TribeIrmAddress": {"address": "0x075538650a9c69ac8019507a7dd1bd879b12c1d7" },
"rariPool9FeiAddress": { "artifact" : "CErc20Delegator", "address": "0x11A9F6ae6B36B4b820777D05B90Cd6CCCB1CDa31"},
"rariPool9FeiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0xF2D8beE45f29A779cFB9F04ac233E703974a2C53"},
"rariPool9RaiAddress": { "artifact" : "CErc20Delegator", "address": "0x752F119bD4Ee2342CE35E2351648d21962c7CAfE"},
"rariPool9RaiPCVDepositAddress": { "artifact" : "ERC20CompoundPCVDeposit", "address": "0x9aAdFfe00eAe6d8e59bB4F7787C6b99388A6960D"},
"ratioPCVControllerAddress": { "artifact": "RatioPCVController", "address": "0xfC1aD6eb84351597cD3b9B65179633697d65B920"},
"reflexerStableAssetFusePoolRaiAddress" : {"artifact" : "CErc20Delegator", "address" : "0x752F119bD4Ee2342CE35E2351648d21962c7CAfE"},
"reflexerStableAssetFusePoolRaiPCVDepositAddress" : { "artifact" : "ERC20CompoundPCVDeposit", "address" : "0x9aAdFfe00eAe6d8e59bB4F7787C6b99388A6960D" },
Expand Down
6 changes: 3 additions & 3 deletions contract-addresses/permissions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"minter": [
"bondingCurveAddress",
"uniswapPCVDepositAddress",
"uniswapPCVControllerAddress",
"timelockAddress",
"dpiBondingCurveAddress",
"daiBondingCurveAddress",
"dpiUniswapPCVDepositAddress",
"raiBondingCurveAddress"
"raiBondingCurveAddress",
"pcvEquityMinterAddress",
"collateralizationOracleKeeperAddress"
],
"burner": [
"ethReserveStabilizerAddress",
"uniswapPCVControllerAddress",
"tribeReserveStabilizerAddress"
],
"governor": [
Expand Down
15 changes: 15 additions & 0 deletions contracts/Constants.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";

library Constants {
/// @notice the denominator for basis points granularity (10,000)
uint256 public constant BASIS_POINTS_GRANULARITY = 10_000;

/// @notice WETH9 address
IWETH public constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

/// @notice USD stand-in address
address public constant USD = 0x1111111111111111111111111111111111111111;
}
37 changes: 18 additions & 19 deletions contracts/bondingcurve/BondingCurve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import "../pcv/utils/PCVSplitter.sol";
import "../utils/Incentivized.sol";
import "../pcv/IPCVDeposit.sol";
import "../utils/Timed.sol";
import "../Constants.sol";

/**
* @title a bonding curve for purchasing FEI with ERC-20 tokens
* @author Fei Protocol
*
*/
contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivized {
contract BondingCurve is IPCVDepositBalances, IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivized {
using Decimal for Decimal.D256;

/// @notice the Scale target at which bonding curve price fixes
Expand All @@ -35,8 +36,6 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
/// @notice the cap on how much FEI can be minted by the bonding curve
uint256 public override mintCap;

uint256 public constant BASIS_POINTS_GRANULARITY = 10_000;

/// @notice constructor
/// @param _core Fei Core to reference
/// @param _oracle the price oracle to reference
Expand Down Expand Up @@ -107,6 +106,16 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
return token.balanceOf(address(this));
}

/// @notice display the related token of the balance reported
function balanceReportedIn() public view override returns (address) {
return address(token);
}

/// @notice returns a manipulation resistant account of both the balance of underlying and protocol owned FEI
function resistantBalanceAndFei() public view override returns(uint256, uint256) {
return (balance(), 0);
}

/// @notice sets the bonding curve Scale target
function setScale(uint256 newScale) external override onlyGovernorOrAdmin {
_setScale(newScale);
Expand All @@ -122,7 +131,7 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
/// @notice sets the bonding curve price buffer
function setBuffer(uint256 newBuffer) external override onlyGovernorOrAdmin {
require(
newBuffer < BASIS_POINTS_GRANULARITY,
newBuffer < Constants.BASIS_POINTS_GRANULARITY,
"BondingCurve: Buffer exceeds or matches granularity"
);
uint256 oldBuffer = buffer;
Expand All @@ -133,7 +142,7 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
/// @notice sets the bonding curve price discount
function setDiscount(uint256 newDiscount) external override onlyGovernorOrAdmin {
require(
newDiscount < BASIS_POINTS_GRANULARITY,
newDiscount < Constants.BASIS_POINTS_GRANULARITY,
"BondingCurve: Buffer exceeds or matches granularity"
);
uint256 oldDiscount = discount;
Expand All @@ -151,20 +160,12 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
_setMintCap(_mintCap);
}

/// @notice sets the allocation of incoming PCV
function setAllocation(
address[] calldata allocations,
uint256[] calldata ratios
) external override onlyGovernor {
_setAllocation(allocations, ratios);
}

/// @notice batch allocate held PCV
function allocate() external override whenNotPaused {
uint256 amount = balance();
uint256 usdValueHeld = readOracle().mul(amount).asUint256();
// the premium is the USD value held multiplied by the buffer that a user would pay to get FEI assuming FEI is $1
uint256 premium = usdValueHeld * buffer / BASIS_POINTS_GRANULARITY;
uint256 premium = usdValueHeld * buffer / Constants.BASIS_POINTS_GRANULARITY;

// this requirement mitigates gaming the allocate function and ensures it is only called when sufficient demand has been met
require(premium >= incentiveAmount, "BondingCurve: Not enough PCV held");
Expand All @@ -176,8 +177,6 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
_initTimed(); // reset window
_incentivize();
}

emit Allocate(msg.sender, amount);
}

/// @notice a boolean signalling whether Scale has been reached
Expand Down Expand Up @@ -246,7 +245,7 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
require(availableToMint() >= amountOut, "BondingCurve: exceeds mint cap");

_incrementTotalPurchased(amountOut);
fei().mint(to, amountOut);
_mintFei(to, amountOut);

emit Purchase(to, amountIn, amountOut);

Expand Down Expand Up @@ -281,14 +280,14 @@ contract BondingCurve is IBondingCurve, OracleRef, PCVSplitter, Timed, Incentivi
virtual
returns (Decimal.D256 memory)
{
uint256 granularity = BASIS_POINTS_GRANULARITY;
uint256 granularity = Constants.BASIS_POINTS_GRANULARITY;
// uses 1/1-b because the oracle price is inverted
return Decimal.ratio(granularity, granularity - discount);
}

/// @notice returns the buffer on the post-scale bonding curve price
function _getBufferMultiplier() internal view returns (Decimal.D256 memory) {
uint256 granularity = BASIS_POINTS_GRANULARITY;
uint256 granularity = Constants.BASIS_POINTS_GRANULARITY;
// uses 1/1+b because the oracle price is inverted
return Decimal.ratio(granularity, granularity + buffer);
}
Expand Down
3 changes: 2 additions & 1 deletion contracts/bondingcurve/EthBondingCurve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.4;

import "./BondingCurve.sol";
import "../Constants.sol";

/// @title a bonding curve for purchasing FEI with ETH
/// @author Fei Protocol
Expand Down Expand Up @@ -32,7 +33,7 @@ contract EthBondingCurve is BondingCurve {
params.ratios,
params.duration,
params.incentive,
IERC20(address(0)),
IERC20(address(Constants.WETH)),
params.discount,
params.buffer
)
Expand Down
9 changes: 0 additions & 9 deletions contracts/bondingcurve/IBondingCurve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ interface IBondingCurve {

event Purchase(address indexed to, uint256 amountIn, uint256 amountOut);

event Allocate(address indexed caller, uint256 amount);

event Reset(uint256 oldTotalPurchased);

// ----------- State changing Api -----------
Expand All @@ -40,11 +38,6 @@ interface IBondingCurve {

function setScale(uint256 newScale) external;

function setAllocation(
address[] calldata pcvDeposits,
uint256[] calldata ratios
) external;

function setIncentiveFrequency(uint256 newFrequency) external;

function setMintCap(uint256 newMintCap) external;
Expand All @@ -68,8 +61,6 @@ interface IBondingCurve {

function totalPurchased() external view returns (uint256);

function balance() external view returns (uint256);

function token() external view returns (IERC20);

function mintCap() external view returns (uint256);
Expand Down
14 changes: 14 additions & 0 deletions contracts/external/ILiquidityBootstrappingPoolFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

interface ILiquidityBootstrappingPoolFactory {
function create(
string memory name,
string memory symbol,
address[] memory tokens,
uint256[] memory weights,
uint256 swapFeePercentage,
address owner,
bool swapEnabledOnStart
) external returns (address);
}
32 changes: 32 additions & 0 deletions contracts/keeper/CollateralizationOracleKeeper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pragma solidity ^0.8.0;

import "../token/FeiTimedMinter.sol";
import "../oracle/ICollateralizationOracleWrapper.sol";

/// @title CollateralizationOracleKeeper
/// @notice a FEI timed minter which only rewards when updating the collateralization oracle
contract CollateralizationOracleKeeper is FeiTimedMinter {

ICollateralizationOracleWrapper public collateralizationOracleWrapper;

/**
@notice constructor for CollateralizationOracleKeeper
@param _core the Core address to reference
@param _incentive the incentive amount for calling mint paid in FEI
@param _collateralizationOracleWrapper the collateralizationOracleWrapper to incentivize updates only
sets the target to this address and mint amount to 0, relying exclusively on the incentive payment to caller
*/
constructor(
address _core,
uint256 _incentive,
ICollateralizationOracleWrapper _collateralizationOracleWrapper
)
FeiTimedMinter(_core, address(this), _incentive, MIN_MINT_FREQUENCY, 0)
{
collateralizationOracleWrapper = _collateralizationOracleWrapper;
}

function _afterMint() internal override {
collateralizationOracleWrapper.updateIfOutdated();
}
}
33 changes: 33 additions & 0 deletions contracts/mock/MockCollateralizationOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;

import "./MockOracleCoreRef.sol";

contract MockCollateralizationOracle is MockOracleCoreRef {

uint256 public userCirculatingFei = 1e20;

uint256 public pcvValue = 5e20;

constructor(address core, uint256 exchangeRate)
MockOracleCoreRef(core, exchangeRate)
{
}

function set(uint _userCirculatingFei, uint _pcvValue) public {
userCirculatingFei = _userCirculatingFei;
pcvValue = _pcvValue;
}

function isOvercollateralized() public view returns (bool) {
return pcvEquityValue() > 0;
}

function pcvEquityValue() public view returns (int256) {
return int256(pcvValue) - int256(userCirculatingFei);
}

function pcvStats() public view returns(uint256, uint256, int256, bool) {
return (pcvValue, userCirculatingFei, pcvEquityValue(), valid);
}
}
Loading