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

Add CI for lint, build and test #47

Merged
merged 7 commits into from
Feb 10, 2024
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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CI"

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref}}

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

jobs:
lint:
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-lint.yml@main"

build:
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-build.yml@main"

test-fuzz:
needs: ["lint", "build"]
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test-optimized"
match-path: "test/fuzz/**/*.sol"
name: "Fuzz tests"

test-invariant:
needs: ["lint", "build"]
uses: "Descent-Collective/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test-optimized"
match-path: "test/invariant/**/*.sol"
name: "Invariant tests"
32 changes: 0 additions & 32 deletions .github/workflows/release.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,18 @@ Solidity compiler: [0.8.21]
- Replace open zeppelin with solady.
- Use rounding down for liquidation reward calculation
- Added invariant tests and fix noticed bugs

# Sepolia Version 0.1.1

## Compiler settings

Solidity compiler: [0.8.21]

### contracts
- Vault Contract: `0x3d35807343CbF4fDb16E42297F2214f62848D032`
- Currency Contract(xNGN): `0xB8747e5cce01AA5a51021989BA11aE33097db485`
- Feed Contract `0xFBD26B871D55ba56B7a780eF1fF243Db7A3E81f4`
- Rate Contract `0x00A0BcB0e2099f4a0564c26e24eBfA866D3235D6`

## Changes
- Fix rate config bug
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

| Contract Name | Addresses |
| ------------------------ | ------------------------------------------ |
| Vault Contract | 0x18196CCaA8C2844c82B40a8bDCa27349C7466280 |
| Currency Contract (xNGN) | 0x5d0583Ef20884C0b175046d515Ec227200C12C89 |
| Feed Contract | 0x94D80B2EA3cda86bF350DD7860e1171701F284c8 |
| Rate Contract | 0x774843f6Baa4AAE62F026a8aF3c1C6FF3e55Ca39 |
| Vault Contract | 0x3d35807343CbF4fDb16E42297F2214f62848D032 |
| Currency Contract (xNGN) | 0xB8747e5cce01AA5a51021989BA11aE33097db485 |
| Feed Contract | 0xFBD26B871D55ba56B7a780eF1fF243Db7A3E81f4 |
| Rate Contract | 0x00A0BcB0e2099f4a0564c26e24eBfA866D3235D6 |

To install libraries needed, run:

Expand Down
2 changes: 1 addition & 1 deletion deployConfigs/sepolia.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"liquidationBonus": "10000000000000000000",
"debtCeiling": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
"collateralFloorPerPosition": "0",
"price": "1100"
"price": "1100000000"
}
}
}
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from 932fdd
38 changes: 8 additions & 30 deletions script/base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ pragma solidity 0.8.21;
import {Script, console2} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";

/// modified from sablier base test file
/// modified from sablier base test fil e
abstract contract BaseScript is Script {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
string internal constant TEST_MNEMONIC =
"test test test test test test test test test test test junk";
string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk";

/// @dev Needed for the deterministic deployments.
bytes32 internal constant ZERO_SALT = bytes32(0);
Expand All @@ -31,20 +30,11 @@ abstract contract BaseScript is Script {
if (from != address(0)) {
broadcaster = from;
} else {
mnemonic = vm.envOr({
name: "MNEMONIC",
defaultValue: TEST_MNEMONIC
});
uint256 walletIndex = vm.envOr({
name: "WALLET_INDEX",
defaultValue: uint256(0)
});
mnemonic = vm.envOr({name: "MNEMONIC", defaultValue: TEST_MNEMONIC});
uint256 walletIndex = vm.envOr({name: "WALLET_INDEX", defaultValue: uint256(0)});
require(walletIndex <= type(uint32).max, "Invalid wallet index");

(broadcaster, ) = deriveRememberKey({
mnemonic: mnemonic,
index: uint32(walletIndex)
});
(broadcaster,) = deriveRememberKey({mnemonic: mnemonic, index: uint32(walletIndex)});
}

if (block.chainid == 31_337) {
Expand Down Expand Up @@ -74,23 +64,11 @@ abstract contract BaseScript is Script {

function getDeployConfigJson() internal view returns (string memory json) {
if (currentChain == Chains.BaseGoerli) {
json = vm.readFile(
string.concat(
vm.projectRoot(),
"/deployConfigs/goerli.base.json"
)
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/goerli.base.json"));
} else if (currentChain == Chains.BaseSepolia) {
json = vm.readFile(
string.concat(
vm.projectRoot(),
"/deployConfigs/sepolia.base.json"
)
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/sepolia.base.json"));
} else {
json = vm.readFile(
string.concat(vm.projectRoot(), "/deployConfigs/localnet.json")
);
json = vm.readFile(string.concat(vm.projectRoot(), "/deployConfigs/localnet.json"));
}
}
}
47 changes: 10 additions & 37 deletions script/deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import {SimpleInterestRate, IRate} from "../src/modules/rate.sol";
contract DeployScript is BaseScript {
using stdJson for string;

function run()
external
broadcast
returns (Currency xNGN, Vault vault, Feed feed, IRate rate)
{
function run() external broadcast returns (Currency xNGN, Vault vault, Feed feed, IRate rate) {
string memory deployConfigJson = getDeployConfigJson();
uint256 baseRate = deployConfigJson.readUint(".baseRate");
uint256 debtCeiling = deployConfigJson.readUint(".debtCeiling");
Expand All @@ -39,27 +35,14 @@ contract DeployScript is BaseScript {

console2.log("\n Getting or deploying usdc contract");
ERC20Token usdc = getOrCreateUsdc();
console2.log(
"Usdc gotten or deployed successfully at address:",
address(usdc)
);
console2.log("Usdc gotten or deployed successfully at address:", address(usdc));

console2.log("\n Creating collateral type");
uint256 _rate = deployConfigJson.readUint(
".collaterals.USDC.collateralRate"
);
uint256 _liquidationThreshold = deployConfigJson.readUint(
".collaterals.USDC.liquidationThreshold"
);
uint256 _liquidationBonus = deployConfigJson.readUint(
".collaterals.USDC.liquidationBonus"
);
uint256 _debtCeiling = deployConfigJson.readUint(
".collaterals.USDC.debtCeiling"
);
uint256 _collateralFloorPerPosition = deployConfigJson.readUint(
".collaterals.USDC.collateralFloorPerPosition"
);
uint256 _rate = deployConfigJson.readUint(".collaterals.USDC.collateralRate");
uint256 _liquidationThreshold = deployConfigJson.readUint(".collaterals.USDC.liquidationThreshold");
uint256 _liquidationBonus = deployConfigJson.readUint(".collaterals.USDC.liquidationBonus");
uint256 _debtCeiling = deployConfigJson.readUint(".collaterals.USDC.debtCeiling");
uint256 _collateralFloorPerPosition = deployConfigJson.readUint(".collaterals.USDC.collateralFloorPerPosition");
vault.createCollateralType({
_collateralToken: usdc,
_rate: _rate,
Expand All @@ -73,10 +56,7 @@ contract DeployScript is BaseScript {
console2.log(" Liquidation threshold:", _liquidationThreshold);
console2.log(" Liquidation bonus:", _liquidationBonus);
console2.log(" Debt ceiling:", _debtCeiling);
console2.log(
" Collateral floor per position:",
_collateralFloorPerPosition
);
console2.log(" Collateral floor per position:", _collateralFloorPerPosition);

console2.log("\n Setting feed contract in vault");
vault.updateFeedModule(address(feed));
Expand All @@ -89,10 +69,7 @@ contract DeployScript is BaseScript {
console2.log("\n Updating price of usdc from feed");
uint256 _price = deployConfigJson.readUint(".collaterals.USDC.price");
feed.mockUpdatePrice(usdc, _price);
console2.log(
"Updating price of usdc from feed done successfully to:",
_price
);
console2.log("Updating price of usdc from feed done successfully to:", _price);

console2.log("\n Giving vault minter role for xNGN");
xNGN.setMinterRole(address(vault), true);
Expand All @@ -103,11 +80,7 @@ contract DeployScript is BaseScript {
if (currentChain == Chains.Localnet) {
usdc = new ERC20Token("Circle USD", "USDC", 6);
} else {
usdc = ERC20Token(
getDeployConfigJson().readAddress(
".collaterals.USDC.collateralAddress"
)
);
usdc = ERC20Token(getDeployConfigJson().readAddress(".collaterals.USDC.collateralAddress"));
}
}
}
Loading
Loading