Skip to content

Commit

Permalink
missing inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcodercrane committed Nov 9, 2022
1 parent 2863521 commit 3578638
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 36 deletions.
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": "similar-names,naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality,incorrect-versions-of-solidity",
"detectors_to_exclude": "naming-conventions,different-pragma-directives-are-used,external-function,assembly,incorrect-equality,incorrect-versions-of-solidity",
"exclude_medium": false,
"exclude_high": false,
"disable_color": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/dollar/DebtCoupon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ pragma solidity 0.8.16;
import "./ERC1155Ubiquity.sol";
import "solidity-linked-list/contracts/StructuredLinkedList.sol";
import "./UbiquityAlgorithmicDollarManager.sol";
import {IDebtCoupon} from "./interfaces/IDebtCoupon.sol";

/// @title A coupon redeemable for dollars with an expiry block number
/// @notice An ERC1155 where the token ID is the expiry block number
/// @dev Implements ERC1155 so receiving contracts must implement IERC1155Receiver
contract DebtCoupon is ERC1155Ubiquity {
contract DebtCoupon is ERC1155Ubiquity, IDebtCoupon {
using StructuredLinkedList for StructuredLinkedList.List;

//not public as if called externally can give inaccurate value. see method
Expand Down
19 changes: 10 additions & 9 deletions packages/contracts/src/dollar/TWAPOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
pragma solidity 0.8.16;

import "./interfaces/IMetaPool.sol";
import {ITWAPOracle} from "./interfaces/ITWAPOracle.sol";

contract TWAPOracle {
contract TWAPOracle is ITWAPOracle {
address public immutable pool;
address public immutable token0;
address public immutable token1;
uint256 public price0Average;
uint256 public price1Average;
uint256 public uADPrice;
uint256 public curve3CRVAverage;
uint256 public pricesBlockTimestampLast;
uint256[2] public priceCumulativeLast;

Expand All @@ -34,8 +35,8 @@ contract TWAPOracle {
priceCumulativeLast = IMetaPool(_pool).get_price_cumulative_last();
pricesBlockTimestampLast = IMetaPool(_pool).block_timestamp_last();

price0Average = 1 ether;
price1Average = 1 ether;
uADPrice = 1 ether;
curve3CRVAverage = 1 ether;
}

// calculate average price
Expand All @@ -52,9 +53,9 @@ contract TWAPOracle {
);

// price to exchange amounIn uAD to 3CRV based on TWAP
price0Average = IMetaPool(pool).get_dy(0, 1, 1 ether, twapBalances);
uADPrice = IMetaPool(pool).get_dy(0, 1, 1 ether, twapBalances);
// price to exchange amounIn 3CRV to uAD based on TWAP
price1Average = IMetaPool(pool).get_dy(1, 0, 1 ether, twapBalances);
curve3CRVAverage = IMetaPool(pool).get_dy(1, 0, 1 ether, twapBalances);
// we update the priceCumulative
priceCumulativeLast = priceCumulative;
pricesBlockTimestampLast = blockTimestamp;
Expand All @@ -66,11 +67,11 @@ contract TWAPOracle {
function consult(address token) external view returns (uint256 amountOut) {
if (token == token0) {
// price to exchange 1 uAD to 3CRV based on TWAP
amountOut = price0Average;
amountOut = uADPrice;
} else {
require(token == token1, "TWAPOracle: INVALID_TOKEN");
// price to exchange 1 3CRV to uAD based on TWAP
amountOut = price1Average;
amountOut = curve3CRVAverage;
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/dollar/UbiquityFormulas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
pragma solidity 0.8.16;

import "abdk-libraries-solidity/ABDKMathQuad.sol";
import {IUbiquityFormulas} from "./interfaces/IUbiquityFormulas.sol";

contract UbiquityFormulas {
contract UbiquityFormulas is IUbiquityFormulas {
using ABDKMathQuad for uint256;
using ABDKMathQuad for bytes16;

Expand Down
24 changes: 0 additions & 24 deletions packages/contracts/src/dollar/utils/SafeAddArray.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,6 @@ pragma solidity 0.8.16;
*
*/
library SafeAddArray {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
*/
function add(bytes32[] storage array, bytes32 value) internal {
for (uint256 i; i < array.length; i++) {
if (array[i] == value) {
return;
}
}
array.push(value);
}

function add(string[] storage array, string memory value) internal {
bytes32 hashValue = keccak256(bytes(value));
for (uint256 i; i < array.length; i++) {
if (keccak256(bytes(array[i])) == hashValue) {
return;
}
}
array.push(value);
}

function add(uint256[] storage array, uint256 value) internal {
for (uint256 i; i < array.length; i++) {
if (array[i] == value) {
Expand Down

1 comment on commit 3578638

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on 3578638 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.