Skip to content

Commit

Permalink
feat: natspec improvements and run natspec check on CI (#72)
Browse files Browse the repository at this point in the history
* chore: run natspec-smells as part of CI

* chore: fix natspec issues
  • Loading branch information
0xteddybear authored Jun 19, 2024
1 parent d7d891c commit 99f6910
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: yarn test:integration

lint:
name: Lint Commit Messages
name: Static Analysis
runs-on: ubuntu-latest

steps:
Expand All @@ -89,4 +89,8 @@ jobs:
- name: Install dependencies
run: yarn --frozen-lockfile --network-concurrency 1

- run: yarn lint:check
- name: Run forge-fmt && solhint
run: yarn lint:check

- name: Run natspec-smells
run: yarn lint:natspec 2>&1 >/dev/null | grep 'No issues found'
4 changes: 3 additions & 1 deletion natspec-smells.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

/** @type {import('@defi-wonderland/natspec-smells').Config} */
module.exports = {
include: 'src/**/*.sol'
enforceInheritdoc: false,
include: 'src/**/*.sol',
exclude: 'src/contracts/B(Num|Const).sol',
};
1 change: 1 addition & 0 deletions src/contracts/BCoWFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract BCoWFactory is BFactory, IBCoWFactory {

/**
* @dev Deploys a BCoWPool instead of a regular BPool.
* @return _pool The deployed BCoWPool
*/
function _newBPool() internal virtual override returns (IBPool _pool) {
return new BCoWPool(SOLUTION_SETTLER, APP_DATA);
Expand Down
1 change: 1 addition & 0 deletions src/contracts/BFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract BFactory is IBFactory {
/**
* @notice Deploys a new BPool.
* @dev Internal function to allow overriding in derived contracts.
* @return _pool The deployed BPool
*/
function _newBPool() internal virtual returns (IBPool _pool) {
return new BPool();
Expand Down
9 changes: 9 additions & 0 deletions src/contracts/BMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ contract BMath is BConst, BNum {
* @param tokenBalanceOut The balance of the output token in the pool
* @param tokenWeightOut The weight of the output token in the pool
* @param swapFee The swap fee of the pool
* @return spotPrice The spot price of a token in terms of another one
* @dev Formula:
* sP = spotPrice
* bI = tokenBalanceIn ( bI / wI ) 1
Expand Down Expand Up @@ -49,6 +50,7 @@ contract BMath is BConst, BNum {
* @param tokenWeightOut The weight of the output token in the pool
* @param tokenAmountIn The amount of the input token
* @param swapFee The swap fee of the pool
* @return tokenAmountOut The amount of token out given the amount of token in for a swap
* @dev Formula:
* aO = tokenAmountOut
* bO = tokenBalanceOut
Expand Down Expand Up @@ -84,6 +86,7 @@ contract BMath is BConst, BNum {
* @param tokenWeightOut The weight of the output token in the pool
* @param tokenAmountOut The amount of the output token
* @param swapFee The swap fee of the pool
* @return tokenAmountIn The amount of token in given the amount of token out for a swap
* @dev Formula:
* aI = tokenAmountIn
* bO = tokenBalanceOut / / bO \ (wO / wI) \
Expand Down Expand Up @@ -120,6 +123,7 @@ contract BMath is BConst, BNum {
* @param totalWeight The total weight of the pool
* @param tokenAmountIn The amount of the input token
* @param swapFee The swap fee of the pool
* @return poolAmountOut The amount of balancer pool tokens that will be minted
* @dev Formula:
* pAo = poolAmountOut / \
* tAi = tokenAmountIn /// / // wI \ \\ \ wI \
Expand Down Expand Up @@ -163,6 +167,7 @@ contract BMath is BConst, BNum {
* @param totalWeight The sum of the weight of all tokens in the pool
* @param poolAmountOut The expected amount of pool tokens
* @param swapFee The swap fee of the pool
* @return tokenAmountIn The amount of token in requred to mint poolAmountIn token pools
* @dev Formula:
* tAi = tokenAmountIn //(pS + pAo)\ / 1 \\
* pS = poolSupply || --------- | ^ | --------- || * bI - bI
Expand Down Expand Up @@ -205,6 +210,8 @@ contract BMath is BConst, BNum {
* @param totalWeight The total weight of the pool
* @param poolAmountIn The amount of pool tokens
* @param swapFee The swap fee of the pool
* @return tokenAmountOut The amount of underlying token out from burning
* poolAmountIn pool tokens
* @dev Formula:
* tAo = tokenAmountOut / / \\
* bO = tokenBalanceOut / // pS - (pAi * (1 - eF)) \ / 1 \ \\
Expand Down Expand Up @@ -251,6 +258,8 @@ contract BMath is BConst, BNum {
* @param totalWeight The total weight of the pool
* @param tokenAmountOut The amount of the output token
* @param swapFee The swap fee of the pool
* @return poolAmountIn The amount of pool tokens to burn in order to receive
* `tokeAmountOut` underlying tokens
* @dev Formula:
* pAi = poolAmountIn // / tAo \\ / wO \ \
* bO = tokenBalanceOut // | bO - -------------------------- |\ | ---- | \
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/IBFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ interface IBFactory {

/**
* @notice Creates a new BPool, assigning the caller as the pool controller
* @return pool The new BPool
* @return _pool The new BPool
*/
function newBPool() external returns (IBPool pool);
function newBPool() external returns (IBPool _pool);

/**
* @notice Sets the BLabs address in the factory
Expand Down

0 comments on commit 99f6910

Please sign in to comment.