Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ node_modules/
artifacts/
cache_hardhat/
typechain-types/

*settings.json

29 changes: 17 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/rari-capital/solmate
path = lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "lib/create3-factory"]
path = lib/create3-factory
url = https://github.com/zeframlou/create3-factory
path = lib/create3-factory
url = https://github.com/zeframlou/create3-factory
[submodule "lib/v3-core"]
path = lib/v3-core
url = https://github.com/uniswap/v3-core
path = lib/v3-core
url = https://github.com/uniswap/v3-core
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
branch = v4.9.6
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
branch = v4.9.6
[submodule "lib/vault-v2"]
path = lib/vault-v2
url = https://github.com/Byte-Masons/vault-v2
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,36 @@ forge build

```
forge test
```
```

### Checklist

#### Internal Audit Checklist

- [x] All functionality that touches funds can be paused
- [ ] Pause function called by 2/7 Guardian
- [ ] Guardian has 7 members globally dispersed
- [x] Arithmetic errors
- [x] Re-entrancy
- [x] Flashloans
- [x] Access Control
- [x] Unchecked External Calls
- [ ] Account abstraction/multicall issues
- [x] USE SLITHER

#### Pre-deployment Checklist

- [x] Contracts pass all tests
- [x] Contracts deployed to testnet
- [x] Does this deployment have access to funds, either directly or indirectly (zappers, leveragers, etc.)?

Minimum security if Yes:

- [x] Internal Audit (not the author, minimum 1x Junior review + minimum 1x Senior review)
- [x] External Audit (impact scope)

Action items in support of deployment:

- [ ] Minimum two people present for deployment
- [ ] All developers who worked on and reviewed the contract should be included in the readme
- [ ] Documentation of deployment procedure if non-standard (i.e. if multiple scripts are necessary)
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[profile.default]
optimizer_runs = 1000000
verbosity = 1
via_ir = true
via_ir = false

[fmt]
line_length = 150
Expand Down
24 changes: 23 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { subtask } from "hardhat/config";

import { config as dotenvConfig } from "dotenv";

// import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-verify";

dotenvConfig();

const PRIVATE_KEY = process.env.PRIVATE_KEY || "";
Expand All @@ -20,6 +23,9 @@ const config: HardhatUserConfig = {
optimizer: { enabled: true, runs: 9999 }
}
},
sourcify: {
enabled: true
},
paths: {
sources: "./src",
tests: "./test_hardhat",
Expand All @@ -35,12 +41,28 @@ const config: HardhatUserConfig = {
chainId: 56,
accounts: [`0x${PRIVATE_KEY}`],
},
mode: {
url: "https://mainnet.mode.network/",
chainId: 34443,
accounts: [`0x${PRIVATE_KEY}`],
},
},
etherscan: {
apiKey: {
bsc: process.env.ETHERSCAN_KEY || "",
}
},
// customChains: [
// {
// network: "mode",
// chainId: 34443,
// urls: {
// apiURL: "https://explorer.mode.network",
// browserURL: "https://explorer.mode.network"
// }
// }
// ]
},

};

subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, hre, runSuper) => {
Expand Down
1 change: 1 addition & 0 deletions lib/vault-v2
Submodule vault-v2 added at 6cbaea
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ create3-factory/=lib/create3-factory/src/
v3-core/=lib/v3-core/contracts/
oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
oz/=lib/openzeppelin-contracts/contracts/
vault/=lib/vault-v2/src

20 changes: 18 additions & 2 deletions src/OptionsToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.13;
import {OwnableUpgradeable} from "oz-upgradeable/access/OwnableUpgradeable.sol";
import {ERC20Upgradeable} from "oz-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import {UUPSUpgradeable} from "oz-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import {PausableUpgradeable} from "oz-upgradeable/security/PausableUpgradeable.sol";
import {IOptionsToken} from "./interfaces/IOptionsToken.sol";
import {IOracle} from "./interfaces/IOracle.sol";
import {IExercise} from "./interfaces/IExercise.sol";
Expand All @@ -13,7 +13,7 @@ import {IExercise} from "./interfaces/IExercise.sol";
/// @author Eidolon & lookee
/// @notice Options token representing the right to perform an advantageous action,
/// such as purchasing the underlying token at a discount to the market price.
contract OptionsToken is IOptionsToken, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
contract OptionsToken is IOptionsToken, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable, PausableUpgradeable {
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -61,6 +61,7 @@ contract OptionsToken is IOptionsToken, ERC20Upgradeable, OwnableUpgradeable, UU
__UUPSUpgradeable_init();
__ERC20_init(name_, symbol_);
__Ownable_init();
__Pausable_init();
tokenAdmin = tokenAdmin_;

_clearUpgradeCooldown();
Expand Down Expand Up @@ -96,9 +97,14 @@ contract OptionsToken is IOptionsToken, ERC20Upgradeable, OwnableUpgradeable, UU
/// @param recipient The recipient of the reward
/// @param option The address of the Exercise contract with the redemption logic
/// @param params Extra parameters to be used by the exercise function
/// @return paymentAmount token amount paid for exercising
/// @return data0 address data to return by different exerciser contracts
/// @return data1 integer data to return by different exerciser contracts
/// @return data2 additional integer data to return by different exerciser contracts
function exercise(uint256 amount, address recipient, address option, bytes calldata params)
external
virtual
whenNotPaused
returns (
uint256 paymentAmount,
address,
Expand All @@ -121,6 +127,16 @@ contract OptionsToken is IOptionsToken, ERC20Upgradeable, OwnableUpgradeable, UU
emit SetExerciseContract(_address, _isExercise);
}

/// @notice Pauses functionality related to exercises of contracts.
function pause() external onlyOwner {
_pause();
}

/// @notice Unpauses functionality related to exercises of contracts.
function unpause() external onlyOwner {
_unpause();
}

/// -----------------------------------------------------------------------
/// Internal functions
/// -----------------------------------------------------------------------
Expand Down
Loading