Skip to content

Commit

Permalink
Make rewardToken mutable to prepare for governance (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenshively authored Sep 10, 2023
1 parent edc9874 commit 55edd89
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
30 changes: 15 additions & 15 deletions core/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
BorrowerGasTest:test_addMargin() (gas: 16203)
BorrowerGasTest:test_borrow() (gas: 110492)
BorrowerGasTest:test_borrow() (gas: 110489)
BorrowerGasTest:test_getUniswapPositions() (gas: 5219)
BorrowerGasTest:test_modify() (gas: 82111)
BorrowerGasTest:test_modifyWithAnte() (gas: 88566)
BorrowerGasTest:test_repay() (gas: 111851)
BorrowerGasTest:test_uniswapDepositInBorrower() (gas: 257726)
BorrowerGasTest:test_modify() (gas: 82108)
BorrowerGasTest:test_modifyWithAnte() (gas: 88563)
BorrowerGasTest:test_repay() (gas: 111848)
BorrowerGasTest:test_uniswapDepositInBorrower() (gas: 257723)
BorrowerGasTest:test_uniswapDepositStandard() (gas: 167558)
BorrowerGasTest:test_uniswapWithdraw() (gas: 147623)
BorrowerGasTest:test_withdraw() (gas: 105631)
FactoryGasTest:test_createBorrower() (gas: 156437)
FactoryGasTest:test_createMarket() (gas: 3900597)
BorrowerGasTest:test_uniswapWithdraw() (gas: 147620)
BorrowerGasTest:test_withdraw() (gas: 105628)
FactoryGasTest:test_createBorrower() (gas: 156431)
FactoryGasTest:test_createMarket() (gas: 3900591)
LenderGasTest:test_accrueInterest() (gas: 46287)
LenderGasTest:test_borrow() (gas: 40812)
LenderGasTest:test_deposit() (gas: 53639)
LenderGasTest:test_depositWithCourier() (gas: 53785)
LenderGasTest:test_redeem() (gas: 53334)
LenderGasTest:test_redeemWithCourier() (gas: 83730)
LenderGasTest:test_redeemWithCourier() (gas: 83726)
LenderGasTest:test_repay() (gas: 44752)
LiquidatorGasTest:test_noCallbackOneAsset() (gas: 51020)
LiquidatorGasTest:test_noCallbackTwoAssets() (gas: 59179)
LiquidatorGasTest:test_noCallbackTwoAssetsAndUniswapPosition() (gas: 95598)
LiquidatorGasTest:test_warn() (gas: 35026)
LiquidatorGasTest:test_withCallbackAndSwap() (gas: 130185)
LiquidatorGasTest:test_noCallbackOneAsset() (gas: 51017)
LiquidatorGasTest:test_noCallbackTwoAssets() (gas: 59176)
LiquidatorGasTest:test_noCallbackTwoAssetsAndUniswapPosition() (gas: 95596)
LiquidatorGasTest:test_warn() (gas: 35023)
LiquidatorGasTest:test_withCallbackAndSwap() (gas: 130182)
VolatilityGasTest:test_consult() (gas: 43075)
VolatilityGasTest:test_updateNoBinarySearch() (gas: 145910)
13 changes: 7 additions & 6 deletions core/.storage-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ forge inspect --pretty src/Borrower.sol:Borrower storage-layout
forge inspect --pretty src/Factory.sol:Factory storage-layout
| Name | Type | Slot | Offset | Bytes | Contract |
|---------------|---------------------------------------------------------------|------|--------|-------|-------------------------|
| getMarket | mapping(contract IUniswapV3Pool => struct Factory.Market) | 0 | 0 | 32 | src/Factory.sol:Factory |
| getParameters | mapping(contract IUniswapV3Pool => struct Factory.Parameters) | 1 | 0 | 32 | src/Factory.sol:Factory |
| isLender | mapping(address => bool) | 2 | 0 | 32 | src/Factory.sol:Factory |
| isBorrower | mapping(address => bool) | 3 | 0 | 32 | src/Factory.sol:Factory |
| couriers | mapping(uint32 => struct Factory.Courier) | 4 | 0 | 32 | src/Factory.sol:Factory |
| isCourier | mapping(address => bool) | 5 | 0 | 32 | src/Factory.sol:Factory |
| rewardsToken | contract ERC20 | 0 | 0 | 20 | src/Factory.sol:Factory |
| getMarket | mapping(contract IUniswapV3Pool => struct Factory.Market) | 1 | 0 | 32 | src/Factory.sol:Factory |
| getParameters | mapping(contract IUniswapV3Pool => struct Factory.Parameters) | 2 | 0 | 32 | src/Factory.sol:Factory |
| isLender | mapping(address => bool) | 3 | 0 | 32 | src/Factory.sol:Factory |
| isBorrower | mapping(address => bool) | 4 | 0 | 32 | src/Factory.sol:Factory |
| couriers | mapping(uint32 => struct Factory.Courier) | 5 | 0 | 32 | src/Factory.sol:Factory |
| isCourier | mapping(address => bool) | 6 | 0 | 32 | src/Factory.sol:Factory |

12 changes: 6 additions & 6 deletions core/src/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ contract Factory {

IRateModel public immutable RATE_MODEL;

ERC20 public immutable REWARDS_TOKEN;

address public immutable LENDER_IMPLEMENTATION;

ERC20 public rewardsToken;

/*//////////////////////////////////////////////////////////////
WORLD STORAGE
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -80,12 +80,12 @@ contract Factory {
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/

constructor(VolatilityOracle oracle, IRateModel rateModel, ERC20 rewardsToken) {
constructor(VolatilityOracle oracle, IRateModel rateModel, ERC20 rewardsToken_) {
ORACLE = oracle;
RATE_MODEL = rateModel;
REWARDS_TOKEN = rewardsToken;

LENDER_IMPLEMENTATION = address(new Lender(address(this)));

rewardsToken = rewardsToken_;
}

function pause(IUniswapV3Pool pool) external {
Expand Down Expand Up @@ -178,6 +178,6 @@ contract Factory {
}
}

REWARDS_TOKEN.safeTransfer(beneficiary, earned);
rewardsToken.safeTransfer(beneficiary, earned);
}
}
2 changes: 1 addition & 1 deletion core/src/Ledger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ contract Ledger {
* @return The maximum amount of `asset()` that can be withdrawn
*/
function maxWithdraw(address owner) external view returns (uint256) {
return convertToAssets(this.maxRedeem(owner));
return convertToAssets(maxRedeem(owner));
}

/*//////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion core/src/libraries/constants/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ uint256 constant MAX_RATE = 706354;

/// @dev The default amount of Ether required to take on debt in a `Borrower`. The `Factory` can override this value
/// on a per-market basis.
uint216 constant DEFAULT_ANTE = 0.1 ether;
uint216 constant DEFAULT_ANTE = 0.01 ether;

/// @dev The default number of standard deviations of price movement used to determine probe prices for `Borrower`
/// solvency. The `Factory` can override this value on a per-market basis.
Expand Down

0 comments on commit 55edd89

Please sign in to comment.