Skip to content

Commit

Permalink
feat: GoodDollar (#522)
Browse files Browse the repository at this point in the history
7704a9b chore: reserve storage gap in new contracts
040b7fe GoodDollar Fork Tests (#530)
2ee14b4 Feat(454): Exchange provider tests  (#529)
578747c test: add BancorExchangeProvider pricing tests (#532)
fcd3d02 feat: improve tests around the expansion controller (#533)
d3a31fa Streamline comments and errors (#528)
ec64f0a fix: ☦ pray to the lords of echidna
13d3a98 fix: add back forge install to the CI step
c236009 fix: echidna tests
c50a198 feat: add Broker liquidity check (#523)
914ba7d Address Slither Issues in GoodDollar/Bancor Contracts (#526)
8bcf3fd Feat/change gdollar modifiers (#524)
379a511 feat: make validate() internal
bcbd9aa chore: added "yarn todo" task to log out open todos in the code
0631c60 refactor: renamed SafeERC20 to SafeERC20MintableBurnable
2800297 feat: simplified SafeERC20
e858391 feat: extend open zeppelin's IERC20 instead of duplicating it
196f6be chore: fixed linter and compiler warnings
096efe2 test: fix fork integration test
e5308d9 feat: add GoodDollar contracts + tests
3135626 feat: update Broker + TradingLimits to 0.8 and make G$ changes
  • Loading branch information
philbow61 authored Oct 24, 2024
1 parent 9349b38 commit 8722c6d
Show file tree
Hide file tree
Showing 48 changed files with 6,799 additions and 402 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CELOSCAN_API_KEY=
CELO_MAINNET_RPC_URL=https://forno.celo.org
BAKLAVA_RPC_URL=https://baklava-forno.celo-testnet.org
ALFAJORES_RPC_URL=https://alfajores-forno.celo-testnet.org
ALFAJORES_RPC_URL=https://alfajores-forno.celo-testnet.org
2 changes: 1 addition & 1 deletion .github/workflows/echidna.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
"test/integration/**/*" \
"test/unit/**/*" \
"test/utils/**/*" \
"script/**/"
"contracts/**/*"
- name: "Run Echidna"
uses: crytic/echidna-action@v2
Expand Down
50 changes: 27 additions & 23 deletions .github/workflows/lint_test.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
name: "CI"
name: CI

env:
FOUNDRY_PROFILE: "ci"
FOUNDRY_PROFILE: ci
ALFAJORES_RPC_URL: ${{secrets.ALFAJORES_RPC_URL}}
CELO_MAINNET_RPC_URL: ${{secrets.CELO_MAINNET_RPC_URL}}

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"
- "develop"
- main
- develop

permissions: read-all

jobs:
lint_and_test:
name: Lint & Test
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: "recursive"
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: "Install Node.js"
uses: "actions/setup-node@v3"
- name: Install Node.js
uses: actions/setup-node@v3
with:
cache: "yarn"
cache: yarn
node-version: "20"

- name: "Install the Node.js dependencies"
run: "yarn install --immutable"
- name: Install the Node.js dependencies
run: yarn install --immutable

- name: "Lint the contracts"
run: "yarn lint"
- name: Lint the contracts
run: yarn lint

- name: "Add lint summary"
- name: Add lint summary
run: |
echo "## Lint" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Show the Foundry config"
run: "forge config"
- name: Show the Foundry config
run: forge config

- name: "Run the tests"
run: "forge test"
- name: Run the tests
run: forge test

- name: "Check contract sizes"
run: "yarn run check-contract-sizes"
- name: Check contract sizes
run: yarn run check-contract-sizes

- name: "Add test summary"
- name: Add test summary
run: |
echo "## Tests" >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
. "$(dirname -- "$0")/_/husky.sh"

yarn lint
yarn todo
35 changes: 19 additions & 16 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,28 @@ trailingComma: all
plugins: [prettier-plugin-solidity]

overrides:
# General Config
- files: ["*.sol"]
options:
compiler: 0.5.17
- files: [contracts/interfaces/*.sol]
- files: [test/**/*.sol]
options:
compiler: ""

# File-specific Config
- files:
[
contracts/common/IERC20MintableBurnable.sol,
contracts/common/SafeERC20MintableBurnable.sol,
contracts/goodDollar/**/*.sol,
contracts/governance/**/*.sol,
contracts/interfaces/*.sol,
contracts/libraries/TradingLimits.sol,
contracts/oracles/Chainlink*.sol,
contracts/swap/Broker.sol,
contracts/tokens/patched/*.sol,
contracts/tokens/StableTokenV2.sol,
]
options:
compiler: 0.8.18
- files:
Expand All @@ -21,18 +39,3 @@ overrides:
- contracts/interfaces/IExchange.sol
options:
compiler: 0.5.17
- files: [contracts/tokens/patched/*.sol]
options:
compiler: 0.8.18
- files: [contracts/tokens/StableTokenV2.sol]
options:
compiler: 0.8.18
- files: [contracts/governance/**/*.sol]
options:
compiler: 0.8.18
- files: [test/**/*.sol]
options:
compiler: ""
- files: [contracts/oracles/Chainlink*.sol]
options:
compiler: 0.8.18
30 changes: 8 additions & 22 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,17 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"no-global-import": "off",
"no-console": "off",
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.5.13"],
"func-visibility": [
"error",
{
"ignoreConstructors": true
}
],
"max-line-length": ["error", 121],
"not-rely-on-time": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"function-max-lines": ["error", 120],
"gas-custom-errors": "off",
"max-line-length": ["error", 121],
"no-console": "off",
"no-empty-blocks": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": [
"warn",
{
"maxLength": 64
}
]
"no-global-import": "off",
"not-rely-on-time": "off",
"prettier/prettier": ["error", { "endOfLine": "auto" }],
"reason-string": ["warn", { "maxLength": 64 }]
}
}
12 changes: 12 additions & 0 deletions contracts/common/IERC20MintableBurnable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pragma solidity ^0.8.0;

import "openzeppelin-contracts-next/contracts/token/ERC20/IERC20.sol";

/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20MintableBurnable is IERC20 {
function mint(address account, uint256 amount) external;
function burn(uint256 amount) external;
}
47 changes: 47 additions & 0 deletions contracts/common/SafeERC20MintableBurnable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pragma solidity ^0.8.0;

import { IERC20MintableBurnable as IERC20 } from "contracts/common/IERC20MintableBurnable.sol";
import { Address } from "openzeppelin-contracts-next/contracts/utils/Address.sol";

/**
* @title SafeERC20MintableBurnable
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20MintableBurnable for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20MintableBurnable {
using Address for address;

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}

function safeMint(IERC20 token, address account, uint256 amount) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.mint.selector, account, amount));
}

function safeBurn(IERC20 token, uint256 amount) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.burn.selector, amount));
}

/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.

bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Loading

0 comments on commit 8722c6d

Please sign in to comment.