@indigo-labs/indigo-sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +52 -7
  2. package/dist/index.d.mts +1064 -182
  3. package/dist/index.d.ts +1064 -182
  4. package/dist/index.js +2565 -561
  5. package/dist/index.mjs +2546 -593
  6. package/package.json +64 -43
  7. package/.nvmrc +0 -1
  8. package/.prettierrc +0 -6
  9. package/babel.config.cjs +0 -13
  10. package/examples/sample-cdp.ts +0 -43
  11. package/jest.config.js +0 -13
  12. package/src/contracts/cdp-creator.ts +0 -86
  13. package/src/contracts/cdp.ts +0 -892
  14. package/src/contracts/collector.ts +0 -91
  15. package/src/contracts/gov.ts +0 -58
  16. package/src/contracts/interest-oracle.ts +0 -49
  17. package/src/contracts/price-oracle.ts +0 -24
  18. package/src/contracts/treasury.ts +0 -95
  19. package/src/helpers/asset-helpers.ts +0 -28
  20. package/src/helpers/cdp-helpers.ts +0 -9
  21. package/src/helpers/helpers.ts +0 -17
  22. package/src/helpers/lucid-utils.ts +0 -24
  23. package/src/helpers/time-helpers.ts +0 -3
  24. package/src/index.ts +0 -23
  25. package/src/scripts/cdp-creator-validator.ts +0 -9
  26. package/src/scripts/cdp-validator.ts +0 -9
  27. package/src/scripts/collector-validator.ts +0 -8
  28. package/src/scripts/interest-oracle-validator.ts +0 -8
  29. package/src/scripts/treasury-validator.ts +0 -8
  30. package/src/types/generic.ts +0 -13
  31. package/src/types/indigo/cdp.ts +0 -33
  32. package/src/types/indigo/gov.ts +0 -21
  33. package/src/types/indigo/interest-oracle.ts +0 -5
  34. package/src/types/indigo/price-oracle.ts +0 -4
  35. package/src/types/system-params.ts +0 -228
  36. package/tests/data/system-params.json +0 -989
  37. package/tests/datums.test.ts +0 -51
  38. package/tests/hash-checks.test.ts +0 -17
  39. package/tests/interest-calculations.test.ts +0 -143
  40. package/tsconfig.json +0 -35
@@ -1,51 +0,0 @@
1
- import { InterestOracleContract } from '../src/contracts/interest-oracle';
2
- import { CDPContract, CDPDatum, PriceOracleContract } from '../src/index';
3
-
4
- describe('Datum checks', () => {
5
- it('Price Oracle', () => {
6
- expect(PriceOracleContract.decodePriceOracleDatum('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff')).toEqual({ price: 1295175n, expiration: 1738766423000n });
7
- expect(PriceOracleContract.encodePriceOracleDatum({ price: 1295175n, expiration: 1738766423000n })).toEqual('d8799fd8799f1a0013c347ff1b00000194d68e13d8ff');
8
- });
9
-
10
- it('Interest Oracle', () => {
11
- expect(InterestOracleContract.decodeInterestOracleDatum('d8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff')).toEqual({ unitaryInterest: 108338304224695572n, interestRate: 200000n, lastUpdated: 1738626287000n });
12
- expect(InterestOracleContract.encodeInterestOracleDatum({ unitaryInterest: 108338304224695572n, interestRate: 200000n, lastUpdated: 1738626287000n })).toEqual('d8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff');
13
- });
14
-
15
- it('CDP', () => {
16
- // Active CDP
17
- const activeCDPDatum = 'd8799fd8799fd8799f581c98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1cff44695553441b00000004d9b0a47ed8799f1b00000194d5ebec201b03022de04fddf5f9ffffff';
18
- const activeCDPObject: CDPDatum = { type: 'CDP', owner: '98e30e1c6dbb727dc98bdcb48b99b313c97fabfb537ff4b29a94ed1c', asset: 'iUSD', mintedAmount: 20832101502n, fees: { type: 'ActiveCDPInterestTracking', last_settled: 1738755796000n, unitary_interest_snapshot: 216786173503075833n } };
19
- expect(CDPContract.decodeCdpDatum(activeCDPDatum)).toEqual(activeCDPObject);
20
- expect(CDPContract.encodeCdpDatum(activeCDPObject)).toEqual(activeCDPDatum);
21
-
22
- // Frozen CDP
23
- const frozenCDPDatum = 'd8799fd8799fd87a8044695553441a0050924ed87a9f1a0002765a1a0003ca56ffffff';
24
- const frozenCDPObject: CDPDatum = { type: 'CDP', owner: undefined, asset: 'iUSD', mintedAmount: 5280334n, fees: { type: 'FrozenCDPAccumulatedFees', lovelaces_treasury: 161370n, lovelaces_indy_stakers: 248406n } };
25
- expect(CDPContract.decodeCdpDatum(frozenCDPDatum)).toEqual(frozenCDPObject);
26
- expect(CDPContract.encodeCdpDatum(frozenCDPObject)).toEqual(frozenCDPDatum);
27
- });
28
-
29
- it('iAsset', () => {
30
- const assetDatum = 'd87a9fd8799f4469455448d87a9fd8799fd8799f581c6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e952694554483230323231323139313931333032ffffffd8799f581c7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef302494d694554485f494e544552455354ffd8799f1a08f0d180ffd8799f1a06dac2c0ffd8799f1a068e7780ffd8799f1a000186a0ffd8799f1a001e8480ffd8799f19c350ffd8799f1a000f4240ffd8799f1a000f4240ffd8799f1a01c9c380ffd87980d8799f4469534f4cffffff';;
31
- const assetObject: CDPDatum = {
32
- type: 'IAsset',
33
- name: 'iETH',
34
- price: [{ unCurrencySymbol: '6c9497ffd7e8baf86c3c0d6fcd43c524daa49ad5fceba26d715468e9'}, {unTokenName: 'iETH20221219191302'}],
35
- interestOracle: [{ unCurrencySymbol: '7b75e317505dddce858ae7bf200656a967c7544e55efa5d18ef30249'}, {unTokenName: 'iETH_INTEREST'}],
36
- redemptionRatioPercentage: {getOnChainInt: 150000000n},
37
- maintenanceRatioPercentage: {getOnChainInt: 115000000n},
38
- liquidationRatioPercentage: {getOnChainInt: 110000000n},
39
- debtMintingFeePercentage: {getOnChainInt: 100000n},
40
- liquidationProcessingFeePercentage: {getOnChainInt: 2000000n},
41
- stabilityPoolWithdrawalFeePercentage: {getOnChainInt: 50000n},
42
- redemptionReimbursementPercentage: {getOnChainInt: 1000000n},
43
- redemptionProcessingFeePercentage: {getOnChainInt: 1000000n},
44
- interestCollectorPortionPercentage: {getOnChainInt: 30000000n},
45
- firstAsset: false,
46
- nextAsset: 'iSOL',
47
- };
48
- expect(CDPContract.decodeCdpDatum(assetDatum)).toEqual(assetObject);
49
- expect(CDPContract.encodeCdpDatum(assetObject)).toEqual(assetDatum);
50
- });
51
- });
@@ -1,17 +0,0 @@
1
- import { loadSystemParamsFromFile, loadSystemParamsFromUrl } from '../src/helpers';
2
- import { CDPCreatorContract } from '../src/contracts/cdp-creator';
3
- import { CDPContract, SystemParams } from '../src';
4
- import { CollectorContract } from '../src/contracts/collector';
5
-
6
- const systemParams = loadSystemParamsFromFile('./tests/data/system-params.json');
7
- describe('Validator Hash checks', () => {
8
- it('CDP Creator validator hash', () => {
9
- expect(CDPCreatorContract.validatorHash(systemParams.cdpCreatorParams)).toBe(systemParams.validatorHashes.cdpCreatorHash);
10
- });
11
- it('CDP validator hash', () => {
12
- expect(CDPContract.validatorHash(systemParams.cdpParams)).toBe(systemParams.validatorHashes.cdpHash);
13
- });
14
- it('Collector validator hash', () => {
15
- expect(CollectorContract.validatorHash(systemParams.collectorParams)).toBe(systemParams.validatorHashes.collectorHash);
16
- });
17
- })
@@ -1,143 +0,0 @@
1
- import { InterestOracleContract } from "../src/contracts/interest-oracle";
2
- import { oneDay } from "../src/helpers/time-helpers";
3
-
4
- describe('Interest Calculations', () => {
5
- describe('Calculate Unitary Interest', () => {
6
- it('Should calculate the unitary interest correctly, 0', () => {
7
- expect(
8
- InterestOracleContract.calculateUnitaryInterestSinceOracleLastUpdated(
9
- oneDay * 6n,
10
- {
11
- unitaryInterest: 684_931_506_849_315n,
12
- interestRate: 100_000n,
13
- lastUpdated: oneDay * 5n
14
- }
15
- )
16
- ).toBe(273_972_602_739_726n);
17
- });
18
-
19
- it('Should calculate the unitary interest correctly, 1', () => {
20
- expect(
21
- InterestOracleContract.calculateUnitaryInterestSinceOracleLastUpdated(
22
- oneDay * 6n,
23
- {
24
- unitaryInterest: 0n,
25
- interestRate: 50_000n,
26
- lastUpdated: 0n
27
- }
28
- )
29
- ).toBe(821_917_808_219_178n);
30
- });
31
-
32
- it('Should calculate the unitary interest correctly, 2', () => {
33
- expect(
34
- InterestOracleContract.calculateUnitaryInterestSinceOracleLastUpdated(
35
- 1n,
36
- {
37
- unitaryInterest: 0n,
38
- interestRate: 1n,
39
- lastUpdated: 0n
40
- }
41
- )
42
- ).toBe(31n);
43
- });
44
- })
45
-
46
- describe('Calculate Accumulated Interest', () => {
47
- it('Should calculate the accumulated interest correctly, 0', () => {
48
- expect(
49
- InterestOracleContract.calculateAccruedInterest(
50
- oneDay,
51
- 0n,
52
- 1_000_000n,
53
- 0n,
54
- {
55
- unitaryInterest: 0n,
56
- interestRate: 50_000n,
57
- lastUpdated: 0n
58
- }
59
- )
60
- ).toBe(136n)
61
- });
62
-
63
- it('Should calculate the accumulated interest correctly, 1', () => {
64
- expect(
65
- InterestOracleContract.calculateAccruedInterest(
66
- oneDay * 6n,
67
- 0n,
68
- 1_000_000n,
69
- 0n,
70
- {
71
- unitaryInterest: 684_931_506_849_315n,
72
- interestRate: 100_000n,
73
- lastUpdated: oneDay * 5n
74
- }
75
- )
76
- ).toBe(684n + 273n)
77
- });
78
-
79
- it('Should calculate the accumulated interest correctly, 2', () => {
80
- expect(
81
- InterestOracleContract.calculateAccruedInterest(
82
- oneDay * 17n,
83
- 0n,
84
- 1_000_000n,
85
- 0n,
86
- {
87
- unitaryInterest: 1_506_849_315_068_493n,
88
- interestRate: 100_000n,
89
- lastUpdated: oneDay * 15n
90
- }
91
- )
92
- ).toBe(1506n + 547n)
93
- });
94
-
95
- it('Should calculate the accumulated interest correctly, 3', () => {
96
- expect(
97
- InterestOracleContract.calculateAccruedInterest(
98
- oneDay * 17n,
99
- 410_958_904_109_589n,
100
- 1_000_000n,
101
- oneDay * 3n,
102
- {
103
- unitaryInterest: 1_506_849_315_068_493n,
104
- interestRate: 100_000n,
105
- lastUpdated: oneDay * 15n
106
- }
107
- )
108
- ).toBe(1095n + 547n)
109
- });
110
-
111
- it('Should calculate the accumulated interest correctly, 4', () => {
112
- expect(
113
- InterestOracleContract.calculateAccruedInterest(
114
- oneDay * 17n,
115
- 767_123_287_671_232n,
116
- 1_000_000n,
117
- oneDay * 6n,
118
- {
119
- unitaryInterest: 1_506_849_315_068_493n,
120
- interestRate: 100_000n,
121
- lastUpdated: oneDay * 15n
122
- }
123
- )
124
- ).toBe(739n + 547n)
125
- });
126
-
127
- it('Should calculate the accumulated interest correctly, 5', () => {
128
- expect(
129
- InterestOracleContract.calculateAccruedInterest(
130
- oneDay * 10n,
131
- 821_917_808_219_178n,
132
- 1_000_000n,
133
- oneDay * 6n,
134
- {
135
- unitaryInterest: 0n,
136
- interestRate: 50_000n,
137
- lastUpdated: 0n
138
- }
139
- )
140
- ).toBe(547n)
141
- });
142
- });
143
- });
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist",
4
- "noImplicitAny": true,
5
- "module": "es2022",
6
- "target": "es2022",
7
- "lib": ["es2022", "DOM"],
8
- "allowJs": true,
9
- "moduleResolution": "node",
10
- "declaration": true,
11
- "strict": true,
12
- "strictNullChecks": true,
13
- "strictFunctionTypes": true,
14
- "strictBindCallApply": true,
15
- "strictPropertyInitialization": false,
16
- "noImplicitThis": true,
17
- "alwaysStrict": false,
18
- "noUnusedLocals": false,
19
- "noUnusedParameters": false,
20
- "noImplicitReturns": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "esModuleInterop": true,
23
- "skipLibCheck": true,
24
- "forceConsistentCasingInFileNames": true,
25
- "resolveJsonModule": true,
26
- "allowSyntheticDefaultImports": true
27
- },
28
- "ts-node": {
29
- "compilerOptions": {
30
- "module": "ES2022",
31
- }
32
- },
33
- "include": ["src/**/*.ts"],
34
- "exclude": ["node_modules", "tests", "dist"],
35
- }