diff --git a/src/interfaces/ISablier.sol b/src/interfaces/ISablier.sol index 36f75e7..900f99d 100644 --- a/src/interfaces/ISablier.sol +++ b/src/interfaces/ISablier.sol @@ -2,8 +2,21 @@ pragma solidity ^0.8.19; +struct SablierStream { + address sender; + address recipient; + uint256 deposit; + address token; + uint256 startTime; + uint256 stopTime; + uint256 remainingBalance; + uint256 ratePerSecond; +} + interface ISablier { function createStream(address recipent, uint256 deposit, address tokenAddress, uint256 startTime, uint256 stopTime) external returns (uint256); + + function getStream(uint256 streamId) external view returns (SablierStream memory); } diff --git a/test/RemunerationProposal.t.sol b/test/RemunerationProposal.t.sol index 07f4e93..0da4824 100644 --- a/test/RemunerationProposal.t.sol +++ b/test/RemunerationProposal.t.sol @@ -2,11 +2,13 @@ pragma solidity ^0.8.19; import { IENSResolver } from "@interfaces/IENSResolver.sol"; +import { ISablier, SablierStream } from "@interfaces/ISablier.sol"; import { ProposalUtils } from "./utils/ProposalUtils.sol"; import { RemunerationProposal } from "@root/RemunerationProposal.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { console2 } from "@forge-std/console2.sol"; +import { Vm } from "@forge-std/Vm.sol"; contract TestRemunerationProposal is ProposalUtils { modifier executeCurrentProposalBefore() { @@ -63,4 +65,28 @@ contract TestRemunerationProposal is ProposalUtils { "Developer didn't get reimbursement" ); } + + function testSablierStreamOpenedCorrectly() public { + uint256 remunerationAmountInTORN = 8625 ether; + address sablierAddress = 0xCD18eAa163733Da39c232722cBC4E8940b1D8888; + + vm.recordLogs(); + createAndExecuteProposal(); + Vm.Log[] memory logs = vm.getRecordedLogs(); + + Vm.Log memory sablierCreateStreamLog; + + for (uint16 i = 0; i < logs.length; i++) { + if (logs[i].emitter == sablierAddress) sablierCreateStreamLog = logs[i]; + } + + uint256 sablierStreamId = uint256(sablierCreateStreamLog.topics[1]); + + SablierStream memory openedStream = ISablier(sablierAddress).getStream(sablierStreamId); + + require(openedStream.deposit + 1 ether > remunerationAmountInTORN, "Developer remuneration stream amount is insufficient"); + require(openedStream.deposit == openedStream.remainingBalance, "Stream started incorrectly"); + require(openedStream.stopTime < block.timestamp + 91 days, "Stream duration is more than quarter"); + require(openedStream.recipient == resolveDeveloperAddress(), "Stream recipient isn't developer"); + } } diff --git a/test/utils/Mock.sol b/test/utils/Mock.sol index f3d0c00..e8b285d 100644 --- a/test/utils/Mock.sol +++ b/test/utils/Mock.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.19; import { IGovernance } from "@interfaces/IGovernance.sol"; contract Mock { - // Developer address with 22 staked TORN + // Developer address with staked TORN address public constant TEST_REAL_ADDRESS_WITH_BALANCE = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58; address public constant TEST_RELAYER_ADDRESS = 0x30F96AEF199B399B722F8819c9b0723016CEAe6C; // moon-relayer.eth (just for testing)