Skip to content

Commit

Permalink
Consistent code across GrandaMento and Exchange in setSpread (#9459)
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze authored and martinvol committed May 13, 2022
1 parent 3cfceab commit 292c443
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/stability/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ contract Exchange is
spread = FixidityLib.wrap(newSpread);
require(
FixidityLib.lte(spread, FixidityLib.fixed1()),
"the value of spread must be less than or equal to 1"
"Spread must be less than or equal to 1"
);
emit SpreadSet(newSpread);
}
Expand Down
7 changes: 5 additions & 2 deletions packages/protocol/contracts/stability/GrandaMento.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract GrandaMento is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 0, 0);
return (1, 1, 0, 1);
}

/**
Expand Down Expand Up @@ -582,8 +582,11 @@ contract GrandaMento is
* @param newSpread The new value for the spread to be wrapped. Must be <= fixed 1.
*/
function setSpread(uint256 newSpread) public onlyOwner {
require(newSpread <= FixidityLib.fixed1().unwrap(), "Spread must be smaller than 1");
spread = FixidityLib.wrap(newSpread);
require(
FixidityLib.lte(spread, FixidityLib.fixed1()),
"Spread must be less than or equal to 1"
);
emit SpreadSet(newSpread);
}

Expand Down
9 changes: 5 additions & 4 deletions packages/protocol/test/stability/grandamento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
assertEqualBN,
assertEqualBNArray,
assertLogMatches2,
assertRevert,
assertRevertWithReason,
timeTravel,
} from '@celo/protocol/lib/test-utils'
Expand Down Expand Up @@ -1085,10 +1086,10 @@ contract('GrandaMento', (accounts: string[]) => {
})
})

it('reverts when the spread is greater than 1', async () => {
await assertRevertWithReason(
grandaMento.setSpread(toFixed(1.0001)),
'Spread must be smaller than 1'
it('reverts when the spread is more than 1', async () => {
await assertRevert(
grandaMento.setSpread(toFixed(1001 / 1000)),
'Spread must be less than or equal to 1'
)
})

Expand Down

0 comments on commit 292c443

Please sign in to comment.