Skip to content

Commit

Permalink
Merge pull request #16 from The-Poolz/issue-15
Browse files Browse the repository at this point in the history
RefundTimeOverride
  • Loading branch information
YouStillAlive authored Dec 12, 2024
2 parents 42f211d + 54abfd3 commit 460d120
Show file tree
Hide file tree
Showing 12 changed files with 3,262 additions and 2,245 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ truffle dashboard
```

```console
npx hardhat run ./scripts/deploy.ts --network truffleDashboard
npx hardhat run ./scripts/deployRefundTime.ts --network truffleDashboard
```
61 changes: 61 additions & 0 deletions contracts/RefundTimeOverride.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

/// This policy outlines the procedures for addressing issues detailed in the following document:
/// https://docs.google.com/document/d/1uhbRpDJbSKRSrwvVm-DJNTHlqsEaAG6tUbPAxh400xI

import "@poolzfinance/poolz-helper-v2/contracts/interfaces/ILockDealNFT.sol";
import "@ironblocks/firewall-policy/contracts/FirewallPolicyBase.sol";

contract RefundTimeOverride is FirewallPolicyBase {
uint256 public immutable validTimeStamp;
uint256 public immutable collateralPoolId;

bytes4 public constant REFUND_SELECTOR = bytes4(keccak256("handleRefund(uint256,address,uint256)"));

error InvalidTime();
error ZeroPoolId();

constructor(
uint256 _validTimeStamp,
uint256 _collateralPoolId
) {
if (_collateralPoolId == 0) revert ZeroPoolId();
validTimeStamp = _validTimeStamp;
collateralPoolId = _collateralPoolId;
}

function preExecution(
address,
address,
bytes memory data,
uint
) external view override {
bytes4 functionSelector;
assembly {
functionSelector := mload(add(data, 0x20))
}
if (functionSelector == REFUND_SELECTOR) {
uint256 poolId;
assembly {
poolId := mload(add(data, 0x24))
}
_check(poolId);
}
}

function postExecution(
address,
address,
bytes calldata,
uint
) external override {
// do nothing
}

function _check(uint256 poolId) private view {
if (poolId == collateralPoolId && block.timestamp > validTimeStamp) {
revert InvalidTime();
}
}
}
4 changes: 4 additions & 0 deletions contracts/mock/CollateralProvider.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@poolzfinance/collateral-provider/contracts/CollateralProvider.sol";
4 changes: 4 additions & 0 deletions contracts/mock/RefundProvider.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@poolzfinance/refund-provider/contracts/RefundProvider.sol";
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 200,
},
viaIR: true,
},
},
],
Expand Down
Loading

0 comments on commit 460d120

Please sign in to comment.