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

Commit

Permalink
Add types and conversion methods for STK to sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-es committed Oct 21, 2020
1 parent b737509 commit 907ba1f
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 150 deletions.
37 changes: 24 additions & 13 deletions packages/protocol/__tests__/Default-Terms.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,75 @@
"contractPerformance": 0,
"couponType": 0,
"creditEventTypeCovered": 0,
"redeemableByIssuer": 0,

"currency": "0x0000000000000000000000000000000000000000",
"settlementCurrency": "0x0000000000000000000000000000000000000000",
"marketObjectCodeRateReset": "0x00",

"contractDealDate": 1356652800,
"statusDate": 1356825600,
"initialExchangeDate": 1356998400,
"issueDate": 1356998400,
"maturityDate": 1388534400,
"purchaseDate": 0,
"capitalizationEndDate": 0,
"nonPerformingDate": 0,
"issueDate": 1356998400,

"cycleAnchorDateOfInterestPayment": 1356998400,
"cycleAnchorDateOfRateReset": 0,
"cycleAnchorDateOfScalingIndex": 0,
"cycleAnchorDateOfFee": 0,
"cycleAnchorDateOfPrincipalRedemption": 1356998400,

"cycleAnchorDateOfRedemption": 1598918400,
"cycleAnchorDateOfTermination": 0,
"cycleAnchorDateOfCoupon": 0,
"cycleAnchorDateOfDividend": 0,

"notionalPrincipal": "3000000000000000000000",
"nominalPrice": "100000000000000000000",
"issuePrice": "100000000000000000000",
"quantity": "100000000000000000000000",
"nominalInterestRate": "100000000000000000",
"feeAccrued": 0,
"accruedInterest": 0,
"rateMultiplier": "1000000000000000000",
"rateSpread": 0,
"nextResetRate": 0,
"feeRate": 0,
"feeAccrued": 0,
"penaltyRate": 0,
"delinquencyRate": 0,
"couponRate": 0,
"denominationRatio": 0,
"premiumDiscountAtIED": 0,
"priceAtPurchaseDate": 0,
"redemptionPrice": 0,
"nextPrincipalRedemptionPayment": 0,
"coverageOfCreditEnhancement": 1,
"lifeCap": 0,
"lifeFloor": 0,
"periodCap": 0,
"periodFloor": 0,
"nominalPrice": "100000000000000000000",
"issuePrice": "100000000000000000000",
"quantity": "100000000000000000000000",
"denominationRatio": 0,
"couponRate": 0,
"nextPrincipalRedemptionPayment": 0,
"coverageOfCreditEnhancement": 1,

"gracePeriod": { "i": 0, "p": 0, "isSet": false },
"delinquencyPeriod": { "i": 0, "p": 0, "isSet": false },
"settlementPeriod": { "i": "10", "p": 0, "isSet": true },
"fixingPeriod": { "i": "0", "p": 0, "isSet": true },
"redemptionExercisePeriod": { "i": "5", "p": 0, "isSet": true },
"redemptionRecordPeriod": { "i": 0, "p": 0, "isSet": false },
"redemptionPaymentPeriod": { "i": 0, "p": 0, "isSet": false },
"dividendRecordPeriod": { "i": 0, "p": 0, "isSet": false },
"dividendPaymentPeriod": { "i": 0, "p": 0, "isSet": false },
"splitSettlementPeriod": { "i": 0, "p": 0, "isSet": false },

"cycleOfInterestPayment": { "i": 1, "p": 2, "s": 0, "isSet": true },
"cycleOfRateReset": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfScalingIndex": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfFee": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfPrincipalRedemption": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfRedemption": { "i": "3", "p": 2, "s": 1, "isSet": true },
"cycleOfTermination": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfCoupon": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfPrincipalRedemption": { "i": 0, "p": 0, "s": 0, "isSet": false },
"cycleOfDividend": { "i": 0, "p": 0, "s": 0, "isSet": false },

"contractReference_1": {
"object": "0x0000000000000000000000000000000000000000000000000000000000000001",
"object2": "0x0000000000000000000000000000000000000000000000000000000000000001",
Expand Down
8 changes: 7 additions & 1 deletion packages/protocol/__tests__/apis/Utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Web3 from 'web3';
import ADDRESS_BOOK from '../../ap-chain/addresses.json';

import { Utils, Contracts } from '../../src/apis';
import { Terms, isPAMTerms, isANNTerms, isCERTFTerms, isCECTerms, isCEGTerms } from '../../src/types';
import { Terms, isPAMTerms, isANNTerms, isCERTFTerms, isCECTerms, isCEGTerms, isSTKTerms } from '../../src/types';
import { removeNullEvents } from '../../src/utils/Schedule';

import DEFAULT_TERMS from '../Default-Terms.json';
Expand Down Expand Up @@ -105,6 +105,12 @@ describe('Utils', (): void => {
const pamTerms = Utils.conversion.extractPAMTerms(terms);
expect(isPAMTerms(pamTerms))
});

it('should convert full terms to STKTerms', async (): Promise<void> => {
const terms: Terms = DEFAULT_TERMS;
const stkTerms = Utils.conversion.extractSTKTerms(terms);
expect(isSTKTerms(stkTerms))
});
});

});
Loading

0 comments on commit 907ba1f

Please sign in to comment.