From 78c5cb6ea2fb1cd8ee675a1cebcaf6332faaf99a Mon Sep 17 00:00:00 2001 From: traceurl <25892474+traceurl@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:10:14 +0800 Subject: [PATCH] add view function of heartbeat --- contracts/DODOV3MM/D3Pool/D3Maker.sol | 5 +++++ test/DODOV3MM/D3MM/D3Maker.t.sol | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/contracts/DODOV3MM/D3Pool/D3Maker.sol b/contracts/DODOV3MM/D3Pool/D3Maker.sol index 60e0b69..fb61136 100644 --- a/contracts/DODOV3MM/D3Pool/D3Maker.sol +++ b/contracts/DODOV3MM/D3Pool/D3Maker.sol @@ -130,6 +130,11 @@ contract D3Maker is InitializableOwnable { } } + function getHeartbeat() external view returns (uint256 lastHeartBeat, uint256 maxInterval) { + lastHeartBeat = state.heartBeat.lastHeartBeat; + maxInterval = state.heartBeat.maxInterval; + } + function getPoolTokenListFromMaker() external view returns(address[] memory tokenlist) { return poolTokenlist; } diff --git a/test/DODOV3MM/D3MM/D3Maker.t.sol b/test/DODOV3MM/D3MM/D3Maker.t.sol index efa0338..6346a98 100644 --- a/test/DODOV3MM/D3MM/D3Maker.t.sol +++ b/test/DODOV3MM/D3MM/D3Maker.t.sol @@ -95,6 +95,10 @@ contract MakerTest is TestContext { d3Maker.setNewToken( address(token1), true, token1Info.priceInfo, token1Info.amountInfo, token1Info.kAsk, token1Info.kBid ); + + (uint256 lastHeartBeat, uint256 maxInterval) = d3Maker.getHeartbeat(); + assertEq(lastHeartBeat, block.timestamp); + assertEq(maxInterval, 100000); } function testCallInvalidToken() public { @@ -432,6 +436,10 @@ contract MakerTest is TestContext { vm.prank(owner); d3Maker.setHeartbeat(300); + (uint256 lastHeartBeat, uint256 maxInterval) = d3Maker.getHeartbeat(); + assertEq(lastHeartBeat, block.timestamp); + assertEq(maxInterval, 300); + vm.warp(302); checkHB = d3Maker.checkHeartbeat(); assertEq(checkHB, false);