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

Commit

Permalink
Refactor actus-solidity
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-es committed Sep 3, 2020
1 parent 7c084b8 commit 43f084e
Show file tree
Hide file tree
Showing 32 changed files with 427 additions and 418 deletions.
69 changes: 65 additions & 4 deletions packages/actus-solidity/contracts/Core/ACTUSTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ struct ContractReference {
ContractReferenceRole role;
}

struct State {
struct UnderlyingState {
int256 exerciseAmount;
bool isSet;
}

struct ANNState {
ContractPerformance contractPerformance;

uint256 statusDate;
uint256 nonPerformingDate;
uint256 maturityDate;
uint256 exerciseDate;
uint256 terminationDate;
uint256 lastCouponDay;

int256 notionalPrincipal;
// int256 notionalPrincipal2;
Expand All @@ -74,16 +77,74 @@ struct State {
int256 interestScalingMultiplier;
int256 notionalScalingMultiplier;
int256 nextPrincipalRedemptionPayment;
}

struct CECState {
ContractPerformance contractPerformance;

uint256 statusDate;
uint256 maturityDate;
uint256 exerciseDate;
uint256 terminationDate;

int256 notionalPrincipal;
int256 feeAccrued;
int256 exerciseAmount;
}

struct CEGState {
ContractPerformance contractPerformance;

uint256 statusDate;
uint256 nonPerformingDate;
uint256 maturityDate;
uint256 exerciseDate;
uint256 terminationDate;

int256 notionalPrincipal;
int256 feeAccrued;
int256 exerciseAmount;
}

struct CERTFState {
ContractPerformance contractPerformance;

uint256 statusDate;
uint256 nonPerformingDate;
uint256 maturityDate;
uint256 exerciseDate;
uint256 terminationDate;
uint256 lastCouponDay;

int256 exerciseAmount;
int256 exerciseQuantity;

int256 quantity;
int256 couponAmountFixed;
// int256 exerciseQuantityOrdered;
int256 marginFactor;
int256 adjustmentFactor;
}

struct PAMState {
ContractPerformance contractPerformance;

uint256 statusDate;
uint256 nonPerformingDate;
uint256 maturityDate;
uint256 terminationDate;

int256 notionalPrincipal;
// int256 notionalPrincipal2;
int256 accruedInterest;
// int256 accruedInterest2;
int256 feeAccrued;
int256 nominalInterestRate;
// int256 nominalInterestRate2;
// int256 interestCalculationBaseAmount;
int256 interestScalingMultiplier;
int256 notionalScalingMultiplier;
}

struct ANNTerms {
ContractType contractType;
Calendar calendar;
Expand Down
22 changes: 10 additions & 12 deletions packages/actus-solidity/contracts/Engines/ANN/ANNEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
*/
function computeStateForEvent(
ANNTerms calldata terms,
State calldata state,
ANNState calldata state,
bytes32 _event,
bytes32 externalData
)
external
pure
override
returns (State memory)
returns (ANNState memory)
{
return stateTransitionFunction(
terms,
Expand All @@ -56,7 +56,7 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
*/
function computePayoffForEvent(
ANNTerms calldata terms,
State calldata state,
ANNState calldata state,
bytes32 _event,
bytes32 externalData
)
Expand Down Expand Up @@ -93,9 +93,9 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
external
pure
override
returns (State memory)
returns (ANNState memory)
{
State memory state;
ANNState memory state;

state.contractPerformance = ContractPerformance.PF;
state.notionalScalingMultiplier = ONE_POINT_ZERO;
Expand Down Expand Up @@ -383,16 +383,14 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
* param _event event for which to check if its still scheduled
* param terms terms of the contract
* param state current state of the contract
* param hasUnderlying boolean indicating whether the contract has an underlying contract
* param underlyingState state of the underlying (empty state object if non-existing)
* @return boolean indicating whether event is still scheduled
*/
function isEventScheduled(
bytes32 /* _event */,
ANNTerms calldata /* terms */,
State calldata /* state */,
bool /* hasUnderlying */,
State calldata /* underlyingState */
ANNState calldata /* state */,
UnderlyingState calldata /* underlyingState */
)
external
pure
Expand All @@ -415,13 +413,13 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
*/
function stateTransitionFunction(
ANNTerms memory terms,
State memory state,
ANNState memory state,
bytes32 _event,
bytes32 externalData
)
internal
pure
returns (State memory)
returns (ANNState memory)
{
(EventType eventType, uint256 scheduleTime) = decodeEvent(_event);

Expand Down Expand Up @@ -461,7 +459,7 @@ contract ANNEngine is Core, ANNSTF, ANNPOF, IANNEngine {
*/
function payoffFunction(
ANNTerms memory terms,
State memory state,
ANNState memory state,
bytes32 _event,
bytes32 externalData
)
Expand Down
16 changes: 8 additions & 8 deletions packages/actus-solidity/contracts/Engines/ANN/ANNPOF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_FP (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 scheduleTime,
bytes32 /* externalData */
)
Expand Down Expand Up @@ -59,7 +59,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_IED (
ANNTerms memory terms,
State memory /* state */,
ANNState memory /* state */,
uint256 /* scheduleTime */,
bytes32 /* externalData */
)
Expand All @@ -81,7 +81,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_IP (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 scheduleTime,
bytes32 /* externalData */
)
Expand Down Expand Up @@ -118,7 +118,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_PP (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 /* scheduleTime */,
bytes32 /* externalData */
)
Expand All @@ -138,7 +138,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_MD (
ANNTerms memory /* terms */,
State memory state,
ANNState memory state,
uint256 /* scheduleTime */,
bytes32 /* externalData */
)
Expand All @@ -158,7 +158,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_PY (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 scheduleTime,
bytes32 /* externalData */
)
Expand Down Expand Up @@ -203,7 +203,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_TD (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 scheduleTime,
bytes32 /* externalData */
)
Expand Down Expand Up @@ -240,7 +240,7 @@ contract ANNPOF is Core {
*/
function POF_ANN_PR (
ANNTerms memory terms,
State memory state,
ANNState memory state,
uint256 scheduleTime,
bytes32 /* externalData */
)
Expand Down
Loading

0 comments on commit 43f084e

Please sign in to comment.