Skip to content

Commit

Permalink
chore: live balances milestone (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase authored Jun 10, 2024
2 parents c9e0b37 + 45d29b1 commit e9edf1f
Show file tree
Hide file tree
Showing 29 changed files with 1,109 additions and 993 deletions.
1 change: 1 addition & 0 deletions .forge-snapshots/newBFactory.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3811528
1 change: 1 addition & 0 deletions .forge-snapshots/newBPool.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3567680
2 changes: 1 addition & 1 deletion .forge-snapshots/swapExactAmountIn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
116075
107618
19 changes: 6 additions & 13 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["off"],
"avoid-low-level-calls": "off",
"constructor-syntax": "warn",
"quotes": ["error", "single"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"private-vars-leading-underscore": ["warn", { "strict": false }],
"ordering": "warn",
"immutable-name-snakecase": "warn",
"avoid-low-level-calls": "off",
"no-console": "off",
"max-line-length": ["warn", 120],
"private-vars-leading-underscore": ["warn", { "strict": false }],
"quotes": "off",
"one-contract-per-file": "warn",
"TODO": "REMOVE_TEMPORARY_LINTER_SETTINGS_BELOW",
"custom-errors": "off",
"one-contract-per-file": "off",
"definition-name-capwords": "off"
"style-guide-casing": ["warn", { "ignoreEvents": true } ],
"custom-errors": "off"
}
}
27 changes: 0 additions & 27 deletions .solhint.tests.json

This file was deleted.

2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ multiline_func_header = 'params_first'
sort_imports = true

[profile.default]
solc_version = '0.8.23'
solc_version = '0.8.25'
libs = ["node_modules", "lib"]
optimizer_runs = 50 # TODO: increase for production and add via-ir
ffi = true
Expand Down
2 changes: 1 addition & 1 deletion natspec-smells.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

/** @type {import('@defi-wonderland/natspec-smells').Config} */
module.exports = {
include: 'src'
include: 'src/**/*.sol'
};
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@
"coverage": "forge coverage --match-contract Unit",
"deploy:mainnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"deploy:testnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'",
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
"lint:check": "solhint 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol' && forge fmt --check",
"lint:fix": "solhint --fix 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol' && sort-package-json && forge fmt",
"lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js",
"lint:sol-logic": "solhint -c .solhint.json 'src/**/*.sol' 'script/**/*.sol'",
"lint:sol-tests": "solhint -c .solhint.tests.json 'test/**/*.sol'",
"prepare": "husky install",
"smock": "smock-foundry --contracts src/contracts",
"test": "forge test -vvv",
"test:integration": "forge test --match-contract Integration -vvv",
"test:local": "FOUNDRY_FUZZ_RUNS=100 forge test -vvv",
"test:unit": "forge test --match-contract Unit -vvv",
"test:unit:deep": "FOUNDRY_FUZZ_RUNS=5000 yarn test:unit"
},
"lint-staged": {
"*.{js,css,md,ts,sol}": "forge fmt",
"(src|script)/**/*.sol": "yarn lint:sol-logic",
"test/**/*.sol": "yarn lint:sol-tests",
"(src|script|test)/**/*.sol": "yarn lint:check",
"package.json": "sort-package-json"
},
"dependencies": {
"@openzeppelin/contracts": "5.0.2",
"solmate": "github:transmissions11/solmate#c892309"
},
"devDependencies": {
Expand All @@ -48,7 +47,7 @@
"forge-std": "github:foundry-rs/forge-std#5475f85",
"husky": ">=8",
"lint-staged": ">=10",
"solhint": "github:solhint-community/solhint-community#v4.0.0-rc01",
"solhint-community": "4.0.0",
"sort-package-json": "2.10.0"
}
}
}
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ forge-std/=node_modules/forge-std/src
forge-gas-snapshot/=node_modules/forge-gas-snapshot/src
solmate/=node_modules/solmate/src

contracts/=src/contracts
contracts/=src/contracts
interfaces/=src/interfaces
2 changes: 1 addition & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BFactory} from 'contracts/BFactory.sol';
import {Params} from 'script/Params.s.sol';
Expand Down
2 changes: 1 addition & 1 deletion script/Params.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity 0.8.25;

contract Params {
struct DeploymentParams {
Expand Down
12 changes: 0 additions & 12 deletions src/contracts/BColor.sol

This file was deleted.

6 changes: 2 additions & 4 deletions src/contracts/BConst.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {BBronze} from './BColor.sol';

contract BConst is BBronze {
contract BConst {
uint256 public constant BONE = 10 ** 18;

uint256 public constant MIN_BOUND_TOKENS = 2;
Expand Down
35 changes: 20 additions & 15 deletions src/contracts/BFactory.sol
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.23;
pragma solidity 0.8.25;

// Builds new BPools, logging their addresses and providing `isBPool(address) -> (bool)`

import {BBronze} from './BColor.sol';
import {BPool} from './BPool.sol';
import {IERC20} from './BToken.sol';

contract BFactory is BBronze {
import {IBFactory} from 'interfaces/IBFactory.sol';
import {IBPool} from 'interfaces/IBPool.sol';

/**
* @title BFactory
* @notice Creates new BPools, logging their addresses and acting as a registry of pools.
*/
contract BFactory is IBFactory {
/// @dev Mapping indicating whether the address is a BPool.
mapping(address => bool) internal _isBPool;
/// @dev bLabs address.
address internal _blabs;

event LOG_NEW_POOL(address indexed caller, address indexed pool);

event LOG_BLABS(address indexed caller, address indexed blabs);

constructor() {
_blabs = msg.sender;
}

function newBPool() external returns (BPool) {
BPool bpool = new BPool();
/// @inheritdoc IBFactory
function newBPool() external returns (IBPool _pool) {
IBPool bpool = new BPool();
_isBPool[address(bpool)] = true;
emit LOG_NEW_POOL(msg.sender, address(bpool));
bpool.setController(msg.sender);
return bpool;
}

/// @inheritdoc IBFactory
function setBLabs(address b) external {
require(msg.sender == _blabs, 'ERR_NOT_BLABS');
emit LOG_BLABS(msg.sender, b);
_blabs = b;
}

function collect(BPool pool) external {
/// @inheritdoc IBFactory
function collect(IBPool pool) external {
require(msg.sender == _blabs, 'ERR_NOT_BLABS');
uint256 collected = IERC20(pool).balanceOf(address(this));
uint256 collected = pool.balanceOf(address(this));
bool xfer = pool.transfer(_blabs, collected);
require(xfer, 'ERR_ERC20_FAILED');
}

/// @inheritdoc IBFactory
function isBPool(address b) external view returns (bool) {
return _isBPool[b];
}

/// @inheritdoc IBFactory
function getBLabs() external view returns (address) {
return _blabs;
}
Expand Down
Loading

0 comments on commit e9edf1f

Please sign in to comment.