Skip to content

Commit 01a9610

Browse files
authored
Update market oracle signature (#8)
* Bumping dep versions, fixing lint warnings * update oracle name * removing intellij files * volume type
1 parent 0e7e8d7 commit 01a9610

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
"deployer", "http", "https", "github", "chai", "argv", "evm",
3737
"jsonrpc", "timestamp", "uint256", "erc20", "bignumber", "lodash",
3838
"arg", "npm", "seedrandom", "eql", "sinon", "yaml", "promisify",
39-
"passcode", "geth", "rpc", "rpcmsg","stdev", "stochasm", "aggregator",
39+
"passcode", "geth", "rpc", "rpcmsg","stdev", "stochasm",
4040
"whitelist", "uint",
4141

4242
// shorthand

contracts/UFragmentsPolicy.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
66
import "./UFragments.sol";
77

88

9-
interface ExchangeRateAggregator {
10-
function aggregate() external returns (uint128, uint256);
9+
interface MarketOracle {
10+
function getPriceAndVolume() external returns (uint128, uint128);
1111
}
1212

1313

1414
/**
1515
* @title uFragments Monetary Supply Policy
1616
* @notice This component regulates the token supply of the uFragments ERC20 token in response to
17-
* price-feed oracles.
17+
* market oracles.
1818
*/
1919
contract UFragmentsPolicy is Ownable {
2020
using SafeMath for uint256;
2121

22-
event Rebase(uint256 indexed epoch, uint128 exchangeRate, uint256 volume, int256 appliedSupplyAdjustment);
22+
event Rebase(uint256 indexed epoch, uint128 exchangeRate, uint128 volume, int256 appliedSupplyAdjustment);
2323

2424
UFragments private uFrags;
25-
ExchangeRateAggregator private rateAggregator;
25+
MarketOracle private marketOracle;
2626

2727
// Timestamp of last rebase operation
2828
uint256 public lastRebaseTimestamp;
@@ -47,9 +47,9 @@ contract UFragmentsPolicy is Ownable {
4747
// The upper bound on uFragments' supply
4848
uint256 private constant MAX_SUPPLY = 2**128 - 1;
4949

50-
constructor(UFragments _uFrags, ExchangeRateAggregator _rateAggregator) public {
50+
constructor(UFragments _uFrags, MarketOracle _marketOracle) public {
5151
uFrags = _uFrags;
52-
rateAggregator = _rateAggregator;
52+
marketOracle = _marketOracle;
5353
}
5454

5555
/**
@@ -62,8 +62,8 @@ contract UFragmentsPolicy is Ownable {
6262
lastRebaseTimestamp = now;
6363

6464
uint128 exchangeRate;
65-
uint256 volume;
66-
(exchangeRate, volume) = rateAggregator.aggregate();
65+
uint128 volume;
66+
(exchangeRate, volume) = marketOracle.getPriceAndVolume();
6767
int256 supplyDelta = calcSupplyDelta(exchangeRate);
6868
supplyDelta = calcDampenedSupplyDelta(supplyDelta);
6969

@@ -76,8 +76,8 @@ contract UFragmentsPolicy is Ownable {
7676
}
7777

7878
/**
79-
* @notice Allows setting the Deviation Threshold. If the exchange rate given by the exchange
80-
* rate aggregator is within this threshold, then no supply modifications are made.
79+
* @notice Allows setting the Deviation Threshold. If the exchange rate given by the market
80+
* oracle is within this threshold, then no supply modifications are made.
8181
* @param _deviationThreshold The new exchange rate threshold.
8282
* TODO(iles): This should only be modified through distributed governance. #158010389
8383
*/
@@ -111,7 +111,7 @@ contract UFragmentsPolicy is Ownable {
111111

112112
/**
113113
* @return The total supply adjustment that should be made in response to the exchange
114-
* rate, as read from the aggregator.
114+
* rate, as provided by the market oracle.
115115
*/
116116
function calcSupplyDelta(uint128 rate) private view returns (int256) {
117117
if (withinDeviationThreshold(rate)) {

contracts/mocks/ProxyContract.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ contract ProxyContract {
88

99
uint256 private epoch;
1010
uint128 private exchangeRate;
11-
uint256 private volume;
11+
uint128 private volume;
1212
uint256 private supply;
1313

1414
event FunctionCalled(string functionName, address caller);
@@ -23,7 +23,7 @@ contract ProxyContract {
2323
exchangeRate = _exchangeRate;
2424
}
2525

26-
function storeVolume(uint256 _volume) public {
26+
function storeVolume(uint128 _volume) public {
2727
volume = _volume;
2828
}
2929

@@ -46,8 +46,8 @@ contract ProxyContract {
4646
emit FunctionArguments(uintVals, intVals);
4747
}
4848

49-
function aggregate() external returns (uint128, uint256) {
50-
emit FunctionCalled("ExchangeRateAggregator:aggregate", msg.sender);
49+
function getPriceAndVolume() external returns (uint128, uint128) {
50+
emit FunctionCalled("MarketOracle:getPriceAndVolume", msg.sender);
5151
uint256[] memory uintVals = new uint256[](0);
5252
int256[] memory intVals = new int256[](0);
5353
emit FunctionArguments(uintVals, intVals);

scripts/gen_dummy_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function mockData () {
4343
supply = await uFragments.totalSupply.call();
4444
supply = new BigNumber(supply);
4545

46-
// Mocking policy interactions with aggregator and uFragments
46+
// Mocking policy interactions with oracle and uFragments
4747
await proxy.storeRate(rate, txConfig);
4848
await proxy.storeSupply(supply, txConfig);
4949
await proxy.storeVolume(volume, txConfig);

test/logs/gas-utilization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Code generated - DO NOT EDIT.
22
# Any manual changes may be lost.
33
'UFragments:DEPLOYMENT': 1816916
4-
'UFragments:rebase(1, +100) [VIA PROXY]': 31446
4+
'UFragments:rebase(1, +100) [VIA PROXY]': 31468
55
'UFragments:transfer(user, 10)': 53799
66
'UFragments:transferFrom(user, 10)': 46151
7-
'UFragmentsPolicy:rebase() [WITH STUB]': 84417
7+
'UFragmentsPolicy:rebase() [WITH STUB]': 84439

test/unit/UFragmentsPolicy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ contract('uFragmentsPolicy', async accounts => {
121121
expect(log.args.appliedSupplyAdjustment.toNumber()).to.eq(20);
122122
expect(log.args.volume.toNumber()).to.eq(100);
123123
});
124-
it('should call aggregate from the exchange rate aggregator', async () => {
124+
it('should call getPriceAndVolume from the market oracle', async () => {
125125
const fnCalls = new ProxyContractFunctionSpy(uFragSpy).getCalledFunctions();
126-
expect(fnCalls[0].fnName).to.eq('ExchangeRateAggregator:aggregate');
126+
expect(fnCalls[0].fnName).to.eq('MarketOracle:getPriceAndVolume');
127127
expect(fnCalls[0].calledBy).to.eq(uFragmentsPolicy.address);
128128
expect(fnCalls[0].arguments).to.be.empty;
129129
});

0 commit comments

Comments
 (0)