Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: version 3.1 #282

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
97a88db
feat: `BotListV3` improvements (#199)
lekhovitsky Apr 23, 2024
6bf5dc1
feat: `PriceOracleV3` improvements (#200)
lekhovitsky Apr 23, 2024
abdba47
feat: treat all non-underlying tokens as quoted (#202)
lekhovitsky May 4, 2024
db8a558
fix: simplify forbidden tokens logic (#204)
lekhovitsky May 5, 2024
5478414
feat: `RateKeeperV3` contract (#205)
lekhovitsky May 5, 2024
31fc139
feat: `CreditFacadeV3` improvements (#207)
lekhovitsky May 8, 2024
f255c5a
feat: configuration overhaul (#209)
lekhovitsky May 9, 2024
adec88d
feat: reorganize project
lekhovitsky May 9, 2024
50a6e58
Merge pull request #212 from Gearbox-protocol/reorganize-project
0xmikko May 9, 2024
320d30e
fix: i_contracts_register simplified
0xmikko May 10, 2024
44c7692
fix: i_contracts_register simplified
0xmikko May 10, 2024
fd2d55e
fix: i_contracts_register simplified
0xmikko May 10, 2024
72aad81
feat: small tweaks (#214)
0xmikko May 10, 2024
e3ff71e
feat: partial liquidations and minor improvements (#217)
lekhovitsky May 13, 2024
49e6ad9
fix: small changes (#219)
0xmikko May 13, 2024
72f3595
feat: make `GearStakingV3` ownable
lekhovitsky May 13, 2024
5bbf59f
fix: use `bytes32` instead of `string` in `IAddressProviderV3` in tests
lekhovitsky May 27, 2024
18dff5e
feat: fixes after Spearbit review (#245)
lekhovitsky Sep 1, 2024
dcf879b
feat: reorganize traits to remove redundant functions from contracts …
lekhovitsky Sep 1, 2024
603b94f
feat: reorganize interfaces, introduce `contractType` getter (#284)
lekhovitsky Sep 1, 2024
28d3790
feat: loss liquidator (#285)
lekhovitsky Sep 1, 2024
4c7d434
feat: phantom token withdrawals (#286)
lekhovitsky Sep 1, 2024
20ec014
feat: extend contract types (#287)
lekhovitsky Sep 11, 2024
1e7ca78
feat: simplify `TumblerV3`'s deployment (#289)
lekhovitsky Sep 13, 2024
12aa418
feat: fixes after secondary Spearbit review (#290)
lekhovitsky Sep 30, 2024
a60af54
feat: update solidity tests for v3.1 (#291)
Van0k Oct 2, 2024
357ece6
fix: replace Tokens enum with uint256 in tests
Van0k Nov 27, 2024
2512430
fix: test fix
Van0k Nov 27, 2024
352f950
fix: empty commit for CI
doomsower Nov 28, 2024
31d131e
build: avoid rate limit bug
doomsower Nov 28, 2024
50cdb4a
feat: remove `controller` role
lekhovitsky Dec 9, 2024
725c7f3
feat: `IACL` now provides `hasRole`
lekhovitsky Dec 9, 2024
60af9e7
feat: minor changes in `GaugeV3` and `TumblerV3`
lekhovitsky Dec 17, 2024
b8a2c07
feat: additional checks in `CreditConfiguratorV3`
lekhovitsky Dec 21, 2024
06d77c3
feat: switch from loss liquidators to loss policies
lekhovitsky Jan 5, 2025
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
7 changes: 0 additions & 7 deletions .env.fork

This file was deleted.

4 changes: 0 additions & 4 deletions .env.goerli

This file was deleted.

7 changes: 0 additions & 7 deletions .env.mainnet

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup node.js
uses: actions/setup-node@v3
with:
cache: "yarn"
node-version-file: ".nvmrc"

- name: Install dependencies
run: |
yarn install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -43,7 +33,3 @@ jobs:

- name: Run gas tests
run: forge test --mt test_G -vv

- name: Perform checks
run: |
yarn prettier:ci
36 changes: 15 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
.history/
.idea/
abi/
node_modules/
# Compiler files
cache/
build/
typechain/
artifacts/
coverage*
/out/
/node_modules/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
.verifier*
.DS_Store
/security/Peckshield.sol
/security/ClickerAttackSolution.sol
/security/TickerBombAttackSolution.sol
/.env.local
out/
forge-out/
.mainnet.test.cache

# Logs
*.log
.eslintcache
.eslint.local.json
.favorites.json
dist/
10 changes: 9 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.3.0
[submodule "lib/@gearbox-protocol/sdk-gov"]
path = lib/@gearbox-protocol/sdk-gov
url = https://github.com/Gearbox-protocol/sdk-gov
[submodule "lib/@1inch/solidity-utils"]
path = lib/@1inch/solidity-utils
url = https://github.com/1inch/solidity-utils
[submodule "lib/@openzeppelin"]
path = lib/@openzeppelin
url = https://github.com/OpenZeppelin/openzeppelin-contracts
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
node_modules
artifacts
cache
types
forge-out
out
8 changes: 7 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
[
"@semantic-release/github",
{
"successComment": false,
"failTitle": false
}
]
]
}
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"JuanBlanco.solidity",
"dbaeumer.vscode-eslint"
]
"recommendations": ["esbenp.prettier-vscode", "JuanBlanco.solidity"]
}
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
"editor.defaultFormatter": "JuanBlanco.solidity",
"editor.tabSize": 4
},

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"eslint.validate": ["javascript", "typescript"],
"files.eol": "\n",
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
"solidity.packageDefaultDependenciesDirectory": "node_modules",
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.17",
"solidity.formatter": "forge"
}
40 changes: 21 additions & 19 deletions contracts/core/AccountFactoryV3.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: BUSL-1.1
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;
pragma abicoder v1;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";

import {CreditAccountV3} from "../credit/CreditAccountV3.sol";
Expand All @@ -14,8 +15,6 @@ import {
CreditAccountIsInUseException,
MasterCreditAccountAlreadyDeployedException
} from "../interfaces/IExceptions.sol";
import {ACLTrait} from "../traits/ACLTrait.sol";
import {ContractsRegisterTrait} from "../traits/ContractsRegisterTrait.sol";

/// @dev Struct holding factory and queue params for a credit manager
/// @param masterCreditAccount Address of the contract to clone to create new accounts for the credit manager
Expand All @@ -41,9 +40,12 @@ struct QueuedAccount {
/// - When account is returned to the factory, it is only added to the queue after a certain delay, which
/// allows DAO to rescue funds that might have been accidentally left upon account closure, and serves
/// as protection against potential attacks involving reopening an account right after closing it
contract AccountFactoryV3 is IAccountFactoryV3, ACLTrait, ContractsRegisterTrait {
contract AccountFactoryV3 is IAccountFactoryV3, Ownable {
/// @notice Contract version
uint256 public constant override version = 3_00;
uint256 public constant override version = 3_10;

/// @notice Contract type
bytes32 public constant override contractType = "ACCOUNT_FACTORY";

/// @notice Delay after which returned credit accounts can be reused
uint40 public constant override delay = 3 days;
Expand All @@ -55,8 +57,10 @@ contract AccountFactoryV3 is IAccountFactoryV3, ACLTrait, ContractsRegisterTrait
mapping(address => mapping(uint256 => QueuedAccount)) internal _queuedAccounts;

/// @notice Constructor
/// @param addressProvider Address provider contract address
constructor(address addressProvider) ACLTrait(addressProvider) ContractsRegisterTrait(addressProvider) {}
/// @param owner_ Contract owner
constructor(address owner_) {
transferOwnership(owner_);
}

/// @notice Provides a reusable credit account from the queue to the credit manager.
/// If there are no accounts that can be reused in the queue, deploys a new one.
Expand Down Expand Up @@ -114,15 +118,14 @@ contract AccountFactoryV3 is IAccountFactoryV3, ACLTrait, ContractsRegisterTrait
function addCreditManager(address creditManager)
external
override
configuratorOnly // U:[AF-1]
registeredCreditManagerOnly(creditManager) // U:[AF-4A]
onlyOwner // U:[AF-1]
{
if (_factoryParams[creditManager].masterCreditAccount != address(0)) {
revert MasterCreditAccountAlreadyDeployedException(); // U:[AF-4B]
revert MasterCreditAccountAlreadyDeployedException(); // U:[AF-4A]
}
address masterCreditAccount = address(new CreditAccountV3(creditManager)); // U:[AF-4C]
_factoryParams[creditManager].masterCreditAccount = masterCreditAccount; // U:[AF-4C]
emit AddCreditManager(creditManager, masterCreditAccount); // U:[AF-4C]
address masterCreditAccount = address(new CreditAccountV3(creditManager)); // U:[AF-4B]
_factoryParams[creditManager].masterCreditAccount = masterCreditAccount; // U:[AF-4B]
emit AddCreditManager(creditManager, masterCreditAccount); // U:[AF-4B]
}

/// @notice Executes function call from the account to the target contract with provided data,
Expand All @@ -133,18 +136,17 @@ contract AccountFactoryV3 is IAccountFactoryV3, ACLTrait, ContractsRegisterTrait
/// @param data Data to call the target contract with
function rescue(address creditAccount, address target, bytes calldata data)
external
configuratorOnly // U:[AF-1]
override
onlyOwner // U:[AF-1]
{
address creditManager = CreditAccountV3(creditAccount).creditManager();
_ensureRegisteredCreditManager(creditManager); // U:[AF-5A]

(,,,,,,, address borrower) = CreditManagerV3(creditManager).creditAccountInfo(creditAccount);
if (borrower != address(0)) {
revert CreditAccountIsInUseException(); // U:[AF-5B]
revert CreditAccountIsInUseException(); // U:[AF-5A]
}

CreditAccountV3(creditAccount).rescue(target, data); // U:[AF-5C]

emit Rescue(creditAccount, target, data);
CreditAccountV3(creditAccount).rescue(target, data); // U:[AF-5B]
emit Rescue(creditAccount, target, data); // U:[AF-5B]
}
}
113 changes: 0 additions & 113 deletions contracts/core/AddressProviderV3.sol

This file was deleted.

Loading
Loading