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

fix: slither errors #681

Merged
merged 15 commits into from Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion .github/workflows/slither-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Slither Analysis

on: workflow_dispatch
on: [push, pull_request]
jobs:
slither-analysis:
name: Slither Analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import "../../../../src/dollar/libraries/Constants.sol";
import "forge-std/Script.sol";

contract Constants is Script {
uint256[] shareAmounts;
uint256[] ids;

string uri;
address curve3PoolToken = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
address basePool = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
address curveFactory = 0xB9fC157394Af804a3578134A6585C0dc9cc990d4;
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address admin = vm.envAddress("PUBLIC_KEY");
address constant curve3PoolToken =
0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
address constant basePool = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
address constant curveFactory = 0xB9fC157394Af804a3578134A6585C0dc9cc990d4;
uint256 immutable deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address immutable admin = vm.envAddress("PUBLIC_KEY");

address[] public users = [
0x89eae71B865A2A39cBa62060aB1b40bbFFaE5b0D,
Expand Down Expand Up @@ -55,42 +52,42 @@ contract Constants is Script {
];

uint256[] public lpAmounts = [
1301000000000000000,
3500000000000000000000,
1301e15,
35e20,
9351040526163838324896,
44739174270101943975392,
74603879373206500005186,
2483850000000000000000,
248385e16,
1878674425540571814543,
8991650309086743220575,
1111050988607803612915,
4459109737462155546375,
21723000000000000000000,
38555895255762442000000,
21723e18,
38555895255762442e6,
5919236274824521937931,
1569191092350025897388,
10201450658519659933880,
890339946944155414434,
5021119790948940093253,
761000000000000000000,
761e18,
49172294677407855270013,
25055256356185888278372,
1576757078627228869179,
3664000000000000000000,
3664e18,
1902189597146391302863,
34959771702943278635904,
9380006436252701023610,
6266995559166564365470,
100000000000000000000,
1e20,
3696476262155265118082,
740480000000000000000,
2266000000000000000000,
74048e16,
2266e18,
1480607760433248019987,
24702171480214199310951,
605000000000000000000,
605e18,
1694766661387270251234,
14857000000000000000000,
26000000000000000000
14857e18,
26e18
];
0x4007 marked this conversation as resolved.
Show resolved Hide resolved

uint256[] public terms = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ contract DiamondScript is Constants {
DollarMintCalculatorFacet dollarMintCalculatorFacet;
DollarMintExcessFacet dollarMintExcessFacet;

UbiquityDollarToken IDollar;

address incentive_addr;
string[] facetNames;
address[] facetAddressList;

function run() public virtual {
vm.startBroadcast(deployerPrivateKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ contract DollarScript is DiamondScript {
uint256 adminBal = IERC20(curve3PoolToken).balanceOf(admin);
console.log("----ADMIN 3CRV bal:", adminBal);
// deployer needs 10000 3CRV to deploy the pool
IERC20(curve3PoolToken).transfer(address(diamond), 10000e18);
require(
IERC20(curve3PoolToken).transfer(address(diamond), 10000e18),
"Transfer failed"
);
uint256 diamondBal = IERC20(curve3PoolToken).balanceOf(
address(diamond)
);
Expand All @@ -32,7 +35,7 @@ contract DollarScript is DiamondScript {
basePool,
curve3PoolToken,
10,
5000000
5e6
);

metapool = IManager.stableSwapMetaPoolAddress();
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/slither.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"exclude_informational": true,
"exclude_low": true,
"detectors_to_exclude": "naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality,incorrect-versions-of-solidity,unused-return",
"detectors_to_exclude": "naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality,solc-version,unused-return",
"exclude_medium": false,
"exclude_high": false,
"disable_color": false,
Expand Down
31 changes: 12 additions & 19 deletions packages/contracts/src/dollar/core/ERC1155Ubiquity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {

IAccessControl public accessCtrl;
// Mapping from account to operator approvals
mapping(address => uint256[]) private _holderBalances;
uint256 private _totalSupply;
mapping(address => uint256[]) public holderBalances;
uint256 public totalSupply;

// ----------- Modifiers -----------
modifier onlyMinter() virtual {
Expand Down Expand Up @@ -89,8 +89,8 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
bytes memory data
) public virtual onlyMinter {
_mint(to, id, amount, data);
_totalSupply += amount;
_holderBalances[to].add(id);
totalSupply += amount;
holderBalances[to].add(id);
}

// @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
Expand All @@ -101,12 +101,12 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
bytes memory data
) public virtual onlyMinter whenNotPaused {
_mintBatch(to, ids, amounts, data);
uint256 localTotalSupply = _totalSupply;
uint256 localTotalSupply = totalSupply;
for (uint256 i = 0; i < ids.length; ++i) {
localTotalSupply += amounts[i];
}
_totalSupply = localTotalSupply;
_holderBalances[to].add(ids);
totalSupply = localTotalSupply;
holderBalances[to].add(ids);
}

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
bytes memory data
) public virtual override {
super.safeTransferFrom(from, to, id, amount, data);
_holderBalances[to].add(id);
holderBalances[to].add(id);
}

/**
Expand All @@ -154,14 +154,7 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
bytes memory data
) public virtual override {
super.safeBatchTransferFrom(from, to, ids, amounts, data);
_holderBalances[to].add(ids);
}

/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
holderBalances[to].add(ids);
}

/**
Expand All @@ -170,7 +163,7 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
function holderTokens(
address holder
) public view returns (uint256[] memory) {
return _holderBalances[holder];
return holderBalances[holder];
}

function _burn(
Expand All @@ -179,7 +172,7 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
uint256 amount
) internal virtual override whenNotPaused {
super._burn(account, id, amount);
_totalSupply -= amount;
totalSupply -= amount;
}

function _burnBatch(
Expand All @@ -189,7 +182,7 @@ contract ERC1155Ubiquity is ERC1155, ERC1155Burnable, ERC1155Pausable {
) internal virtual override whenNotPaused {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply -= amounts[i];
totalSupply -= amounts[i];
}
}

Expand Down
17 changes: 4 additions & 13 deletions packages/contracts/src/dollar/core/StakingShare.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ contract StakingShare is ERC1155Ubiquity, ERC1155URIStorage {
}

// Mapping from account to operator approvals
mapping(address => uint256[]) private _holderBalances;
mapping(uint256 => Stake) private _stakes;
uint256 private _totalLP;
uint256 private _totalSupply;

string private _baseURI = "";

Expand Down Expand Up @@ -101,10 +99,10 @@ contract StakingShare is ERC1155Ubiquity, ERC1155URIStorage {
uint256 lpRewardDebt,
uint256 endBlock
) public virtual onlyMinter whenNotPaused returns (uint256 id) {
id = _totalSupply + 1;
id = totalSupply + 1;
_mint(to, id, 1, bytes(""));
_totalSupply += 1;
_holderBalances[to].add(id);
totalSupply += 1;
holderBalances[to].add(id);
Stake storage _stake = _stakes[id];
_stake.minter = to;
_stake.lpFirstDeposited = lpDeposited;
Expand All @@ -128,13 +126,6 @@ contract StakingShare is ERC1155Ubiquity, ERC1155URIStorage {
super.safeTransferFrom(from, to, id, amount, data);
}

/**
* @dev Total amount of tokens .
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}

/**
* @dev Total amount of LP tokens deposited.
*/
Expand Down Expand Up @@ -202,7 +193,7 @@ contract StakingShare is ERC1155Ubiquity, ERC1155URIStorage {
super._burn(account, id, 1);
Stake storage _stake = _stakes[id];
require(_stake.lpAmount == 0, "LP <> 0");
_totalSupply -= 1;
totalSupply -= 1;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ pragma solidity ^0.8.19;

import {LibStakingFormulas} from "../libraries/LibStakingFormulas.sol";
import {StakingShare} from "../core/StakingShare.sol";
import "../interfaces/IUbiquityFormulas.sol";

contract StakingFormulasFacet {
contract StakingFormulasFacet is IUbiquityFormulas {
/// @dev formula Governance Rights corresponding to a staking shares LP amount
/// @param _stake , staking share
/// @param _amount , amount of LP tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {LibUbiquityPool} from "../libraries/LibUbiquityPool.sol";
import {Modifiers} from "../libraries/LibAppStorage.sol";
import {IMetaPool} from "../interfaces/IMetaPool.sol";
import "forge-std/console.sol";
import "../interfaces/IUbiquityPool.sol";

contract UbiquityPoolFacet is Modifiers {
contract UbiquityPoolFacet is Modifiers, IUbiquityPool {
/// @dev Mints 1 UbiquityDollarToken for every 1USD of CollateralToken deposited
/// @param collateralAddress address of collateral token being deposited
/// @param collateralAmount amount of collateral tokens being deposited
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface ICollectableDust {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ contract DiamondInit is Modifiers {
.ubiquityPoolStorage();
poolStore.mintingFee = 0;
poolStore.redemptionFee = 0;
poolStore.dollarFloor = 1000000000000000000;
poolStore.dollarFloor = 1e18;
}
}
58 changes: 0 additions & 58 deletions packages/contracts/src/dollar/utils/CollectableDust.sol
rndquu marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.