Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Merge 173b2d9 into 7c084b8
Browse files Browse the repository at this point in the history
  • Loading branch information
joeb000 committed Sep 10, 2020
2 parents 7c084b8 + 173b2d9 commit 2fb975f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
14 changes: 8 additions & 6 deletions packages/actus-solidity/contracts/Core/Utils/CycleUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.6.11;
pragma experimental ABIEncoderV2;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../../external/BokkyPooBah/BokkyPooBahsDateTimeLibrary.sol";

import "../ACTUSTypes.sol";
Expand All @@ -17,6 +18,7 @@ import "./PeriodUtils.sol";
contract CycleUtils is ACTUSConstants, EndOfMonthConventions, PeriodUtils {

using BokkyPooBahsDateTimeLibrary for uint;
using SafeMath for uint;

/**
* @notice Applies the cycle n - times (n := cycleIndex) to a given date
Expand All @@ -29,17 +31,17 @@ contract CycleUtils is ACTUSConstants, EndOfMonthConventions, PeriodUtils {
uint256 newTimestamp;

if (cycle.p == P.D) {
newTimestamp = cycleStart.addDays(cycle.i * cycleIndex);
newTimestamp = cycleStart.addDays(cycle.i.mul(cycleIndex));
} else if (cycle.p == P.W) {
newTimestamp = cycleStart.addDays(cycle.i * 7 * cycleIndex);
newTimestamp = cycleStart.addDays(cycle.i.mul(7).mul(cycleIndex));
} else if (cycle.p == P.M) {
newTimestamp = cycleStart.addMonths(cycle.i * cycleIndex);
newTimestamp = cycleStart.addMonths(cycle.i.mul(cycleIndex));
} else if (cycle.p == P.Q) {
newTimestamp = cycleStart.addMonths(cycle.i * 3 * cycleIndex);
newTimestamp = cycleStart.addMonths(cycle.i.mul(3).mul(cycleIndex));
} else if (cycle.p == P.H) {
newTimestamp = cycleStart.addMonths(cycle.i * 6 * cycleIndex);
newTimestamp = cycleStart.addMonths(cycle.i.mul(6).mul(cycleIndex));
} else if (cycle.p == P.Y) {
newTimestamp = cycleStart.addYears(cycle.i * cycleIndex);
newTimestamp = cycleStart.addYears(cycle.i.mul(cycleIndex));
} else {
revert("Schedule.getNextCycleDate: ATTRIBUTE_NOT_FOUND");
}
Expand Down
8 changes: 5 additions & 3 deletions packages/actus-solidity/contracts/Core/Utils/PeriodUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.6.11;
pragma experimental ABIEncoderV2;

import {SafeMath as SafeMul} from "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../../external/BokkyPooBah/BokkyPooBahsDateTimeLibrary.sol";

import "../ACTUSTypes.sol";
Expand All @@ -13,6 +14,7 @@ import "../ACTUSTypes.sol";
contract PeriodUtils {

using BokkyPooBahsDateTimeLibrary for uint;
using SafeMul for uint;

/**
* @notice Applies a period in IP notation to a given timestamp
Expand All @@ -27,13 +29,13 @@ contract PeriodUtils {
if (period.p == P.D) {
newTimestamp = timestamp.addDays(period.i);
} else if (period.p == P.W) {
newTimestamp = timestamp.addDays(period.i * 7);
newTimestamp = timestamp.addDays(period.i.mul(7));
} else if (period.p == P.M) {
newTimestamp = timestamp.addMonths(period.i);
} else if (period.p == P.Q) {
newTimestamp = timestamp.addMonths(period.i * 3);
newTimestamp = timestamp.addMonths(period.i.mul(3));
} else if (period.p == P.H) {
newTimestamp = timestamp.addMonths(period.i * 6);
newTimestamp = timestamp.addMonths(period.i.mul(6));
} else if (period.p == P.Y) {
newTimestamp = timestamp.addYears(period.i);
} else {
Expand Down
8 changes: 4 additions & 4 deletions packages/actus-solidity/contracts/Engines/ANN/ANNPOF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ contract ANNPOF is Core {
roleSign(terms.contractRole)
* (
state.nextPrincipalRedemptionPayment
- state.accruedInterest
- timeFromLastEvent
.floatMult(state.nominalInterestRate)
.floatMult(state.notionalPrincipal)
.sub(state.accruedInterest)
.sub(timeFromLastEvent
.floatMult(state.nominalInterestRate)
.floatMult(state.notionalPrincipal))
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion packages/actus-solidity/contracts/Engines/ANN/ANNSTF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ contract ANNSTF is Core {
returns (State memory)
{
// riskFactor not supported
int256 rate = int256(externalData) * terms.rateMultiplier + terms.rateSpread;
int256 rate = int256(externalData).mul(terms.rateMultiplier).add(terms.rateSpread);
int256 deltaRate = rate.sub(state.nominalInterestRate);

// apply period cap/floor
Expand Down
2 changes: 1 addition & 1 deletion packages/actus-solidity/contracts/Engines/CEG/CEGPOF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract CEGPOF is Core {
pure
returns(int256)
{
return state.exerciseAmount + state.feeAccrued;
return state.exerciseAmount.add(state.feeAccrued);
}

/**
Expand Down

0 comments on commit 2fb975f

Please sign in to comment.