diff --git a/.gitmodules b/.gitmodules index 5c71a385d..d840a8275 100644 --- a/.gitmodules +++ b/.gitmodules @@ -46,3 +46,6 @@ path = packages/contracts/lib/aave-v3-periphery url = https://github.com/aave/aave-v3-periphery branch= master +[submodule "packages/contracts/lib/v3-periphery"] + path = packages/contracts/lib/v3-periphery + url = https://github.com/Uniswap/v3-periphery diff --git a/packages/contracts/lib/v3-periphery b/packages/contracts/lib/v3-periphery new file mode 160000 index 000000000..068238719 --- /dev/null +++ b/packages/contracts/lib/v3-periphery @@ -0,0 +1 @@ +Subproject commit 0682387198a24c7cd63566a2c58398533860a5d1 diff --git a/packages/contracts/src/traps/ProtocolTrap.sol b/packages/contracts/src/traps/ProtocolTrap.sol index 895f0568b..0c965c175 100644 --- a/packages/contracts/src/traps/ProtocolTrap.sol +++ b/packages/contracts/src/traps/ProtocolTrap.sol @@ -6,12 +6,30 @@ contract ProtocolTrap { } function collect() external view returns (bytes memory) { - return abi.encode(CollectOutput({triggerResponse: true})); // Logic to be modified + uint256 randomNumber = randomize(); + return + abi.encode(CollectOutput({triggerResponse: randomNumber % 2 == 0})); // Logic to be modified according to requirements } function shouldRespond( bytes[] calldata data ) external pure returns (bool, bytes memory) { - return (true, bytes("")); + CollectOutput memory collectOutput = abi.decode( + data[0], + (CollectOutput) + ); + return (collectOutput.triggerResponse, bytes("")); + } + + function randomize() private view returns (uint256 result) { + result = uint256( + keccak256( + abi.encodePacked( + tx.origin, + blockhash(block.number - 1), + block.timestamp + ) + ) + ); } }