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

Commit

Permalink
Refactor ap.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-es committed Feb 25, 2020
1 parent 3c16390 commit 1403836
Show file tree
Hide file tree
Showing 8 changed files with 1,037 additions and 805 deletions.
68 changes: 36 additions & 32 deletions packages/ap.js/src/types/ACTUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export interface Terms {
feeBasis: string | number;
creditEventTypeCovered: string | number;

contractReference_1: ContractReference;
contractReference_2: ContractReference;

currency: string;
settlementCurrency: string;

Expand Down Expand Up @@ -94,6 +91,10 @@ export interface Terms {
priceAtPurchaseDate: number | string;
nextPrincipalRedemptionPayment: number | string;
coverageOfCreditEnhancement: number | string;
lifeCap: number | string;
lifeFloor: number | string;
periodCap: number | string;
periodFloor: number | string;

cycleOfInterestPayment: IPS;
cycleOfRateReset: IPS;
Expand All @@ -104,10 +105,8 @@ export interface Terms {
gracePeriod: IP;
delinquencyPeriod: IP;

lifeCap: number | string;
lifeFloor: number | string;
periodCap: number | string;
periodFloor: number | string;
contractReference_1: ContractReference;
contractReference_2: ContractReference;
}

export interface LifecycleTerms {
Expand All @@ -121,9 +120,6 @@ export interface LifecycleTerms {
feeBasis: string | number;
creditEventTypeCovered: string | number;

contractReference_1: ContractReference;
contractReference_2: ContractReference;

currency: string;
settlementCurrency: string;

Expand All @@ -145,14 +141,16 @@ export interface LifecycleTerms {
priceAtPurchaseDate: number | string;
nextPrincipalRedemptionPayment: number | string;
coverageOfCreditEnhancement: number | string;

gracePeriod: IP;
delinquencyPeriod: IP;

lifeCap: number | string;
lifeFloor: number | string;
periodCap: number | string;
periodFloor: number | string;

gracePeriod: IP;
delinquencyPeriod: IP;

contractReference_1: ContractReference;
contractReference_2: ContractReference;
}

export interface GeneratingTerms {
Expand Down Expand Up @@ -183,15 +181,8 @@ export interface GeneratingTerms {

export interface CustomTerms {
anchorDate: string | number;
notionalPrincipal: number | string;
nominalInterestRate: number | string;
premiumDiscountAtIED: number | string;
rateSpread: number | string;
lifeCap: number | string;
lifeFloor: number | string;
coverageOfCreditEnhancement: number | string;
contractReference_1: ContractReference;
contractReference_2: ContractReference;
overwrittenAttributesMap: string;
overwrittenTerms: LifecycleTerms;
}

export interface TemplateTerms {
Expand All @@ -204,29 +195,35 @@ export interface TemplateTerms {
penaltyType: string | number;
feeBasis: string | number;
creditEventTypeCovered: string | number;

currency: string;
settlementCurrency: string;

marketObjectCodeRateReset: string | number[];

statusDateOffset: number | string;
maturityDateOffset: number | string;

notionalPrincipal: number | string;
nominalInterestRate: number | string;
feeAccrued: number | string;
accruedInterest: number | string;
rateMultiplier: number | string;
rateSpread: number | string;
feeRate: number | string;
nextResetRate: number | string;
penaltyRate: number | string;
premiumDiscountAtIED: number | string;
priceAtPurchaseDate: number | string;
nextPrincipalRedemptionPayment: number | string;
coverageOfCreditEnhancement: number | string;
lifeCap: number | string;
lifeFloor: number | string;
periodCap: number | string;
periodFloor: number | string;

gracePeriod: IP;
delinquencyPeriod: IP;

periodCap: number | string;
periodFloor: number | string;
}

export interface ExtendedTemplateTerms {
Expand All @@ -246,6 +243,7 @@ export interface ExtendedTemplateTerms {

creatorID: string | number[];
counterpartyID: string | number[];

marketObjectCodeRateReset: string | number[];

contractDealDateOffset: number | string;
Expand All @@ -261,14 +259,23 @@ export interface ExtendedTemplateTerms {
cycleAnchorDateOfFeeOffset: number | string;
cycleAnchorDateOfPrincipalRedemptionOffset: number | string;

notionalPrincipal: number | string;
nominalInterestRate: number | string;
feeAccrued: number | string;
accruedInterest: number | string;
rateMultiplier: number | string;
rateSpread: number | string;
feeRate: number | string;
nextResetRate: number | string;
penaltyRate: number | string;
premiumDiscountAtIED: number | string;
priceAtPurchaseDate: number | string;
nextPrincipalRedemptionPayment: number | string;
coverageOfCreditEnhancement: number | string;
lifeCap: number | string;
lifeFloor: number | string;
periodCap: number | string;
periodFloor: number | string;

cycleOfInterestPayment: IPS;
cycleOfRateReset: IPS;
Expand All @@ -278,7 +285,4 @@ export interface ExtendedTemplateTerms {

gracePeriod: IP;
delinquencyPeriod: IP;

periodCap: number | string;
periodFloor: number | string;
}
67 changes: 56 additions & 11 deletions packages/ap.js/src/utils/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
import { LifecycleTerms } from '../types';

export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
export const ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000';
export const ZERO_BYTES = '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';

export const EMPTY_OWNERSHIP = {
creatorObligor: ZERO_ADDRESS,
creatorBeneficiary: ZERO_ADDRESS,
counterpartyObligor: ZERO_ADDRESS,
counterpartyBeneficiary: ZERO_ADDRESS
}
export const EMPTY_IP = {
i: '0',
p: '0',
isSet: false
};

export const EMPTY_LIFECYCLE_TERMS: LifecycleTerms = {
calendar: '0',
contractRole: '0',
dayCountConvention: '0',
businessDayConvention: '0',
endOfMonthConvention: '0',
scalingEffect: '0',
penaltyType: '0',
feeBasis: '0',
creditEventTypeCovered: '0',

currency: '',
settlementCurrency: '',

marketObjectCodeRateReset: '',

statusDate: '0',
maturityDate: '0',

export const EMPTY_CUSTOM_TERMS = {
anchorDate: '0',
notionalPrincipal: '0',
nominalInterestRate: '0',
premiumDiscountAtIED: '0',
feeAccrued: '0',
accruedInterest: '0',
rateMultiplier: '0',
rateSpread: '0',
feeRate: '0',
nextResetRate: '0',
penaltyRate: '0',
premiumDiscountAtIED: '0',
priceAtPurchaseDate: '0',
nextPrincipalRedemptionPayment: '0',
coverageOfCreditEnhancement: '0',
lifeCap: '0',
lifeFloor: '0',
coverageOfCreditEnhancement: '0',
periodCap: '0',
periodFloor: '0',

gracePeriod: EMPTY_IP,
delinquencyPeriod: EMPTY_IP,

contractReference_1: { object: ZERO_BYTES32, contractReferenceType: '0', contractReferenceRole: '0' },
contractReference_2: { object: ZERO_BYTES32, contractReferenceType: '0', contractReferenceRole: '0' }
};

export const EMPTY_OWNERSHIP = {
creatorObligor: ZERO_ADDRESS,
creatorBeneficiary: ZERO_ADDRESS,
counterpartyObligor: ZERO_ADDRESS,
counterpartyBeneficiary: ZERO_ADDRESS
}


export const EMPTY_CUSTOM_TERMS = {
anchorDate: '0',
overwrittenAttributesMap: ZERO_BYTES32,
overwrittenTerms: EMPTY_LIFECYCLE_TERMS
};

export const EMPTY_ENHANCEMENT_PARAMS = {
termsHash: ZERO_BYTES32,
templateId: ZERO_BYTES32,
Expand All @@ -32,4 +77,4 @@ export const EMPTY_ENHANCEMENT_PARAMS = {
creatorSignature: ZERO_BYTES,
counterpartySignature: ZERO_BYTES,
salt: Math.floor(Math.random() * 1000000)
}
};
Loading

0 comments on commit 1403836

Please sign in to comment.