Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgonecrypto committed Nov 3, 2021
1 parent 356ee16 commit 501d16a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 63 deletions.
12 changes: 0 additions & 12 deletions contracts/Exchanger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,6 @@ contract Exchanger is Owned, MixinSystemSettings, IExchanger {
systemStatus().suspendSynth(currencyKey, CIRCUIT_BREAKER_SUSPENSION_REASON);
}

// SIP-78
function setLastExchangeRateForSynth(bytes32 currencyKey, uint rate) external onlyExchangeRates {
require(rate > 0, "Rate must be above 0");
lastExchangeRate[currencyKey] = rate;
}

// SIP-139
function resetLastExchangeRate(bytes32[] calldata currencyKeys) external onlyOwner {
(uint[] memory rates, bool anyRateInvalid) = exchangeRates().ratesAndInvalidForCurrencies(currencyKeys);
Expand Down Expand Up @@ -869,12 +863,6 @@ contract Exchanger is Owned, MixinSystemSettings, IExchanger {
_;
}

modifier onlyExchangeRates() {
IExchangeRates _exchangeRates = exchangeRates();
require(msg.sender == address(_exchangeRates), "Restricted to ExchangeRates");
_;
}

// ========== EVENTS ==========
event ExchangeEntryAppended(
address indexed account,
Expand Down
4 changes: 2 additions & 2 deletions contracts/PurgeableSynth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ contract PurgeableSynth is Synth {

uint maxSupplyToPurge = exRates.effectiveValue("sUSD", maxSupplyToPurgeInUSD, currencyKey);

// Only allow purge when total supply is lte the max or the rate is frozen in ExchangeRates
require(totalSupply <= maxSupplyToPurge, "Cannot purge as total supply is above threshold and rate is not frozen.");
// Only allow purge when total supply is lte the max
require(totalSupply <= maxSupplyToPurge, "Cannot purge as total supply is above threshol.");

for (uint i = 0; i < addresses.length; i++) {
address holder = addresses[i];
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IExchanger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ interface IExchanger {
uint numEntries
);

function setLastExchangeRateForSynth(bytes32 currencyKey, uint rate) external;

function resetLastExchangeRate(bytes32[] calldata currencyKeys) external;

function suspendSynthWithInvalidRate(bytes32 currencyKey) external;
Expand Down
40 changes: 0 additions & 40 deletions test/contracts/Exchanger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2498,42 +2498,6 @@ contract('Exchanger (spec tests)', async accounts => {
});
};

const itSetsLastExchangeRateForSynth = () => {
describe('setLastExchangeRateForSynth() SIP-78', () => {
it('cannot be invoked by any user', async () => {
await onlyGivenAddressCanInvoke({
fnc: exchanger.setLastExchangeRateForSynth,
args: [sEUR, toUnit('100')],
accounts,
reason: 'Restricted to ExchangeRates',
});
});

describe('when ExchangeRates is spoofed using an account', () => {
beforeEach(async () => {
await resolver.importAddresses([toBytes32('ExchangeRates')], [account1], {
from: owner,
});
await exchanger.rebuildCache();
});
it('reverts when invoked by ExchangeRates with a 0 rate', async () => {
await assert.revert(
exchanger.setLastExchangeRateForSynth(sEUR, '0', { from: account1 }),
'Rate must be above 0'
);
});
describe('when invoked with a real rate by ExchangeRates', () => {
beforeEach(async () => {
await exchanger.setLastExchangeRateForSynth(sEUR, toUnit('1.9'), { from: account1 });
});
it('then lastExchangeRate is set for the synth', async () => {
assert.bnEqual(await exchanger.lastExchangeRate(sEUR), toUnit('1.9'));
});
});
});
});
};

const itPricesSpikeDeviation = () => {
describe('priceSpikeDeviation', () => {
const baseRate = 100;
Expand Down Expand Up @@ -3386,8 +3350,6 @@ contract('Exchanger (spec tests)', async accounts => {

itExchangesWithVirtual();

itSetsLastExchangeRateForSynth();

itPricesSpikeDeviation();

itSetsExchangeFeeRateForSynths();
Expand Down Expand Up @@ -3484,8 +3446,6 @@ contract('Exchanger (spec tests)', async accounts => {

itExchanges();

itSetsLastExchangeRateForSynth();

itPricesSpikeDeviation();

itSetsExchangeFeeRateForSynths();
Expand Down
8 changes: 1 addition & 7 deletions test/contracts/ExchangerWithVirtualSynth.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ contract('ExchangerWithVirtualSynth (unit tests)', async accounts => {
ensureOnlyExpectedMutativeFunctions({
abi: ExchangerWithVirtualSynth.abi,
ignoreParents: ['Owned', 'MixinResolver'],
expected: [
'exchange',
'resetLastExchangeRate',
'settle',
'suspendSynthWithInvalidRate',
'setLastExchangeRateForSynth',
],
expected: ['exchange', 'resetLastExchangeRate', 'settle', 'suspendSynthWithInvalidRate'],
});
});

Expand Down

0 comments on commit 501d16a

Please sign in to comment.