Skip to content

Commit

Permalink
chore: update trap
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsley-einstein committed Dec 21, 2024
1 parent eeae3d6 commit 8a4ad50
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions packages/contracts/lib/v3-periphery
Submodule v3-periphery added at 068238
22 changes: 20 additions & 2 deletions packages/contracts/src/traps/ProtocolTrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
);
}
}

0 comments on commit 8a4ad50

Please sign in to comment.