Skip to content

Commit

Permalink
feat(market): emit Update event on every action
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurka-o committed May 16, 2024
1 parent 2996e66 commit a5c6f39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions contracts/OverlayV1Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ contract OverlayV1Market is IOverlayV1Market, Pausable {

/// @param oiLong oiLong after public update
/// @param oiShort oiShort after public update
event PublicUpdate(uint256 oiLong, uint256 oiShort);
event Update(uint256 oiLong, uint256 oiShort);

constructor() {
(address _ov, address _feed, address _factory) =
Expand Down Expand Up @@ -517,10 +517,9 @@ contract OverlayV1Market is IOverlayV1Market, Pausable {
/// @dev update is called every time market is interacted with
function update() external returns (Oracle.Data memory data) {
data = _update();
emit PublicUpdate(oiLong, oiShort);
}

function _update() private whenNotPaused returns (Oracle.Data memory) {
function _update() internal whenNotPaused returns (Oracle.Data memory) {
// pay funding for time elasped since last interaction w market
_payFunding();

Expand All @@ -533,6 +532,7 @@ contract OverlayV1Market is IOverlayV1Market, Pausable {
Oracle.Data memory data = IOverlayV1Feed(feed).latest();
require(dataIsValid(data), "OVV1:!data");

emit Update(oiLong, oiShort);
// return the latest data from feed
return data;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/OverlayV1Market.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ contract MarketTest is Test {
assertEq(ov.balanceOf(address(market)), 0);
}

event PublicUpdate(uint256 oiLong, uint256 oiShort);
event Update(uint256 oiLong, uint256 oiShort);

function testUpdate() public {
function testUpdateEventEmitting() public {
vm.startPrank(USER);

ov.approve(address(market), type(uint256).max);
Expand All @@ -193,7 +193,7 @@ contract MarketTest is Test {
uint256 newoiShort = isLongOverweight ? oiUnderweight : oiOverweight;

vm.expectEmit(false, false, false, true);
emit PublicUpdate(newoiLong, newoiShort);
emit Update(newoiLong, newoiShort);
market.update();

vm.stopPrank();
Expand Down

0 comments on commit a5c6f39

Please sign in to comment.